logging/gradle/compile/java.gradle

48 lines
1.2 KiB
Groovy
Raw Normal View History

2024-07-05 22:23:39 +02:00
apply plugin: 'java-library'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
modularity.inferModulePath.set(true)
withSourcesJar()
withJavadocJar()
}
jar {
manifest {
attributes('Implementation-Version': project.version)
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.withType(JavaCompile).configureEach {
doFirst {
options.fork = true
options.forkOptions.jvmArgs += ['-Duser.language=en', '-Duser.country=US']
options.encoding = 'UTF-8'
// -classfile because of log4j2 issues "warning: Cannot find annotation method"
options.compilerArgs.add('-Xlint:all,-classfile')
options.compilerArgs.add("--module-version")
options.compilerArgs.add(project.version as String)
options.compilerArgs.add("--module-path")
options.compilerArgs.add(classpath.asPath)
classpath = files()
}
}
tasks.withType(Javadoc).configureEach {
doFirst {
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
}
}
tasks.withType(JavaExec).configureEach {
doFirst {
jvmArguments.add("--module-path")
jvmArguments.add(classpath.asPath)
classpath = files()
}
}