From 9393a96320b6b00c0dae0de90cdab366fdad7761 Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Fri, 15 Sep 2023 21:24:25 -0400 Subject: [PATCH] Messing around with the buildscripts --- buildSrc/src/main/kotlin/AdapterConfig.kt | 5 +++-- buildSrc/src/main/kotlin/CommonJavaConfig.kt | 7 +++--- buildSrc/src/main/kotlin/LibsConfig.kt | 11 ++++++++++ buildSrc/src/main/kotlin/PlatformConfig.kt | 23 ++++++++++++-------- worldedit-bukkit/build.gradle.kts | 4 +++- worldedit-core/build.gradle.kts | 4 +++- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/buildSrc/src/main/kotlin/AdapterConfig.kt b/buildSrc/src/main/kotlin/AdapterConfig.kt index 60f9a5733..52be679e6 100644 --- a/buildSrc/src/main/kotlin/AdapterConfig.kt +++ b/buildSrc/src/main/kotlin/AdapterConfig.kt @@ -3,12 +3,13 @@ import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.dependencies // For specific version pinning, see -// https://papermc.io/repo/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/ -fun Project.applyPaperweightAdapterConfiguration() { +// https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/ +fun Project.applyPaperweightAdapterConfiguration(javaRelease: Int = 17) { applyCommonConfiguration() apply(plugin = "java-library") applyCommonJavaConfiguration( sourcesJar = true, + javaRelease = javaRelease, banSlf4j = false, ) apply(plugin = "io.papermc.paperweight.userdev") diff --git a/buildSrc/src/main/kotlin/CommonJavaConfig.kt b/buildSrc/src/main/kotlin/CommonJavaConfig.kt index 549a26037..4c4ded483 100644 --- a/buildSrc/src/main/kotlin/CommonJavaConfig.kt +++ b/buildSrc/src/main/kotlin/CommonJavaConfig.kt @@ -11,9 +11,8 @@ 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) { +fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, javaRelease: Int = 17, banSlf4j: Boolean = true) { applyCommonConfiguration() - apply(plugin = "eclipse") apply(plugin = "idea") tasks @@ -23,7 +22,7 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean val disabledLint = listOf( "processing", "path", "fallthrough", "serial" ) - options.release.set(17) + options.release.set(javaRelease) options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" }) options.isDeprecation = true options.encoding = "UTF-8" @@ -49,6 +48,7 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean // Java 8 turns on doclint which we fail tasks.withType().configureEach { + options.encoding = "UTF-8" (options as StandardJavadocDocletOptions).apply { addStringOption("Xdoclint:none", "-quiet") tags( @@ -56,7 +56,6 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean "implSpec:a:Implementation Requirements:", "implNote:a:Implementation Note:" ) - options.encoding = "UTF-8" links( "https://jd.advntr.dev/api/latest/", "https://logging.apache.org/log4j/2.x/log4j-api/apidocs/", diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt index 4fd69cb65..4fb319b2e 100644 --- a/buildSrc/src/main/kotlin/LibsConfig.kt +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -49,13 +49,20 @@ fun Project.applyLibrariesConfiguration() { configurations = listOf(project.configurations["shade"]) archiveClassifier.set("") + // Yeet module-info's + exclude("module-info.class") + dependencies { exclude(dependency("com.google.guava:guava")) exclude(dependency("com.google.code.gson:gson")) exclude(dependency("com.google.errorprone:error_prone_annotations")) exclude(dependency("org.checkerframework:checker-qual")) + exclude(dependency("org.jetbrains:annotations")) exclude(dependency("org.apache.logging.log4j:log4j-api")) exclude(dependency("com.google.code.findbugs:jsr305")) + exclude { + it.moduleGroup == "org.jetbrains.kotlin" + } } relocations.forEach { (from, to) -> @@ -85,6 +92,10 @@ fun Project.applyLibrariesConfiguration() { from({ altConfigFiles("sources") }) + + // Yeet module-info's + exclude("module-info.java") + relocations.forEach { (from, to) -> val filePattern = Regex("(.*)${from.replace('.', '/')}((?:/|$).*)") val textPattern = Regex.fromLiteral(from) diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 807ee9e8a..5a15110fb 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -17,10 +17,7 @@ import org.gradle.plugins.signing.SigningExtension fun Project.applyPlatformAndCoreConfiguration() { applyCommonConfiguration() apply(plugin = "java") - apply(plugin = "eclipse") - apply(plugin = "idea") apply(plugin = "maven-publish") - apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "signing") applyCommonJavaConfiguration( @@ -42,11 +39,6 @@ fun Project.applyPlatformAndCoreConfiguration() { the().withSourcesJar() } - val javaComponent = components["java"] as AdhocComponentWithVariants - javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { - skip() - } - val publishingExtension = the() configure { @@ -62,7 +54,14 @@ fun Project.applyPlatformAndCoreConfiguration() { configure { publications { register("maven") { - from(javaComponent) + versionMapping { + usage("java-api") { + fromResolutionOf("runtimeClasspath") + } + usage("java-runtime") { + fromResolutionResult() + } + } group = "com.fastasyncworldedit" artifactId = "${rootProject.name}-${project.description}" @@ -128,6 +127,7 @@ fun Project.applyPlatformAndCoreConfiguration() { } fun Project.applyShadowConfiguration() { + apply(plugin = "com.github.johnrengelman.shadow") tasks.named("shadowJar") { dependencies { include(project(":worldedit-libs:core")) @@ -141,6 +141,11 @@ fun Project.applyShadowConfiguration() { exclude("META-INF/maven/**") minimize() } + val javaComponent = components["java"] as AdhocComponentWithVariants + // I don't think we want this published (it's the shadow jar) + javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { + skip() + } } val CLASSPATH = listOf("truezip", "truevfs", "js") diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 4f7211db5..0daab21c6 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -44,6 +44,8 @@ val localImplementation = configurations.create("localImplementation") { isCanBeConsumed = false isCanBeResolved = false } +configurations["compileOnly"].extendsFrom(localImplementation) +configurations["testImplementation"].extendsFrom(localImplementation) val adapters = configurations.create("adapters") { description = "Adapters to include in the JAR" @@ -75,8 +77,8 @@ dependencies { // Platform expectations compileOnly(libs.paper) { - exclude("junit", "junit") exclude(group = "org.slf4j", module = "slf4j-api") + exclude("junit", "junit") } // Logging diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index a58230b2c..c2eb52029 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -31,7 +31,9 @@ dependencies { implementation(libs.snakeyaml) // Logging - implementation(libs.log4jApi) + implementation(libs.log4jApi) { + because("Mojang provides Log4J") + } // Plugins compileOnly(libs.plotSquaredCore) { isTransitive = false }