2019-08-26 04:45:03 +00:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
|
|
|
import org.gradle.api.JavaVersion
|
|
|
|
import org.gradle.api.Project
|
|
|
|
import org.gradle.api.plugins.JavaPluginConvention
|
|
|
|
import org.gradle.api.tasks.bundling.Jar
|
2020-08-14 19:29:15 +00:00
|
|
|
import org.gradle.api.tasks.compile.JavaCompile
|
2019-08-26 04:45:03 +00:00
|
|
|
import org.gradle.api.tasks.javadoc.Javadoc
|
|
|
|
import org.gradle.api.tasks.testing.Test
|
2020-01-07 21:11:47 +00:00
|
|
|
import org.gradle.external.javadoc.StandardJavadocDocletOptions
|
2019-08-26 04:45:03 +00:00
|
|
|
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.getByName
|
|
|
|
import org.gradle.kotlin.dsl.named
|
|
|
|
import org.gradle.kotlin.dsl.register
|
|
|
|
import org.gradle.kotlin.dsl.withType
|
|
|
|
|
|
|
|
fun Project.applyPlatformAndCoreConfiguration() {
|
|
|
|
applyCommonConfiguration()
|
|
|
|
apply(plugin = "java")
|
2020-10-05 17:41:41 +00:00
|
|
|
apply(plugin = "eclipse")
|
2019-08-26 04:45:03 +00:00
|
|
|
apply(plugin = "idea")
|
2021-01-18 20:58:50 +00:00
|
|
|
apply(plugin = "maven-publish")
|
2019-08-26 04:45:03 +00:00
|
|
|
apply(plugin = "com.github.johnrengelman.shadow")
|
|
|
|
|
2021-04-19 10:56:34 +00:00
|
|
|
if (project.hasProperty("buildnumber")) {
|
|
|
|
ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}"
|
|
|
|
} else {
|
|
|
|
ext["internalVersion"] = "$version"
|
|
|
|
}
|
2021-05-14 21:42:37 +00:00
|
|
|
|
2020-08-14 19:29:15 +00:00
|
|
|
tasks
|
|
|
|
.withType<JavaCompile>()
|
|
|
|
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
|
|
|
|
.configureEach {
|
|
|
|
val disabledLint = listOf(
|
|
|
|
"processing", "path", "fallthrough", "serial"
|
|
|
|
)
|
2021-07-01 20:16:25 +00:00
|
|
|
options.release.set(11)
|
2021-07-24 20:48:58 +00:00
|
|
|
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
|
2020-08-14 19:29:15 +00:00
|
|
|
options.isDeprecation = false
|
|
|
|
options.encoding = "UTF-8"
|
2021-02-25 21:58:17 +00:00
|
|
|
options.compilerArgs.add("-parameters")
|
2020-08-14 19:29:15 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 04:45:03 +00:00
|
|
|
|
|
|
|
tasks.withType<Test>().configureEach {
|
|
|
|
useJUnitPlatform()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2021-02-11 16:59:03 +00:00
|
|
|
"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
|
|
|
|
"testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}")
|
|
|
|
"testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}")
|
|
|
|
"testImplementation"("org.mockito:mockito-junit-jupiter:${Versions.MOCKITO}")
|
2021-05-07 21:47:35 +00:00
|
|
|
"testImplementation"("net.bytebuddy:byte-buddy:1.11.0")
|
2021-05-14 21:42:37 +00:00
|
|
|
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}")
|
2019-08-26 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Java 8 turns on doclint which we fail
|
|
|
|
tasks.withType<Javadoc>().configureEach {
|
2020-08-14 19:29:15 +00:00
|
|
|
(options as StandardJavadocDocletOptions).apply {
|
|
|
|
addStringOption("Xdoclint:none", "-quiet")
|
|
|
|
tags(
|
|
|
|
"apiNote:a:API Note:",
|
|
|
|
"implSpec:a:Implementation Requirements:",
|
|
|
|
"implNote:a:Implementation Note:"
|
|
|
|
)
|
|
|
|
}
|
2019-08-26 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register<Jar>("javadocJar") {
|
|
|
|
dependsOn("javadoc")
|
2021-07-01 20:16:25 +00:00
|
|
|
archiveClassifier.set(null as String?)
|
|
|
|
archiveFileName.set("${rootProject.name}-${project.description}-${project.version}-javadoc.${archiveExtension.getOrElse("jar")}")
|
2019-08-26 04:45:03 +00:00
|
|
|
from(tasks.getByName<Javadoc>("javadoc").destinationDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named("assemble").configure {
|
|
|
|
dependsOn("javadocJar")
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
add("archives", tasks.named("jar"))
|
|
|
|
add("archives", tasks.named("javadocJar"))
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == "worldedit-core" || name == "worldedit-bukkit") {
|
|
|
|
tasks.register<Jar>("sourcesJar") {
|
|
|
|
dependsOn("classes")
|
2021-07-01 20:16:25 +00:00
|
|
|
archiveClassifier.set(null as String?)
|
|
|
|
archiveFileName.set("${rootProject.name}-${project.description}-${project.version}-sources.${archiveExtension.getOrElse("jar")}")
|
2019-08-26 04:45:03 +00:00
|
|
|
from(sourceSets["main"].allSource)
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
add("archives", tasks.named("sourcesJar"))
|
|
|
|
}
|
|
|
|
tasks.named("assemble").configure {
|
|
|
|
dependsOn("sourcesJar")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-09 09:08:17 +00:00
|
|
|
if (name != "worldedit-fabric") {
|
|
|
|
configurations["compileClasspath"].apply {
|
|
|
|
resolutionStrategy.componentSelection {
|
|
|
|
withModule("org.slf4j:slf4j-api") {
|
|
|
|
reject("No SLF4J allowed on compile classpath")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fun Project.applyShadowConfiguration() {
|
|
|
|
tasks.named<ShadowJar>("shadowJar") {
|
|
|
|
dependencies {
|
|
|
|
include(project(":worldedit-libs:core"))
|
|
|
|
include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}"))
|
|
|
|
include(project(":worldedit-core"))
|
2021-01-25 10:14:09 +00:00
|
|
|
exclude("com.google.code.findbugs:jsr305")
|
2019-08-26 04:45:03 +00:00
|
|
|
}
|
|
|
|
exclude("GradleStart**")
|
|
|
|
exclude(".cache")
|
|
|
|
exclude("LICENSE*")
|
2019-11-19 21:25:36 +00:00
|
|
|
exclude("META-INF/maven/**")
|
2019-08-26 04:45:03 +00:00
|
|
|
minimize()
|
|
|
|
}
|
|
|
|
}
|
2020-01-11 03:32:12 +00:00
|
|
|
|
2019-12-16 11:00:12 +00:00
|
|
|
val CLASSPATH = listOf("truezip", "truevfs", "js")
|
|
|
|
.map { "$it.jar" }
|
2021-04-10 21:28:20 +00:00
|
|
|
.flatMap { listOf(it, "FastAsyncWorldEdit/$it") }
|
2019-12-16 11:00:12 +00:00
|
|
|
.joinToString(separator = " ")
|
2021-02-25 21:58:17 +00:00
|
|
|
|
|
|
|
sealed class WorldEditKind(
|
2021-07-01 20:16:25 +00:00
|
|
|
val name: String,
|
|
|
|
val mainClass: String = "com.sk89q.worldedit.internal.util.InfoEntryPoint"
|
2021-02-25 21:58:17 +00:00
|
|
|
) {
|
|
|
|
class Standalone(mainClass: String) : WorldEditKind("STANDALONE", mainClass)
|
|
|
|
object Mod : WorldEditKind("MOD")
|
|
|
|
object Plugin : WorldEditKind("PLUGIN")
|
|
|
|
}
|
|
|
|
|
|
|
|
fun Project.addJarManifest(kind: WorldEditKind, includeClasspath: Boolean = false) {
|
|
|
|
tasks.named<Jar>("jar") {
|
|
|
|
val version = project(":worldedit-core").version
|
|
|
|
inputs.property("version", version)
|
|
|
|
val attributes = mutableMapOf(
|
2021-07-01 20:16:25 +00:00
|
|
|
"Implementation-Version" to version,
|
|
|
|
"WorldEdit-Version" to version,
|
|
|
|
"WorldEdit-Kind" to kind.name,
|
|
|
|
"Main-Class" to kind.mainClass
|
2021-02-25 21:58:17 +00:00
|
|
|
)
|
|
|
|
if (includeClasspath) {
|
|
|
|
attributes["Class-Path"] = CLASSPATH
|
|
|
|
}
|
|
|
|
manifest.attributes(attributes)
|
|
|
|
}
|
|
|
|
}
|