diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 9bb4cb22a..302d78f8f 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -44,7 +44,7 @@ implementation("com.github.jengelman.gradle.plugins:shadow:6.1.0") implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0") implementation("org.spongepowered:SpongeGradle:0.11.5") - // implementation("net.minecraftforge.gradle:ForgeGradle:4.1.12") + implementation("net.minecraftforge.gradle:ForgeGradle:5.0.9") implementation("net.fabricmc:fabric-loom:$loomVersion") implementation("net.fabricmc:sponge-mixin:$mixinVersion") implementation("org.enginehub.gradle:gradle-codecov-plugin:0.1.0") diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 8ecb9344c..15e6991b3 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -1,5 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.api.Project +import org.gradle.api.component.AdhocComponentWithVariants import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.plugins.quality.CheckstyleExtension import org.gradle.api.publish.PublishingExtension @@ -32,7 +33,6 @@ apply(plugin = "idea") apply(plugin = "maven-publish") apply(plugin = "checkstyle") - apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.jfrog.artifactory") ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}" @@ -82,7 +82,7 @@ the().withJavadocJar() - if (name == "worldedit-core" || name == "worldedit-bukkit") { + if (name in setOf("worldedit-core", "worldedit-bukkit", "worldedit-fabric")) { the().withSourcesJar() } @@ -93,7 +93,6 @@ configure { publications { register("maven") { - from(components["java"]) versionMapping { usage("java-api") { fromResolutionOf("runtimeClasspath") @@ -110,6 +109,7 @@ } fun Project.applyShadowConfiguration() { + apply(plugin = "com.github.johnrengelman.shadow") tasks.named("shadowJar") { archiveClassifier.set("dist") dependencies { @@ -124,6 +124,11 @@ 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() + } } private val CLASSPATH = listOf("truezip", "truevfs", "js") diff --git a/settings.gradle.kts b/settings.gradle.kts index 05a48affc..a37fe1ca6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,8 +2,7 @@ include("worldedit-libs") -// Forge has been removed until FG 5 is available. -listOf("bukkit", "core", "sponge", "fabric", "cli").forEach { +listOf("bukkit", "core", "sponge", "fabric", "forge", "cli").forEach { include("worldedit-libs:$it") include("worldedit-$it") } diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 2b086e539..b15997eba 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -18,17 +18,27 @@ } } +val localImplementation = configurations.create("localImplementation") { + description = "Dependencies used locally, but provided by the runtime Bukkit implementation" + isCanBeConsumed = false + isCanBeResolved = false +} +configurations["compileOnly"].extendsFrom(localImplementation) +configurations["testImplementation"].extendsFrom(localImplementation) + dependencies { "api"(project(":worldedit-core")) "api"(project(":worldedit-libs:bukkit")) - "api"("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT") { + // Technically this is api, but everyone should already have some form of the bukkit API + // Avoid pulling in another one, especially one so outdated. + "localImplementation"("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT") { exclude("junit", "junit") } - "implementation"(platform("org.apache.logging.log4j:log4j-bom:2.14.1") { + "localImplementation"(platform("org.apache.logging.log4j:log4j-bom:2.14.1") { because("Spigot provides Log4J (sort of, not in API, implicitly part of server)") }) - "implementation"("org.apache.logging.log4j:log4j-api") + "localImplementation"("org.apache.logging.log4j:log4j-api") "compileOnly"("org.jetbrains:annotations:20.1.0") "compileOnly"("com.destroystokyo.paper:paper-api:1.16.1-R0.1-SNAPSHOT") { @@ -81,3 +91,9 @@ tasks.named("assemble").configure { dependsOn("shadowJar") } + +configure { + publications.named("maven") { + from(components["java"]) + } +} diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 57930ccf8..70f1ae2b4 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -120,3 +120,10 @@ into("lang") } } + +configure { + publications.named("maven") { + artifactId = the().archivesBaseName + from(components["java"]) + } +} diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index 60398d638..8ede61641 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -116,6 +116,12 @@ configure { publications.named("maven") { artifactId = the().archivesBaseName + artifact(tasks.named("jar")) { + builtBy(tasks.named("remapJar")) + } + artifact(tasks.named("sourcesJar")) { + builtBy(tasks.named("remapSourcesJar")) + } } } @@ -138,31 +144,6 @@ } } -tasks.register("deobfJar") { - from(sourceSets["main"].output) - archiveClassifier.set("dev") -} - -val deobfElements = configurations.register("deobfElements") { - isVisible = false - description = "De-obfuscated elements for libs" - isCanBeResolved = false - isCanBeConsumed = true - attributes { - attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_API)) - attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY)) - attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.EXTERNAL)) - attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR)) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) - } - outgoing.artifact(tasks.named("deobfJar")) -} - -val javaComponent = components["java"] as AdhocComponentWithVariants -javaComponent.addVariantsFromConfiguration(deobfElements.get()) { - mapToMavenScope("runtime") -} - tasks.register("remapShadowJar") { val shadowJar = tasks.getByName("shadowJar") dependsOn(shadowJar) diff --git a/worldedit-forge/build.gradle.kts b/worldedit-forge/build.gradle.kts index 472f21dbd..d9ea915bd 100644 --- a/worldedit-forge/build.gradle.kts +++ b/worldedit-forge/build.gradle.kts @@ -36,8 +36,8 @@ configure { mappings(mapOf( - "channel" to "snapshot", - "version" to "20200514-$mappingsMinecraftVersion" + "channel" to "snapshot", + "version" to "20200514-$mappingsMinecraftVersion" )) accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg")) @@ -45,8 +45,8 @@ runs { val runConfig = Action { properties(mapOf( - "forge.logging.markers" to "SCAN,REGISTRIES,REGISTRYDUMP", - "forge.logging.console.level" to "debug" + "forge.logging.markers" to "SCAN,REGISTRIES,REGISTRYDUMP", + "forge.logging.console.level" to "debug" )) workingDirectory = project.file("run").canonicalPath source(sourceSets["main"]) @@ -60,19 +60,79 @@ configure { archivesBaseName = "$archivesBaseName-mc$minecraftVersion" } + +val javaComponent = components["java"] as AdhocComponentWithVariants +javaComponent.withVariantsFromConfiguration(configurations["apiElements"]) { + skip() +} + +javaComponent.withVariantsFromConfiguration(configurations["runtimeElements"]) { + skip() +} +tasks.register("deobfJar") { + from(sourceSets["main"].output) + archiveClassifier.set("dev") +} + +val reobfApiElements = configurations.register("reobfApiElements") { + isVisible = false + description = "Re-obfuscated API elements for libs" + isCanBeResolved = false + isCanBeConsumed = true + attributes { + attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_API)) + attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY)) + attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.EXTERNAL)) + attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR)) + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) + } + outgoing.artifact(tasks.named("jar")) { + builtBy(project.provider { tasks.named("reobfJar") }) + } + extendsFrom(configurations["api"]) +} + +javaComponent.addVariantsFromConfiguration(reobfApiElements.get()) { + mapToMavenScope("compile") +} + +val reobfRuntimeElements = configurations.register("reobfRuntimeElements") { + isVisible = false + description = "Re-obfuscated runtime elements for libs" + isCanBeResolved = false + isCanBeConsumed = true + attributes { + attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME)) + attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY)) + attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.EXTERNAL)) + attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR)) + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) + } + outgoing.artifact(tasks.named("jar")) { + builtBy(project.provider { tasks.named("reobfJar") }) + } + extendsFrom(configurations["reobfApiElements"]) + extendsFrom(configurations["runtimeClasspath"].copy { d -> d.group != "net.minecraftforge" }) +} + +javaComponent.addVariantsFromConfiguration(reobfRuntimeElements.get()) { + mapToMavenScope("runtime") +} + configure { publications.named("maven") { artifactId = the().archivesBaseName + from(components["java"]) } } tasks.named("processResources") { // this will ensure that this task is redone when the versions change. val properties = mapOf( - "version" to project.ext["internalVersion"], - "forgeVersion" to forgeVersion, - "minecraftVersion" to minecraftVersion, - "nextMajorMinecraftVersion" to nextMajorMinecraftVersion + "version" to project.ext["internalVersion"], + "forgeVersion" to forgeVersion, + "minecraftVersion" to minecraftVersion, + "nextMajorMinecraftVersion" to nextMajorMinecraftVersion ) properties.forEach { (key, value) -> inputs.property(key, value) @@ -106,28 +166,3 @@ mappings = tasks.getByName("createMcpToSrg").output } } - -tasks.register("deobfJar") { - from(sourceSets["main"].output) - archiveClassifier.set("dev") -} - -val deobfElements = configurations.register("deobfElements") { - isVisible = false - description = "De-obfuscated elements for libs" - isCanBeResolved = false - isCanBeConsumed = true - attributes { - attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_API)) - attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY)) - attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.EXTERNAL)) - attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR)) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) - } - outgoing.artifact(tasks.named("deobfJar")) -} - -val javaComponent = components["java"] as AdhocComponentWithVariants -javaComponent.addVariantsFromConfiguration(deobfElements.get()) { - mapToMavenScope("runtime") -} diff --git a/worldedit-mod/build.gradle.kts b/worldedit-mod/build.gradle.kts index b5b006597..66fa8cd67 100644 --- a/worldedit-mod/build.gradle.kts +++ b/worldedit-mod/build.gradle.kts @@ -9,11 +9,11 @@ tasks.register("jar") { val remapFabric = project(":worldedit-fabric").tasks.named("remapShadowJar") dependsOn( - remapFabric//, - //project(":worldedit-forge").tasks.named("reobfShadowJar") + remapFabric, + project(":worldedit-forge").tasks.named("reobfShadowJar") ) from(zipTree({remapFabric.get().archiveFile})) - //from(zipTree({project(":worldedit-forge").tasks.getByName("shadowJar").outputs.files.singleFile})) + from(zipTree({project(":worldedit-forge").tasks.getByName("shadowJar").outputs.files.singleFile})) duplicatesStrategy = DuplicatesStrategy.EXCLUDE archiveClassifier.set("dist")