blob: f1c8c15f05d1e1be9484e6cf7df96ebd12d64dbf [file] [log] [blame]
Marc Kupietz4f6ed422024-03-01 07:27:46 +01001plugins {
2 // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
Marc Kupietzde917592025-10-31 15:44:27 +01003 id 'org.jetbrains.kotlin.jvm' version '2.2.21'
Marc Kupietz4f6ed422024-03-01 07:27:46 +01004
5 // Apply the application plugin to add support for building a CLI application in Java.
6 id 'application'
Marc Kupietz1b595992024-03-01 14:54:30 +01007 id 'com.github.johnrengelman.shadow' version '8.1.1'
Marc Kupietz4f6ed422024-03-01 07:27:46 +01008}
9
Marc Kupietz4f6ed422024-03-01 07:27:46 +010010repositories {
Marc Kupietz4f6ed422024-03-01 07:27:46 +010011 mavenCentral()
Marc Kupietz56a45562024-03-20 20:18:08 +010012 maven { url 'https://jitpack.io' }
Marc Kupietz4f6ed422024-03-01 07:27:46 +010013}
14
Marc Kupietz47b43c32024-03-27 20:43:32 +010015test {
Marc Kupietzfc18d282025-08-31 12:07:46 +020016 minHeapSize = "512m"
17 maxHeapSize = "4096m"
18 jvmArgs '-XX:MaxMetaspaceSize=1024m'
Marc Kupietz47b43c32024-03-27 20:43:32 +010019}
20
Marc Kupietz4f6ed422024-03-01 07:27:46 +010021dependencies {
22 // Align versions of all Kotlin components
23 implementation platform('org.jetbrains.kotlin:kotlin-bom')
24
25 // Use the Kotlin JDK 8 standard library.
26 implementation 'org.jetbrains.kotlin:kotlin-stdlib'
Marc Kupietzfc18d282025-08-31 12:07:46 +020027 implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2'
Marc Kupietz4f6ed422024-03-01 07:27:46 +010028
29 // This dependency is used by the application.
Marc Kupietzde917592025-10-31 15:44:27 +010030 implementation 'com.google.guava:guava:33.5.0-jre'
Marc Kupietz4f6ed422024-03-01 07:27:46 +010031
Marc Kupietz31122362024-03-02 11:13:37 +010032
Marc Kupietzfc18d282025-08-31 12:07:46 +020033 implementation ("info.picocli:picocli:4.7.7")
Marc Kupietz31122362024-03-02 11:13:37 +010034
Marc Kupietz4f6ed422024-03-01 07:27:46 +010035 // Use the Kotlin test library.
36 testImplementation 'org.jetbrains.kotlin:kotlin-test'
37
38 // Use the Kotlin JUnit integration.
39 testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
Marc Kupietzde917592025-10-31 15:44:27 +010040 testImplementation "org.jetbrains.kotlin:kotlin-test:2.2.21"
Marc Kupietz0c6e8772024-03-19 07:03:07 +010041
Marc Kupietz1465ce22024-03-26 09:51:17 +010042 implementation 'com.github.kupietz:cistern:v1.0.4'
Marc Kupietzaf682a42024-03-22 06:51:55 +010043 implementation 'org.maltparser:maltparser:1.9.2'
Marc Kupietzde917592025-10-31 15:44:27 +010044 implementation 'org.apache.opennlp:opennlp-tools:2.5.6'
Marc Kupietzfc18d282025-08-31 12:07:46 +020045 implementation 'org.slf4j:slf4j-simple:2.0.17'
Marc Kupietz916bdfe2024-09-20 09:02:57 +020046 implementation 'org.apache.ant:ant:1.10.15'
Marc Kupietzfc18d282025-08-31 12:07:46 +020047 implementation 'org.apache.commons:commons-compress:1.28.0'
Marc Kupietzd698f0e2025-11-01 20:00:07 +010048 implementation 'me.tongfei:progressbar:0.10.1'
Marc Kupietza92bacb2024-04-06 20:26:05 +020049
Marc Kupietz4f6ed422024-03-01 07:27:46 +010050}
51
Marc Kupietz64dce822025-11-02 14:39:39 +010052// Enforce JDK 21 Toolchain and Bytecode-Level 21
Marc Kupietz8d875cc2025-10-31 15:36:33 +010053java {
54 toolchain {
55 languageVersion = JavaLanguageVersion.of(21)
56 }
57}
Marc Kupietz4f6ed422024-03-01 07:27:46 +010058
Marc Kupietz8d875cc2025-10-31 15:36:33 +010059kotlin {
60 jvmToolchain(21)
61}
62
Marc Kupietz64dce822025-11-02 14:39:39 +010063// For any existing Java source code
Marc Kupietz8d875cc2025-10-31 15:36:33 +010064tasks.withType(JavaCompile).configureEach {
65 options.release = 21
66}
67
68tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
69 kotlinOptions {
70 jvmTarget = "21"
Marc Kupietz64dce822025-11-02 14:39:39 +010071 // If available, this ensures consistent API targets similar to Java --release
Marc Kupietz8d875cc2025-10-31 15:36:33 +010072 // freeCompilerArgs += ["-Xjdk-release=21"]
73 }
74}
Marc Kupietz9da19db2024-04-01 11:06:51 +020075
Marc Kupietz64dce822025-11-02 14:39:39 +010076// Explicitly inherit version from root project
Marc Kupietzf13fc7b2025-10-31 17:28:21 +010077version = rootProject.version
78
Marc Kupietz4f6ed422024-03-01 07:27:46 +010079application {
80 // Define the main class for the application.
Marc Kupietz07c60d32025-01-21 19:32:48 +010081 mainClass = 'de.ids_mannheim.korapxmltools.KorapXmlToolKt'
Marc Kupietz4f6ed422024-03-01 07:27:46 +010082}
83
84jar {
Marc Kupietz64dce822025-11-02 14:39:39 +010085 // Mark standard JAR as "plain" to avoid conflicts with ShadowJar
Marc Kupietzf13fc7b2025-10-31 17:28:21 +010086 archiveClassifier.set('plain')
Marc Kupietz4f6ed422024-03-01 07:27:46 +010087 manifest.attributes(
88 'Class-Path': configurations.compileClasspath.collect { it.getName() }.join(' '),
Marc Kupietzde917592025-10-31 15:44:27 +010089 'Main-Class': "de.ids_mannheim.korapxmltools.KorapXmlToolKt",
90 'Implementation-Title': rootProject.name,
91 'Implementation-Version': project.version
Marc Kupietz4f6ed422024-03-01 07:27:46 +010092 )
Marc Kupietzf13fc7b2025-10-31 17:28:21 +010093}
94
95shadowJar {
96 archiveBaseName.set('korapxmltool')
97 archiveClassifier.set('')
98 archiveVersion.set(project.version.toString())
99 manifest.attributes(
100 'Main-Class': "de.ids_mannheim.korapxmltools.KorapXmlToolKt",
101 'Implementation-Title': rootProject.name,
102 'Implementation-Version': project.version
103 )
104}
105
Marc Kupietz64dce822025-11-02 14:39:39 +0100106// Ensure that assemble also creates the ShadowJar
Marc Kupietzf13fc7b2025-10-31 17:28:21 +0100107tasks.named('assemble') {
108 dependsOn tasks.named('shadowJar')
109}
110
Marc Kupietz64dce822025-11-02 14:39:39 +0100111// Additionally create a symlink korapxmltool.jar to the current version for stable script paths
112tasks.register('createJarSymlink') {
113 dependsOn shadowJar
114 doLast {
115 def targetJar = shadowJar.archiveFile.get().asFile
116 def linkFile = new File(targetJar.parent, 'korapxmltool.jar')
117
118 // Remove existing symlink or file
119 if (linkFile.exists()) {
120 linkFile.delete()
121 }
122
123 // Create symlink (Java 7+ NIO)
124 try {
125 java.nio.file.Files.createSymbolicLink(
126 linkFile.toPath(),
127 java.nio.file.Paths.get(targetJar.name)
128 )
129 println "Created symlink: ${linkFile.name} -> ${targetJar.name}"
130 } catch (Exception e) {
131 // Fallback to copy on systems where symlinks aren't supported
132 println "Warning: Could not create symlink (${e.message}), copying instead"
133 java.nio.file.Files.copy(targetJar.toPath(), linkFile.toPath())
134 }
135 }
Marc Kupietzf13fc7b2025-10-31 17:28:21 +0100136}
137
138tasks.named('build') {
Marc Kupietz64dce822025-11-02 14:39:39 +0100139 dependsOn createJarSymlink
Marc Kupietz4f6ed422024-03-01 07:27:46 +0100140}
141
142
143configurations {
144 runtimeLib.extendsFrom implementation
145}