net/gradle/compile/java.gradle

57 lines
1.6 KiB
Groovy
Raw Permalink Normal View History

2022-10-20 09:43:33 +02:00
apply plugin: 'java-library'
java {
2023-09-30 15:33:07 +02:00
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
2022-10-20 09:43:33 +02:00
modularity.inferModulePath.set(true)
2023-04-05 20:23:01 +02:00
withSourcesJar()
withJavadocJar()
2022-10-20 09:43:33 +02:00
}
jar {
manifest {
2024-07-30 19:14:47 +02:00
attributes('Implementation-Name': project.name)
2022-10-20 09:43:33 +02:00
attributes('Implementation-Version': project.version)
2024-07-30 19:14:47 +02:00
attributes('Implementation-Vendor': project.vendor)
attributes('X-Compile-Source-JDK': JavaLanguageVersion.of(21).toString())
attributes('X-Compile-Target-JDK': JavaLanguageVersion.of(21).toString())
2022-10-20 09:43:33 +02:00
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
2024-07-30 19:14:47 +02:00
from (project.file('.')) {
include 'LICENSE.txt'
include 'NOTICE.txt'
into 'META-INF'
}
2022-10-20 09:43:33 +02:00
}
2024-04-05 15:31:06 +02:00
tasks.withType(JavaCompile).configureEach {
2024-03-04 13:54:05 +01:00
doFirst {
options.fork = true
2024-04-05 15:31:06 +02:00
options.forkOptions.jvmArgs += ['-Duser.language=en', '-Duser.country=US']
2024-03-04 13:54:05 +01:00
options.encoding = 'UTF-8'
options.compilerArgs.add('-Xlint:all')
// enforce presence of module-info.java
2024-04-15 15:34:55 +02:00
options.compilerArgs.add("--module-version")
options.compilerArgs.add(project.version as String)
2024-03-04 13:54:05 +01:00
options.compilerArgs.add("--module-path")
options.compilerArgs.add(classpath.asPath)
classpath = files()
}
2022-11-04 16:49:11 +01:00
}
2024-04-05 15:31:06 +02:00
tasks.withType(Javadoc).configureEach {
2024-03-04 13:54:05 +01:00
doFirst {
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
}
}
2024-04-05 15:31:06 +02:00
tasks.withType(JavaExec).configureEach {
2024-03-04 13:54:05 +01:00
doFirst {
jvmArguments.add("--module-path")
jvmArguments.add(classpath.asPath)
classpath = files()
}
2022-11-04 16:49:11 +01:00
}