blob: c50eecbc42b84f24cb888b75a2f18f160ed5bfb6 [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 Kupietzddea0c02025-11-15 19:53:38 +010045 implementation 'edu.stanford.nlp:stanford-corenlp:3.9.2'
Marc Kupietzfc18d282025-08-31 12:07:46 +020046 implementation 'org.slf4j:slf4j-simple:2.0.17'
Marc Kupietz916bdfe2024-09-20 09:02:57 +020047 implementation 'org.apache.ant:ant:1.10.15'
Marc Kupietzfc18d282025-08-31 12:07:46 +020048 implementation 'org.apache.commons:commons-compress:1.28.0'
Marc Kupietzd698f0e2025-11-01 20:00:07 +010049 implementation 'me.tongfei:progressbar:0.10.1'
Marc Kupietza92bacb2024-04-06 20:26:05 +020050
Marc Kupietz4f6ed422024-03-01 07:27:46 +010051}
52
Marc Kupietz64dce822025-11-02 14:39:39 +010053// Enforce JDK 21 Toolchain and Bytecode-Level 21
Marc Kupietz8d875cc2025-10-31 15:36:33 +010054java {
55 toolchain {
56 languageVersion = JavaLanguageVersion.of(21)
57 }
58}
Marc Kupietz4f6ed422024-03-01 07:27:46 +010059
Marc Kupietz8d875cc2025-10-31 15:36:33 +010060kotlin {
61 jvmToolchain(21)
62}
63
Marc Kupietz64dce822025-11-02 14:39:39 +010064// For any existing Java source code
Marc Kupietz8d875cc2025-10-31 15:36:33 +010065tasks.withType(JavaCompile).configureEach {
66 options.release = 21
67}
68
69tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
70 kotlinOptions {
71 jvmTarget = "21"
Marc Kupietz64dce822025-11-02 14:39:39 +010072 // If available, this ensures consistent API targets similar to Java --release
Marc Kupietz8d875cc2025-10-31 15:36:33 +010073 // freeCompilerArgs += ["-Xjdk-release=21"]
74 }
75}
Marc Kupietz9da19db2024-04-01 11:06:51 +020076
Marc Kupietz64dce822025-11-02 14:39:39 +010077// Explicitly inherit version from root project
Marc Kupietzf13fc7b2025-10-31 17:28:21 +010078version = rootProject.version
79
Marc Kupietz4f6ed422024-03-01 07:27:46 +010080application {
81 // Define the main class for the application.
Marc Kupietz07c60d32025-01-21 19:32:48 +010082 mainClass = 'de.ids_mannheim.korapxmltools.KorapXmlToolKt'
Marc Kupietz4f6ed422024-03-01 07:27:46 +010083}
84
85jar {
Marc Kupietz64dce822025-11-02 14:39:39 +010086 // Mark standard JAR as "plain" to avoid conflicts with ShadowJar
Marc Kupietzf13fc7b2025-10-31 17:28:21 +010087 archiveClassifier.set('plain')
Marc Kupietz4f6ed422024-03-01 07:27:46 +010088 manifest.attributes(
89 'Class-Path': configurations.compileClasspath.collect { it.getName() }.join(' '),
Marc Kupietzde917592025-10-31 15:44:27 +010090 'Main-Class': "de.ids_mannheim.korapxmltools.KorapXmlToolKt",
91 'Implementation-Title': rootProject.name,
92 'Implementation-Version': project.version
Marc Kupietz4f6ed422024-03-01 07:27:46 +010093 )
Marc Kupietzf13fc7b2025-10-31 17:28:21 +010094}
95
96shadowJar {
97 archiveBaseName.set('korapxmltool')
98 archiveClassifier.set('')
99 archiveVersion.set(project.version.toString())
100 manifest.attributes(
101 'Main-Class': "de.ids_mannheim.korapxmltools.KorapXmlToolKt",
102 'Implementation-Title': rootProject.name,
103 'Implementation-Version': project.version
104 )
105}
106
Marc Kupietz64dce822025-11-02 14:39:39 +0100107// Ensure that assemble also creates the ShadowJar
Marc Kupietzf13fc7b2025-10-31 17:28:21 +0100108tasks.named('assemble') {
109 dependsOn tasks.named('shadowJar')
110}
111
Marc Kupietz64dce822025-11-02 14:39:39 +0100112// Additionally create a symlink korapxmltool.jar to the current version for stable script paths
113tasks.register('createJarSymlink') {
114 dependsOn shadowJar
115 doLast {
116 def targetJar = shadowJar.archiveFile.get().asFile
117 def linkFile = new File(targetJar.parent, 'korapxmltool.jar')
118
119 // Remove existing symlink or file
120 if (linkFile.exists()) {
121 linkFile.delete()
122 }
123
124 // Create symlink (Java 7+ NIO)
125 try {
126 java.nio.file.Files.createSymbolicLink(
127 linkFile.toPath(),
128 java.nio.file.Paths.get(targetJar.name)
129 )
130 println "Created symlink: ${linkFile.name} -> ${targetJar.name}"
131 } catch (Exception e) {
132 // Fallback to copy on systems where symlinks aren't supported
133 println "Warning: Could not create symlink (${e.message}), copying instead"
134 java.nio.file.Files.copy(targetJar.toPath(), linkFile.toPath())
135 }
136 }
Marc Kupietzf13fc7b2025-10-31 17:28:21 +0100137}
138
139tasks.named('build') {
Marc Kupietz64dce822025-11-02 14:39:39 +0100140 dependsOn createJarSymlink
Marc Kupietz4f6ed422024-03-01 07:27:46 +0100141}
142
143
144configurations {
145 runtimeLib.extendsFrom implementation
146}