2021-10-17 14:32:36 +00:00
|
|
|
import org.gradle.api.Project
|
|
|
|
import org.gradle.api.attributes.java.TargetJvmVersion
|
|
|
|
import org.gradle.api.plugins.JavaPluginExtension
|
|
|
|
import org.gradle.api.tasks.compile.JavaCompile
|
|
|
|
import org.gradle.api.tasks.javadoc.Javadoc
|
|
|
|
import org.gradle.api.tasks.testing.Test
|
|
|
|
import org.gradle.external.javadoc.StandardJavadocDocletOptions
|
|
|
|
import org.gradle.kotlin.dsl.apply
|
|
|
|
import org.gradle.kotlin.dsl.configure
|
|
|
|
import org.gradle.kotlin.dsl.dependencies
|
|
|
|
import org.gradle.kotlin.dsl.get
|
|
|
|
import org.gradle.kotlin.dsl.withType
|
|
|
|
|
|
|
|
fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean = true) {
|
|
|
|
applyCommonConfiguration()
|
|
|
|
apply(plugin = "eclipse")
|
|
|
|
apply(plugin = "idea")
|
|
|
|
|
|
|
|
tasks
|
|
|
|
.withType<JavaCompile>()
|
|
|
|
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
|
|
|
|
.configureEach {
|
|
|
|
val disabledLint = listOf(
|
|
|
|
"processing", "path", "fallthrough", "serial"
|
|
|
|
)
|
2021-11-22 12:38:32 +00:00
|
|
|
options.release.set(17)
|
2021-10-17 14:32:36 +00:00
|
|
|
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
|
|
|
|
options.isDeprecation = true
|
|
|
|
options.encoding = "UTF-8"
|
|
|
|
options.compilerArgs.add("-parameters")
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations.all {
|
2021-11-22 12:38:32 +00:00
|
|
|
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
|
2021-10-17 14:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType<Test>().configureEach {
|
|
|
|
useJUnitPlatform()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
"compileOnly"("com.google.code.findbugs:jsr305:3.0.2")
|
2023-08-09 18:52:18 +00:00
|
|
|
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
|
|
|
"testImplementation"("org.junit.jupiter:junit-jupiter-params:5.10.0")
|
|
|
|
"testImplementation"("org.mockito:mockito-core:5.4.0")
|
|
|
|
"testImplementation"("org.mockito:mockito-junit-jupiter:5.4.0")
|
|
|
|
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.10.0")
|
2021-10-17 14:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Java 8 turns on doclint which we fail
|
|
|
|
tasks.withType<Javadoc>().configureEach {
|
|
|
|
(options as StandardJavadocDocletOptions).apply {
|
|
|
|
addStringOption("Xdoclint:none", "-quiet")
|
|
|
|
tags(
|
|
|
|
"apiNote:a:API Note:",
|
|
|
|
"implSpec:a:Implementation Requirements:",
|
|
|
|
"implNote:a:Implementation Note:"
|
|
|
|
)
|
|
|
|
options.encoding = "UTF-8"
|
|
|
|
links(
|
2023-03-06 23:04:44 +00:00
|
|
|
"https://jd.advntr.dev/api/latest/",
|
2022-06-17 13:09:32 +00:00
|
|
|
"https://logging.apache.org/log4j/2.x/log4j-api/apidocs/",
|
2021-10-17 14:32:36 +00:00
|
|
|
"https://www.antlr.org/api/Java/",
|
|
|
|
"https://docs.enginehub.org/javadoc/org.enginehub.piston/core/0.5.7/",
|
|
|
|
"https://docs.enginehub.org/javadoc/org.enginehub.piston/default-impl/0.5.7/",
|
2023-06-29 10:23:26 +00:00
|
|
|
"https://jd.papermc.io/paper/1.20/",
|
2022-06-17 13:09:32 +00:00
|
|
|
"https://intellectualsites.github.io/fastasyncworldedit-javadocs/worldedit-core/"
|
2021-10-17 14:32:36 +00:00
|
|
|
)
|
2022-06-29 21:18:39 +00:00
|
|
|
docTitle = "${rootProject.name}-${project.description}" + " " + "${rootProject.version}"
|
2021-10-17 14:32:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configure<JavaPluginExtension> {
|
|
|
|
disableAutoTargetJvm()
|
|
|
|
withJavadocJar()
|
|
|
|
if (sourcesJar) {
|
|
|
|
withSourcesJar()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (banSlf4j) {
|
|
|
|
configurations["compileClasspath"].apply {
|
|
|
|
resolutionStrategy.componentSelection {
|
|
|
|
withModule("org.slf4j:slf4j-api") {
|
|
|
|
reject("No SLF4J allowed on compile classpath")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|