From 59c2a15cdae831c90aa311050705f0d377727a22 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 11:07:00 -0700 Subject: [PATCH 01/15] Further minor cleanup from Gradle 5 change --- build.gradle | 29 ++++++----------------------- settings.gradle | 11 ----------- settings.gradle.kts | 11 +++++++++++ worldedit-forge/build.gradle | 2 +- worldedit-libs/build.gradle | 7 +++---- 5 files changed, 21 insertions(+), 39 deletions(-) delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle index dddd5470e..c3e908d37 100644 --- a/build.gradle +++ b/build.gradle @@ -1,25 +1,8 @@ -buildscript { - repositories { - mavenCentral() - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } - jcenter() - } - - configurations.all { - resolutionStrategy { - force 'commons-io:commons-io:2.4' - } - } - - dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' - classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1' - } -} - plugins { id 'net.minecrell.licenser' version '0.4.1' apply false - id "org.ajoberstar.grgit" version "2.3.0" + id "org.ajoberstar.grgit" version "3.1.1" + id "com.github.johnrengelman.shadow" version "5.1.0" + id "com.jfrog.artifactory" version "4.9.7" } println """ @@ -109,7 +92,7 @@ configure(['core', 'bukkit', 'forge', 'sponge', 'fabric'].collect { project(":wo } task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' + getArchiveClassifier().set('javadoc') from javadoc.destinationDir } @@ -120,7 +103,7 @@ configure(['core', 'bukkit', 'forge', 'sponge', 'fabric'].collect { project(":wo if (name == "worldedit-core" || name == "worldedit-bukkit") { task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' + getArchiveClassifier().set('sources') from sourceSets.main.allSource } @@ -146,7 +129,7 @@ configure(['core', 'bukkit', 'forge', 'sponge', 'fabric'].collect { project(":wo configure(['bukkit', 'forge', 'sponge', 'fabric'].collect { project(":worldedit-$it") }) { shadowJar { - classifier 'dist' + getArchiveClassifier().set('dist') dependencies { include(project(":worldedit-libs:core")) include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}")) diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index a7c14e8ee..000000000 --- a/settings.gradle +++ /dev/null @@ -1,11 +0,0 @@ -rootProject.name = 'worldedit' - -include 'worldedit-libs' - -['bukkit', 'core', 'forge', 'sponge', 'fabric'].forEach { - include "worldedit-libs:$it" - include "worldedit-$it" -} -include "worldedit-libs:core:ap" - -include "worldedit-core:doctools" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..6da7bedcc --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,11 @@ +rootProject.name = "worldedit" + +include("worldedit-libs") + +listOf("bukkit", "core", "forge", "sponge", "fabric").forEach { + include("worldedit-libs:$it") + include("worldedit-$it") +} +include("worldedit-libs:core:ap") + +include("worldedit-core:doctools") diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle index 920903932..0c389e66f 100644 --- a/worldedit-forge/build.gradle +++ b/worldedit-forge/build.gradle @@ -108,7 +108,7 @@ afterEvaluate { task deobfJar(type: Jar) { from sourceSets.main.output - classifier = 'dev' + getArchiveClassifier().set("dev") } artifacts { diff --git a/worldedit-libs/build.gradle b/worldedit-libs/build.gradle index b31760f52..cc3c681a0 100644 --- a/worldedit-libs/build.gradle +++ b/worldedit-libs/build.gradle @@ -13,7 +13,7 @@ dependents of `-core` to compile and work with WorldEdit's API. */ configure(subprojects + project("core:ap")) { - apply plugin: 'java' + apply plugin: 'java-base' apply plugin: 'maven' apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.jfrog.artifactory' @@ -24,8 +24,7 @@ configure(subprojects + project("core:ap")) { group = rootProject.group + ".worldedit-libs" - tasks.replace("jar", ShadowJar) - tasks.withType(ShadowJar).named("jar").configure { + tasks.register("jar", ShadowJar) { configurations = [project.configurations.shade] classifier = "" @@ -79,7 +78,7 @@ configure(subprojects + project("core:ap")) { } } - tasks.withType(Upload).named("install").configure { + tasks.register("install", Upload) { configuration = configurations.archives repositories.mavenInstaller { pom.version = project.version From eccbad92e8b2312b02023f28dc5f00f2ac97c066 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 13:13:41 -0700 Subject: [PATCH 02/15] Move away from deprecation, move dependencies towards buildSrc --- build.gradle | 7 +++--- buildSrc/build.gradle.kts | 32 ++++++++++++++++++++++++ worldedit-core/build.gradle | 12 ++++----- worldedit-core/doctools/build.gradle.kts | 2 +- worldedit-fabric/build.gradle | 8 +++--- worldedit-sponge/build.gradle | 11 +------- 6 files changed, 46 insertions(+), 26 deletions(-) create mode 100644 buildSrc/build.gradle.kts diff --git a/build.gradle b/build.gradle index c3e908d37..b39e4ebb3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,7 @@ plugins { - id 'net.minecrell.licenser' version '0.4.1' apply false - id "org.ajoberstar.grgit" version "3.1.1" - id "com.github.johnrengelman.shadow" version "5.1.0" - id "com.jfrog.artifactory" version "4.9.7" + id "org.ajoberstar.grgit" + id "com.github.johnrengelman.shadow" + id "com.jfrog.artifactory" } println """ diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000..658143d8d --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,32 @@ +plugins { + `kotlin-dsl` + kotlin("jvm") version embeddedKotlinVersion +} + +repositories { + jcenter() + gradlePluginPortal() + maven { + name = "Forge Maven" + url = uri("https://files.minecraftforge.net/maven") + } +} + +configurations.all { + resolutionStrategy { + // Fabric needs this. + force("commons-io:commons-io:2.5", "org.ow2.asm:asm:7.1") + } +} + +dependencies { + implementation(gradleApi()) + implementation("gradle.plugin.net.minecrell:licenser:0.4.1") + implementation("org.ajoberstar.grgit:grgit-gradle:3.1.1") + implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0") + implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21") + implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21") + implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7") + implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0") + implementation("net.minecraftforge.gradle:ForgeGradle:3.0.130") +} diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index 182702290..41efbff01 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -1,13 +1,11 @@ plugins { - id("net.ltgt.apt") version "0.21" apply false + id("java-library") + id("eclipse") + id("idea") + id("net.ltgt.apt-eclipse") + id("net.ltgt.apt-idea") } -apply plugin: 'java-library' -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'net.ltgt.apt-eclipse' -apply plugin: 'net.ltgt.apt-idea' - configurations.all { Configuration it -> it.resolutionStrategy { ResolutionStrategy rs -> rs.force("com.google.guava:guava:21.0") diff --git a/worldedit-core/doctools/build.gradle.kts b/worldedit-core/doctools/build.gradle.kts index 002f367bd..75a347ece 100644 --- a/worldedit-core/doctools/build.gradle.kts +++ b/worldedit-core/doctools/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") version "1.3.31" + kotlin("jvm") version "1.3.41" } tasks.withType { diff --git a/worldedit-fabric/build.gradle b/worldedit-fabric/build.gradle index b27289bf9..6eee60e9e 100644 --- a/worldedit-fabric/build.gradle +++ b/worldedit-fabric/build.gradle @@ -77,7 +77,7 @@ jar { } shadowJar { - classifier = 'dist-dev' + archiveClassifier.set("dist-dev") dependencies { relocate "org.slf4j", "com.sk89q.worldedit.slf4j" relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" @@ -89,7 +89,7 @@ shadowJar { task deobfJar(type: Jar) { from sourceSets.main.output - classifier = 'dev' + archiveClassifier.set("dev") } artifacts { @@ -97,8 +97,8 @@ artifacts { } task shadowJarRemap(type: RemapJarTask) { - input shadowJar.archivePath - output new File(shadowJar.archivePath.getAbsolutePath().replaceFirst('-dev\\.jar$', ".jar")) + input shadowJar.archiveFile + output new File(shadowJar.archiveFile.get().asFile.getAbsolutePath().replaceFirst('-dev\\.jar$', ".jar")) } shadowJarRemap.dependsOn(shadowJar) diff --git a/worldedit-sponge/build.gradle b/worldedit-sponge/build.gradle index a745869b6..8d6633de2 100644 --- a/worldedit-sponge/build.gradle +++ b/worldedit-sponge/build.gradle @@ -1,14 +1,5 @@ -buildscript { - repositories { - mavenCentral() - maven { url = "https://files.minecraftforge.net/maven" } - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } - jcenter() - } -} - plugins { - id 'org.spongepowered.plugin' version '0.9.0' + id("org.spongepowered.plugin") } repositories { From 19802e478ce3e9c08c500076041f4c75d5820825 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 16:33:21 -0700 Subject: [PATCH 03/15] Re-write root and libs to Kotlin DSL --- build.gradle | 141 ----------------- build.gradle.kts | 28 ++++ buildSrc/src/main/kotlin/ArtifactoryConfig.kt | 40 +++++ buildSrc/src/main/kotlin/CommonConfig.kt | 18 +++ buildSrc/src/main/kotlin/GradleExtras.kt | 6 + buildSrc/src/main/kotlin/LibsConfig.kt | 98 ++++++++++++ buildSrc/src/main/kotlin/PlatformConfig.kt | 101 ++++++++++++ buildSrc/src/main/kotlin/Versions.kt | 5 + gradle.properties | 3 + worldedit-bukkit/build.gradle | 2 + worldedit-core/build.gradle | 2 + worldedit-fabric/build.gradle | 3 + worldedit-forge/build.gradle | 14 +- worldedit-libs/README.md | 9 ++ worldedit-libs/build.gradle | 145 ------------------ worldedit-libs/bukkit/build.gradle.kts | 11 ++ worldedit-libs/core/ap/build.gradle.kts | 6 + worldedit-libs/core/build.gradle.kts | 16 ++ worldedit-libs/fabric/build.gradle.kts | 1 + worldedit-libs/forge/build.gradle.kts | 1 + worldedit-libs/sponge/build.gradle.kts | 11 ++ worldedit-sponge/build.gradle | 3 + 22 files changed, 366 insertions(+), 298 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/ArtifactoryConfig.kt create mode 100644 buildSrc/src/main/kotlin/CommonConfig.kt create mode 100644 buildSrc/src/main/kotlin/GradleExtras.kt create mode 100644 buildSrc/src/main/kotlin/LibsConfig.kt create mode 100644 buildSrc/src/main/kotlin/PlatformConfig.kt create mode 100644 buildSrc/src/main/kotlin/Versions.kt create mode 100644 worldedit-libs/README.md create mode 100644 worldedit-libs/bukkit/build.gradle.kts create mode 100644 worldedit-libs/core/ap/build.gradle.kts create mode 100644 worldedit-libs/core/build.gradle.kts create mode 100644 worldedit-libs/fabric/build.gradle.kts create mode 100644 worldedit-libs/forge/build.gradle.kts create mode 100644 worldedit-libs/sponge/build.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index b39e4ebb3..000000000 --- a/build.gradle +++ /dev/null @@ -1,141 +0,0 @@ -plugins { - id "org.ajoberstar.grgit" - id "com.github.johnrengelman.shadow" - id "com.jfrog.artifactory" -} - -println """ -******************************************* - You are building WorldEdit! - - If you encounter trouble: - 1) Read COMPILING.md if you haven't yet - 2) Try running 'build' in a separate Gradle run - 3) Use gradlew and not gradle - 4) If you still need help, ask on Discord! https://discord.gg/enginehub - - Output files will be in [subproject]/build/libs -******************************************* -""" - -allprojects { - group = 'com.sk89q.worldedit' - version = '7.0.1-SNAPSHOT' -} - -if (!project.hasProperty("artifactory_contextUrl")) ext.artifactory_contextUrl = "http://localhost" -if (!project.hasProperty("artifactory_user")) ext.artifactory_user = "guest" -if (!project.hasProperty("artifactory_password")) ext.artifactory_password = "" - -if (!project.hasProperty("gitCommitHash") && !JavaVersion.current().isJava6()) { - try { - def repo = grgit.open() - ext.gitCommitHash = repo.head().abbreviatedId - } catch (Exception e) { - println "Error getting commit hash: " + e.getMessage() - } -} -if (!project.hasProperty("gitCommitHash")) { - ext.gitCommitHash = "no_git_id" -} - -apply plugin: 'com.jfrog.artifactory' -artifactory { - contextUrl = "${artifactory_contextUrl}" - publish { - repository { - repoKey = project.version.contains("SNAPSHOT") ? 'libs-snapshot-local' : 'libs-release-local' - username = "${artifactory_user}" - password = "${artifactory_password}" - maven = true - ivy = false - } - } -} -artifactoryPublish.skip = true - -subprojects { - repositories { - mavenCentral() - maven { url "http://maven.sk89q.com/repo/" } - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - } - configurations.all { - resolutionStrategy { - cacheChangingModulesFor 5, 'minutes' - } - } -} - -configure(['core', 'bukkit', 'forge', 'sponge', 'fabric'].collect { project(":worldedit-$it") }) { - apply plugin: 'java' - apply plugin: 'maven' - apply plugin: 'checkstyle' - apply plugin: 'com.github.johnrengelman.shadow' - apply plugin: 'com.jfrog.artifactory' - apply plugin: 'net.minecrell.licenser' - - ext.internalVersion = version + ";" + gitCommitHash - - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - - checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml") - checkstyle.toolVersion = '7.6.1' - - if (JavaVersion.current().isJava8Compatible()) { - // Java 8 turns on doclint which we fail - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - getArchiveClassifier().set('javadoc') - from javadoc.destinationDir - } - - artifacts { - archives jar - archives javadocJar - } - - if (name == "worldedit-core" || name == "worldedit-bukkit") { - task sourcesJar(type: Jar, dependsOn: classes) { - getArchiveClassifier().set('sources') - from sourceSets.main.allSource - } - - artifacts { - archives sourcesJar - } - build.dependsOn(sourcesJar) - } - - build.dependsOn(checkstyleMain) - build.dependsOn(checkstyleTest) - build.dependsOn(javadocJar) - - artifactoryPublish { - publishConfigs('archives') - } - - license { - header = rootProject.file("HEADER.txt") - include '**/*.java' - } -} - -configure(['bukkit', 'forge', 'sponge', 'fabric'].collect { project(":worldedit-$it") }) { - shadowJar { - getArchiveClassifier().set('dist') - dependencies { - include(project(":worldedit-libs:core")) - include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}")) - include(project(":worldedit-core")) - } - exclude 'GradleStart**' - exclude '.cache' - exclude 'LICENSE*' - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..7088d0893 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,28 @@ +import org.ajoberstar.grgit.Grgit + +println(""" +******************************************* + You are building WorldEdit! + + If you encounter trouble: + 1) Read COMPILING.md if you haven't yet + 2) Try running 'build' in a separate Gradle run + 3) Use gradlew and not gradle + 4) If you still need help, ask on Discord! https://discord.gg/enginehub + + Output files will be in [subproject]/build/libs +******************************************* +""") + +applyRootArtifactoryConfig() + +if (!project.hasProperty("gitCommitHash")) { + apply(plugin = "org.ajoberstar.grgit") + ext["gitCommitHash"] = try { + (ext["grgit"] as Grgit).head().abbreviatedId + } catch (e: Exception) { + println("Error getting commit hash: " + e.message) + + "no_git_id" + } +} diff --git a/buildSrc/src/main/kotlin/ArtifactoryConfig.kt b/buildSrc/src/main/kotlin/ArtifactoryConfig.kt new file mode 100644 index 000000000..d19f35238 --- /dev/null +++ b/buildSrc/src/main/kotlin/ArtifactoryConfig.kt @@ -0,0 +1,40 @@ +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.named +import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention +import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask + +private const val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl" +private const val ARTIFACTORY_USER = "artifactory_user" +private const val ARTIFACTORY_PASSWORD = "artifactory_password" + +fun Project.applyRootArtifactoryConfig() { + if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost" + if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest" + if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = "" + + apply(plugin = "com.jfrog.artifactory") + configure { + setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}") + clientConfig.publisher.run { + repoKey = when { + "${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local" + else -> "libs-release-local" + } + username = "${project.property(ARTIFACTORY_USER)}" + password = "${project.property(ARTIFACTORY_PASSWORD)}" + isMaven = true + isIvy = false + } + } + tasks.named("artifactoryPublish") { + isSkip = true + } +} + +fun Project.applyCommonArtifactoryConfig() { + tasks.named("artifactoryPublish") { + publishConfigs("archives") + } +} diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt new file mode 100644 index 000000000..e93f4a2dd --- /dev/null +++ b/buildSrc/src/main/kotlin/CommonConfig.kt @@ -0,0 +1,18 @@ +import org.gradle.api.Project +import org.gradle.kotlin.dsl.repositories + +fun Project.applyCommonConfiguration() { + group = rootProject.group + version = rootProject.version + + repositories { + mavenCentral() + maven { url = uri("https://maven.sk89q.com/repo/") } + maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } + } + configurations.all { + resolutionStrategy { + cacheChangingModulesFor(5, "minutes") + } + } +} diff --git a/buildSrc/src/main/kotlin/GradleExtras.kt b/buildSrc/src/main/kotlin/GradleExtras.kt new file mode 100644 index 000000000..5358f6b37 --- /dev/null +++ b/buildSrc/src/main/kotlin/GradleExtras.kt @@ -0,0 +1,6 @@ +import org.gradle.api.Project +import org.gradle.api.plugins.ExtraPropertiesExtension +import org.gradle.kotlin.dsl.getByType + +val Project.ext: ExtraPropertiesExtension + get() = extensions.getByType() diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt new file mode 100644 index 000000000..c2754d487 --- /dev/null +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -0,0 +1,98 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.api.Project +import org.gradle.api.artifacts.ModuleDependency +import org.gradle.api.internal.HasConvention +import org.gradle.api.plugins.MavenRepositoryHandlerConvention +import org.gradle.api.tasks.Upload +import org.gradle.api.tasks.bundling.Jar +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.getPlugin +import org.gradle.kotlin.dsl.invoke +import org.gradle.kotlin.dsl.register + +fun Project.applyLibrariesConfiguration() { + applyCommonConfiguration() + apply(plugin = "java-base") + apply(plugin = "maven") + apply(plugin = "com.github.johnrengelman.shadow") + apply(plugin = "com.jfrog.artifactory") + + configurations { + create("shade") + getByName("archives").extendsFrom(getByName("default")) + } + + group = "${rootProject.group}.worldedit-libs" + + tasks.register("jar") { + configurations = listOf(project.configurations["shade"]) + archiveClassifier.set("") + + dependencies { + exclude(dependency("com.google.guava:guava")) + exclude(dependency("com.google.code.gson:gson")) + exclude(dependency("org.checkerframework:checker-qual")) + } + + relocate("net.kyori.text", "com.sk89q.worldedit.util.formatting.text") + } + val altConfigFiles = { artifactType: String -> + val deps = configurations["shade"].incoming.dependencies + .filterIsInstance() + .map { it.copy() } + .map { dependency -> + dependency.artifact { + name = dependency.name + type = artifactType + extension = "jar" + classifier = artifactType + } + dependency + } + + files(configurations.detachedConfiguration(*deps.toTypedArray()) + .resolvedConfiguration.lenientConfiguration.artifacts + .filter { it.classifier == artifactType } + .map { zipTree(it.file) }) + } + tasks.register("sourcesJar") { + from({ + altConfigFiles("sources") + }) + val filePattern = Regex("(.*)net/kyori/text((?:/|$).*)") + val textPattern = Regex("net\\.kyori\\.text") + eachFile { + filter { + it.replaceFirst(textPattern, "com.sk89q.worldedit.util.formatting.text") + } + path = path.replaceFirst(filePattern, "$1com/sk89q/worldedit/util/formatting/text$2") + } + archiveClassifier.set("sources") + } + + tasks.named("assemble").configure { + dependsOn("jar", "sourcesJar") + } + + artifacts { + val jar = tasks.named("jar") + add("default", jar) { + builtBy(jar) + } + val sourcesJar = tasks.named("sourcesJar") + add("archives", sourcesJar) { + builtBy(sourcesJar) + } + } + + tasks.register("install") { + configuration = configurations["archives"] + (repositories as HasConvention).convention.getPlugin().mavenInstaller { + pom.version = project.version.toString() + pom.artifactId = project.name + } + } + + applyCommonArtifactoryConfig() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt new file mode 100644 index 000000000..85042cc9f --- /dev/null +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -0,0 +1,101 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import net.minecrell.gradle.licenser.LicenseExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.plugins.quality.CheckstyleExtension +import org.gradle.api.tasks.bundling.Jar +import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.external.javadoc.CoreJavadocOptions +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.getByName +import org.gradle.kotlin.dsl.getPlugin +import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.the +import org.gradle.kotlin.dsl.withType +import org.gradle.kotlin.dsl.named + +fun Project.applyPlatformAndCoreConfiguration() { + applyCommonConfiguration() + apply(plugin = "java") + apply(plugin = "maven") + apply(plugin = "checkstyle") + apply(plugin = "com.github.johnrengelman.shadow") + apply(plugin = "com.jfrog.artifactory") + apply(plugin = "net.minecrell.licenser") + + ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}" + + configure { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + configure { + configFile = rootProject.file("config/checkstyle/checkstyle.xml") + toolVersion = "7.6.1" + } + + // Java 8 turns on doclint which we fail + tasks.withType().configureEach { + (options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet") + } + + tasks.register("javadocJar") { + dependsOn("javadoc") + archiveClassifier.set("javadoc") + from(tasks.getByName("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("sourcesJar") { + dependsOn("classes") + archiveClassifier.set("sources") + from(project.the().sourceSets["main"].allSource) + } + + artifacts { + add("archives", tasks.named("sourcesJar")) + } + tasks.named("assemble").configure { + dependsOn("sourcesJar") + } + } + + tasks.named("check").configure { + dependsOn("checkstyleMain", "checkstyleTest") + } + + applyCommonArtifactoryConfig() + + configure { + header = rootProject.file("HEADER.txt") + include("**/*.java") + } +} + +fun Project.applyShadowConfiguration() { + tasks.named("shadowJar") { + archiveClassifier.set("dist") + dependencies { + include(project(":worldedit-libs:core")) + include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}")) + include(project(":worldedit-core")) + } + exclude("GradleStart**") + exclude(".cache") + exclude("LICENSE*") + minimize() + } +} diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt new file mode 100644 index 000000000..fd61ee13b --- /dev/null +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -0,0 +1,5 @@ +object Versions { + const val TEXT = "3.0.1" + const val TEXT_EXTRAS = "3.0.2" + const val PISTON = "0.4.2" +} diff --git a/gradle.properties b/gradle.properties index f7c837830..a2cc53d8e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,4 @@ +group=com.sk89q.worldedit +version=7.0.1-SNAPSHOT + org.gradle.jvmargs=-Xmx1G diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index ba7a34f31..b81612b0c 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -1,3 +1,5 @@ +PlatformConfigKt.applyPlatformAndCoreConfiguration(project) +PlatformConfigKt.applyShadowConfiguration(project) apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'maven' diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index 41efbff01..a5b3bba63 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -6,6 +6,8 @@ plugins { id("net.ltgt.apt-idea") } +PlatformConfigKt.applyPlatformAndCoreConfiguration(project) + configurations.all { Configuration it -> it.resolutionStrategy { ResolutionStrategy rs -> rs.force("com.google.guava:guava:21.0") diff --git a/worldedit-fabric/build.gradle b/worldedit-fabric/build.gradle index 6eee60e9e..70acc7a1d 100644 --- a/worldedit-fabric/build.gradle +++ b/worldedit-fabric/build.gradle @@ -19,6 +19,9 @@ buildscript { } } +PlatformConfigKt.applyPlatformAndCoreConfiguration(project) +PlatformConfigKt.applyShadowConfiguration(project) + apply plugin: 'eclipse' apply plugin: 'fabric-loom' diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle index 0c389e66f..fc3dcaee8 100644 --- a/worldedit-forge/build.gradle +++ b/worldedit-forge/build.gradle @@ -1,15 +1,5 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - maven { url = "https://files.minecraftforge.net/maven" } - jcenter() - } - - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true - } -} +PlatformConfigKt.applyPlatformAndCoreConfiguration(project) +PlatformConfigKt.applyShadowConfiguration(project) apply plugin: 'eclipse' apply plugin: 'net.minecraftforge.gradle' diff --git a/worldedit-libs/README.md b/worldedit-libs/README.md new file mode 100644 index 000000000..6387fde12 --- /dev/null +++ b/worldedit-libs/README.md @@ -0,0 +1,9 @@ +This project shades _API_ libraries, i.e. those libraries +whose classes are publicly referenced from `-core` classes. + +This project _does not_ shade implementation libraries, i.e. +those libraries whose classes are internally depended on. + +This is because the main reason for shading those libraries is for +their internal usage in each platform, not because we need them available to +dependents of `-core` to compile and work with WorldEdit's API. diff --git a/worldedit-libs/build.gradle b/worldedit-libs/build.gradle index cc3c681a0..29c096e2d 100644 --- a/worldedit-libs/build.gradle +++ b/worldedit-libs/build.gradle @@ -1,148 +1,3 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -/* - -This project shades API libraries, i.e. those libraries -whose classes are publicly referenced from `-core` classes. - -This project does not shade implementation libraries, i.e. -those libraries whose classes are internally depended on. - -This is because the main reason for shading those libraries is for -their internal usage in each platform, not because we need them available to -dependents of `-core` to compile and work with WorldEdit's API. - - */ -configure(subprojects + project("core:ap")) { - apply plugin: 'java-base' - apply plugin: 'maven' - apply plugin: 'com.github.johnrengelman.shadow' - apply plugin: 'com.jfrog.artifactory' - configurations { - create("shade") - getByName("archives").extendsFrom(getByName("default")) - } - - group = rootProject.group + ".worldedit-libs" - - tasks.register("jar", ShadowJar) { - configurations = [project.configurations.shade] - classifier = "" - - dependencies { - exclude(dependency("com.google.guava:guava")) - exclude(dependency("com.google.code.gson:gson")) - exclude(dependency("org.checkerframework:checker-qual")) - } - - relocate('net.kyori.text', 'com.sk89q.worldedit.util.formatting.text') - } - def altConfigFiles = { String artifactType -> - def deps = configurations.shade.incoming.dependencies - .collect { it.copy() } - .collect { dependency -> - dependency.artifact { artifact -> - artifact.name = dependency.name - artifact.type = artifactType - artifact.extension = 'jar' - artifact.classifier = artifactType - } - dependency - } - - return files(configurations.detachedConfiguration(deps as Dependency[]) - .resolvedConfiguration.lenientConfiguration.getArtifacts() - .findAll { it.classifier == artifactType } - .collect { zipTree(it.file) }) - } - tasks.register("sourcesJar", Jar) { - from { - altConfigFiles('sources') - } - def filePattern = ~'(.*)net/kyori/text((?:/|$).*)' - def textPattern = ~/net\.kyori\.text/ - eachFile { - it.filter { String line -> - line.replaceFirst(textPattern, 'com.sk89q.worldedit.util.formatting.text') - } - it.path = it.path.replaceFirst(filePattern, '$1com/sk89q/worldedit/util/formatting/text$2') - } - classifier = "sources" - } - - artifacts { - add("default", jar) { - builtBy(jar) - } - add("archives", sourcesJar) { - builtBy(sourcesJar) - } - } - - tasks.register("install", Upload) { - configuration = configurations.archives - repositories.mavenInstaller { - pom.version = project.version - pom.artifactId = project.name - } - } - - artifactoryPublish { - publishConfigs('default') - } - - build.dependsOn(jar, sourcesJar) -} - -def textExtrasVersion = "3.0.2" -project("core") { - def textVersion = "3.0.1" - def pistonVersion = '0.4.2' - - dependencies { - shade "net.kyori:text-api:$textVersion" - shade "net.kyori:text-serializer-gson:$textVersion" - shade "net.kyori:text-serializer-legacy:$textVersion" - shade "net.kyori:text-serializer-plain:$textVersion" - shade('com.sk89q:jchronic:0.2.4a') { - exclude(group: "junit", module: "junit") - } - shade 'com.thoughtworks.paranamer:paranamer:2.6' - shade 'com.sk89q.lib:jlibnoise:1.0.0' - shade "org.enginehub.piston:core:$pistonVersion" - shade "org.enginehub.piston.core-ap:runtime:$pistonVersion" - shade "org.enginehub.piston:default-impl:$pistonVersion" - } - - project("ap") { - dependencies { - shade "org.enginehub.piston.core-ap:annotations:$pistonVersion" - shade "org.enginehub.piston.core-ap:processor:$pistonVersion" - } - } -} -project("bukkit") { - repositories { - maven { - name = "SpigotMC" - url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" - } - } - dependencies { - shade "net.kyori:text-adapter-bukkit:$textExtrasVersion" - } -} -project("sponge") { - repositories { - maven { - name = "Sponge" - url = "https://repo.spongepowered.org/maven" - } - } - dependencies { - shade "net.kyori:text-adapter-spongeapi:$textExtrasVersion" - } -} - tasks.register("build") { dependsOn(subprojects.collect { it.tasks.named("build") }) } diff --git a/worldedit-libs/bukkit/build.gradle.kts b/worldedit-libs/bukkit/build.gradle.kts new file mode 100644 index 000000000..79734ff82 --- /dev/null +++ b/worldedit-libs/bukkit/build.gradle.kts @@ -0,0 +1,11 @@ +applyLibrariesConfiguration() + +repositories { + maven { + name = "SpigotMC" + url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + } +} +dependencies { + "shade"("net.kyori:text-adapter-bukkit:${Versions.TEXT_EXTRAS}") +} \ No newline at end of file diff --git a/worldedit-libs/core/ap/build.gradle.kts b/worldedit-libs/core/ap/build.gradle.kts new file mode 100644 index 000000000..44374359b --- /dev/null +++ b/worldedit-libs/core/ap/build.gradle.kts @@ -0,0 +1,6 @@ +applyLibrariesConfiguration() + +dependencies { + "shade"("org.enginehub.piston.core-ap:annotations:${Versions.PISTON}") + "shade"("org.enginehub.piston.core-ap:processor:${Versions.PISTON}") +} diff --git a/worldedit-libs/core/build.gradle.kts b/worldedit-libs/core/build.gradle.kts new file mode 100644 index 000000000..d669216d6 --- /dev/null +++ b/worldedit-libs/core/build.gradle.kts @@ -0,0 +1,16 @@ +applyLibrariesConfiguration() + +dependencies { + "shade"("net.kyori:text-api:${Versions.TEXT}") + "shade"("net.kyori:text-serializer-gson:${Versions.TEXT}") + "shade"("net.kyori:text-serializer-legacy:${Versions.TEXT}") + "shade"("net.kyori:text-serializer-plain:${Versions.TEXT}") + "shade"("com.sk89q:jchronic:0.2.4a") { + exclude(group = "junit", module = "junit") + } + "shade"("com.thoughtworks.paranamer:paranamer:2.6") + "shade"("com.sk89q.lib:jlibnoise:1.0.0") + "shade"("org.enginehub.piston:core:${Versions.PISTON}") + "shade"("org.enginehub.piston.core-ap:runtime:${Versions.PISTON}") + "shade"("org.enginehub.piston:default-impl:${Versions.PISTON}") +} diff --git a/worldedit-libs/fabric/build.gradle.kts b/worldedit-libs/fabric/build.gradle.kts new file mode 100644 index 000000000..388618cea --- /dev/null +++ b/worldedit-libs/fabric/build.gradle.kts @@ -0,0 +1 @@ +applyLibrariesConfiguration() diff --git a/worldedit-libs/forge/build.gradle.kts b/worldedit-libs/forge/build.gradle.kts new file mode 100644 index 000000000..388618cea --- /dev/null +++ b/worldedit-libs/forge/build.gradle.kts @@ -0,0 +1 @@ +applyLibrariesConfiguration() diff --git a/worldedit-libs/sponge/build.gradle.kts b/worldedit-libs/sponge/build.gradle.kts new file mode 100644 index 000000000..5854dd616 --- /dev/null +++ b/worldedit-libs/sponge/build.gradle.kts @@ -0,0 +1,11 @@ +applyLibrariesConfiguration() + +repositories { + maven { + name = "Sponge" + url = uri("https://repo.spongepowered.org/maven") + } +} +dependencies { + "shade"("net.kyori:text-adapter-spongeapi:${Versions.TEXT_EXTRAS}") +} \ No newline at end of file diff --git a/worldedit-sponge/build.gradle b/worldedit-sponge/build.gradle index 8d6633de2..81d445a5d 100644 --- a/worldedit-sponge/build.gradle +++ b/worldedit-sponge/build.gradle @@ -2,6 +2,9 @@ plugins { id("org.spongepowered.plugin") } +PlatformConfigKt.applyPlatformAndCoreConfiguration(project) +PlatformConfigKt.applyShadowConfiguration(project) + repositories { maven { url "https://repo.codemc.org/repository/maven-public" } } From ab8397e517eeab1e34f37b38772cc5b50a5ad871 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 16:45:12 -0700 Subject: [PATCH 04/15] Migrate Bukkit to Kotlin DSL --- buildSrc/src/main/kotlin/PlatformConfig.kt | 2 + worldedit-bukkit/build.gradle | 65 -------------------- worldedit-bukkit/build.gradle.kts | 69 ++++++++++++++++++++++ 3 files changed, 71 insertions(+), 65 deletions(-) delete mode 100644 worldedit-bukkit/build.gradle create mode 100644 worldedit-bukkit/build.gradle.kts diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 85042cc9f..faf7a785a 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -20,6 +20,8 @@ import org.gradle.kotlin.dsl.named fun Project.applyPlatformAndCoreConfiguration() { applyCommonConfiguration() apply(plugin = "java") + apply(plugin = "eclipse") + apply(plugin = "idea") apply(plugin = "maven") apply(plugin = "checkstyle") apply(plugin = "com.github.johnrengelman.shadow") diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle deleted file mode 100644 index b81612b0c..000000000 --- a/worldedit-bukkit/build.gradle +++ /dev/null @@ -1,65 +0,0 @@ -PlatformConfigKt.applyPlatformAndCoreConfiguration(project) -PlatformConfigKt.applyShadowConfiguration(project) -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'maven' -apply plugin: 'java-library' - -repositories { - maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } - maven { url "https://repo.codemc.org/repository/maven-public" } - maven { url "https://papermc.io/repo/repository/maven-public/" } -} - -configurations.all { Configuration it -> - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("com.google.guava:guava:21.0") - } -} - -dependencies { - api project(':worldedit-core') - api project(':worldedit-libs:bukkit') - api 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT' // zzz - compileOnly 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT' - implementation 'io.papermc:paperlib:1.0.2' - compileOnly 'com.sk89q:dummypermscompat:1.10' - implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.1' - implementation 'org.bstats:bstats-bukkit:1.5' - testCompile 'org.mockito:mockito-core:1.9.0-rc1' -} - -processResources { - filesMatching('plugin.yml') { - expand 'internalVersion': project.internalVersion - } - from (zipTree('src/main/resources/worldedit-adapters.jar').matching { - exclude 'META-INF/' - }) - exclude '**/worldedit-adapters.jar' -} - -jar { - manifest { - attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", - "WorldEdit-Version": version) - } -} - -shadowJar { - dependencies { - relocate "org.slf4j", "com.sk89q.worldedit.slf4j" - relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" - include(dependency(':worldedit-core')) - include(dependency('org.slf4j:slf4j-api')) - include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) - relocate ("org.bstats", "com.sk89q.worldedit.bukkit.bstats") { - include(dependency("org.bstats:bstats-bukkit:1.5")) - } - relocate ("io.papermc.lib", "com.sk89q.worldedit.bukkit.paperlib") { - include(dependency("io.papermc:paperlib:1.0.2")) - } - } -} - -build.dependsOn(shadowJar) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts new file mode 100644 index 000000000..ee1b94c27 --- /dev/null +++ b/worldedit-bukkit/build.gradle.kts @@ -0,0 +1,69 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + `java-library` +} + +applyPlatformAndCoreConfiguration() +applyShadowConfiguration() + +repositories { + maven { url = uri("https://hub.spigotmc.org/nexus/content/groups/public") } + maven { url = uri("https://repo.codemc.org/repository/maven-public") } + maven { url = uri("https://papermc.io/repo/repository/maven-public/") } +} + +configurations.all { + resolutionStrategy { + force("com.google.guava:guava:21.0") + } +} + +dependencies { + "api"(project(":worldedit-core")) + "api"(project(":worldedit-libs:bukkit")) + "api"("org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT") + "compileOnly"("com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT") + "implementation"("io.papermc:paperlib:1.0.2") + "compileOnly"("com.sk89q:dummypermscompat:1.10") + "implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") + "implementation"("org.bstats:bstats-bukkit:1.5") + "testCompile"("org.mockito:mockito-core:1.9.0-rc1") +} + +tasks.named("processResources") { + filesMatching("plugin.yml") { + expand("internalVersion" to project.ext["internalVersion"]) + } + from(zipTree("src/main/resources/worldedit-adapters.jar").matching { + exclude("META-INF/") + }) + exclude("**/worldedit-adapters.jar") +} + +tasks.named("jar") { + manifest { + attributes("Class-Path" to "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", + "WorldEdit-Version" to project.version) + } +} + +tasks.named("shadowJar") { + dependencies { + relocate("org.slf4j", "com.sk89q.worldedit.slf4j") + relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge") + include(dependency(":worldedit-core")) + include(dependency("org.slf4j:slf4j-api")) + include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + relocate("org.bstats", "com.sk89q.worldedit.bukkit.bstats") { + include(dependency("org.bstats:bstats-bukkit:1.5")) + } + relocate("io.papermc.lib", "com.sk89q.worldedit.bukkit.paperlib") { + include(dependency("io.papermc:paperlib:1.0.2")) + } + } +} + +tasks.named("assemble").configure { + dependsOn("shadowJar") +} From 55100761a33c5c0086e06078ed641ed86bf56a78 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 17:07:37 -0700 Subject: [PATCH 05/15] Migrate Core to Kotlin DSL --- buildSrc/src/main/kotlin/Versions.kt | 1 + worldedit-core/build.gradle | 53 ------------------------ worldedit-core/build.gradle.kts | 50 ++++++++++++++++++++++ worldedit-core/doctools/build.gradle.kts | 6 +-- 4 files changed, 53 insertions(+), 57 deletions(-) delete mode 100644 worldedit-core/build.gradle create mode 100644 worldedit-core/build.gradle.kts diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index fd61ee13b..0f79cbfd1 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -2,4 +2,5 @@ object Versions { const val TEXT = "3.0.1" const val TEXT_EXTRAS = "3.0.2" const val PISTON = "0.4.2" + const val AUTO_VALUE = "1.6.5" } diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle deleted file mode 100644 index a5b3bba63..000000000 --- a/worldedit-core/build.gradle +++ /dev/null @@ -1,53 +0,0 @@ -plugins { - id("java-library") - id("eclipse") - id("idea") - id("net.ltgt.apt-eclipse") - id("net.ltgt.apt-idea") -} - -PlatformConfigKt.applyPlatformAndCoreConfiguration(project) - -configurations.all { Configuration it -> - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("com.google.guava:guava:21.0") - } -} - -dependencies { - compile project(':worldedit-libs:core') - compile 'de.schlichtherle:truezip:6.8.3' - compile 'org.mozilla:rhino:1.7R5' - compile 'org.yaml:snakeyaml:1.9' - compile 'com.google.guava:guava:21.0' - compile 'com.google.code.findbugs:jsr305:1.3.9' - compile 'com.google.code.gson:gson:2.8.0' - compile 'com.googlecode.json-simple:json-simple:1.1.1' - compile 'org.slf4j:slf4j-api:1.7.26' - - compileOnly project(':worldedit-libs:core:ap') - annotationProcessor project(':worldedit-libs:core:ap') - annotationProcessor "com.google.guava:guava:21.0" - def avVersion = "1.6.5" - compileOnly "com.google.auto.value:auto-value-annotations:$avVersion" - annotationProcessor "com.google.auto.value:auto-value:$avVersion" - //compile 'net.sf.trove4j:trove4j:3.0.3' - testCompile 'org.mockito:mockito-core:1.9.0-rc1' -} - -tasks.withType(JavaCompile).configureEach { - dependsOn(":worldedit-libs:build") - it.options.compilerArgs.add("-Aarg.name.key.prefix=") -} - -sourceSets { - main { - java { - srcDir 'src/main/java' - srcDir 'src/legacy/java' - } - resources { - srcDir 'src/main/resources' - } - } -} diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts new file mode 100644 index 000000000..6d268e843 --- /dev/null +++ b/worldedit-core/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + id("java-library") + id("net.ltgt.apt-eclipse") + id("net.ltgt.apt-idea") +} + +applyPlatformAndCoreConfiguration() + +configurations.all { + resolutionStrategy { + force("com.google.guava:guava:21.0") + } +} + +dependencies { + "compile"(project(":worldedit-libs:core")) + "compile"("de.schlichtherle:truezip:6.8.3") + "compile"("rhino:js:1.7R2") + "compile"("org.yaml:snakeyaml:1.9") + "compile"("com.google.guava:guava:21.0") + "compile"("com.google.code.findbugs:jsr305:1.3.9") + "compile"("com.google.code.gson:gson:2.8.0") + "compile"("com.googlecode.json-simple:json-simple:1.1.1") + "compile"("org.slf4j:slf4j-api:1.7.26") + + "compileOnly"(project(":worldedit-libs:core:ap")) + "annotationProcessor"(project(":worldedit-libs:core:ap")) + // ensure this is on the classpath for the AP + "annotationProcessor"("com.google.guava:guava:21.0") + "compileOnly"("com.google.auto.value:auto-value-annotations:${Versions.AUTO_VALUE}") + "annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}") + "testCompile"("org.mockito:mockito-core:1.9.0-rc1") +} + +tasks.withType().configureEach { + dependsOn(":worldedit-libs:build") + options.compilerArgs.add("-Aarg.name.key.prefix=") +} + +sourceSets { + main { + java { + srcDir("src/main/java") + srcDir("src/legacy/java") + } + resources { + srcDir("src/main/resources") + } + } +} diff --git a/worldedit-core/doctools/build.gradle.kts b/worldedit-core/doctools/build.gradle.kts index 75a347ece..803e1078e 100644 --- a/worldedit-core/doctools/build.gradle.kts +++ b/worldedit-core/doctools/build.gradle.kts @@ -4,14 +4,12 @@ plugins { kotlin("jvm") version "1.3.41" } +applyCommonConfiguration() + tasks.withType { kotlinOptions.jvmTarget = "1.8" } -repositories { - jcenter() -} - dependencies { "implementation"(project(":worldedit-libs:core:ap")) "implementation"(project(":worldedit-core")) From 47b9716bdcae6754c44f42702ce4871e45a4f90d Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 17:29:43 -0700 Subject: [PATCH 06/15] Migrate Fabric to Kotlin DSL --- worldedit-fabric/build.gradle | 108 ----------------------------- worldedit-fabric/build.gradle.kts | 109 ++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 108 deletions(-) delete mode 100644 worldedit-fabric/build.gradle create mode 100644 worldedit-fabric/build.gradle.kts diff --git a/worldedit-fabric/build.gradle b/worldedit-fabric/build.gradle deleted file mode 100644 index 70acc7a1d..000000000 --- a/worldedit-fabric/build.gradle +++ /dev/null @@ -1,108 +0,0 @@ -import net.fabricmc.loom.task.RemapJarTask - -buildscript { - repositories { - jcenter() - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - maven { - name = 'sponge' - url = 'https://repo.spongepowered.org/maven' - } - } - - dependencies { - classpath 'net.fabricmc:fabric-loom:0.2.4-SNAPSHOT' - classpath 'org.spongepowered:mixin:0.7.11-SNAPSHOT' - } -} - -PlatformConfigKt.applyPlatformAndCoreConfiguration(project) -PlatformConfigKt.applyShadowConfiguration(project) - -apply plugin: 'eclipse' -apply plugin: 'fabric-loom' - -def minecraftVersion = "1.14.3" -def fabricVersion = "0.3.0+build.187" -def yarnMappings = "1.14.3+build.1" -def loaderVersion = "0.4.8+build.155" - -configurations.all { Configuration it -> - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("com.google.guava:guava:21.0") - } -} - -dependencies { - compile project(':worldedit-core') - compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.1' - - minecraft "com.mojang:minecraft:${minecraftVersion}" - mappings "net.fabricmc:yarn:${yarnMappings}" - modCompile "net.fabricmc:fabric-loader:${loaderVersion}" - - modCompile "net.fabricmc.fabric-api:fabric-api:${fabricVersion}" - - testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0-rc1' -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -minecraft { -} - -project.archivesBaseName = "${project.archivesBaseName}-mc${minecraftVersion}" - -processResources { - // this will ensure that this task is redone when the versions change. - inputs.property 'version', project.internalVersion - - from(sourceSets.main.resources.srcDirs) { - include "fabric.mod.json" - expand "version": project.internalVersion - } - - // copy everything else except the mod json - from(sourceSets.main.resources.srcDirs) { - exclude "fabric.mod.json" - } -} - -jar { - manifest { - attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", - "WorldEdit-Version": version) - } -} - -shadowJar { - archiveClassifier.set("dist-dev") - dependencies { - relocate "org.slf4j", "com.sk89q.worldedit.slf4j" - relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" - - include(dependency('org.slf4j:slf4j-api')) - include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) - } -} - -task deobfJar(type: Jar) { - from sourceSets.main.output - archiveClassifier.set("dev") -} - -artifacts { - archives deobfJar -} - -task shadowJarRemap(type: RemapJarTask) { - input shadowJar.archiveFile - output new File(shadowJar.archiveFile.get().asFile.getAbsolutePath().replaceFirst('-dev\\.jar$', ".jar")) -} - -shadowJarRemap.dependsOn(shadowJar) -build.dependsOn(shadowJarRemap) \ No newline at end of file diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts new file mode 100644 index 000000000..f6417686a --- /dev/null +++ b/worldedit-fabric/build.gradle.kts @@ -0,0 +1,109 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import net.fabricmc.loom.task.RemapJarTask + +buildscript { + repositories { + jcenter() + maven { + name = "Fabric" + url = uri("https://maven.fabricmc.net/") + } + maven { + name = "sponge" + url = uri("https://repo.spongepowered.org/maven") + } + } + + dependencies { + "classpath"("net.fabricmc:fabric-loom:0.2.4-SNAPSHOT") + "classpath"("org.spongepowered:mixin:0.7.11-SNAPSHOT") + } +} + +applyPlatformAndCoreConfiguration() +applyShadowConfiguration() + +apply(plugin = "fabric-loom") + +val minecraftVersion = "1.14.3" +val fabricVersion = "0.3.0+build.187" +val yarnMappings = "1.14.3+build.1" +val loaderVersion = "0.4.8+build.155" + +configurations.all { + resolutionStrategy { + force("com.google.guava:guava:21.0") + } +} + +dependencies { + "compile"(project(":worldedit-core")) + "compile"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") + + "minecraft"("com.mojang:minecraft:$minecraftVersion") + "mappings"("net.fabricmc:yarn:$yarnMappings") + "modCompile"("net.fabricmc:fabric-loader:$loaderVersion") + + "modCompile"("net.fabricmc.fabric-api:fabric-api:$fabricVersion") + + "testCompile"("org.mockito:mockito-core:1.9.0-rc1") +} + +configure { + archivesBaseName = "$archivesBaseName-mc$minecraftVersion" +} + +val sourceSets = project.the().sourceSets + +tasks.named("processResources") { + // this will ensure that this task is redone when the versions change. + inputs.property("version", project.ext["internalVersion"]) + + from(sourceSets["main"].resources.srcDirs) { + include("fabric.mod.json") + expand("version" to project.ext["internalVersion"]) + } + + // copy everything else except the mod json + from(sourceSets["main"].resources.srcDirs) { + exclude("fabric.mod.json") + } +} + +tasks.named("jar") { + manifest { + attributes("Class-Path" to "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", + "WorldEdit-Version" to project.version) + } +} + +tasks.named("shadowJar") { + archiveClassifier.set("dist-dev") + dependencies { + relocate("org.slf4j", "com.sk89q.worldedit.slf4j") + relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge") + + include(dependency("org.slf4j:slf4j-api")) + include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + } +} + +tasks.register("deobfJar") { + from(sourceSets["main"].output) + archiveClassifier.set("dev") +} + +artifacts { + add("archives", tasks.named("deobfJar")) +} + +tasks.register("remapShadowJar") { + val shadowJar = tasks.getByName("shadowJar") + dependsOn(shadowJar) + setInput(shadowJar.archiveFile) + setOutput(shadowJar.archiveFile.get().asFile.getAbsolutePath().replaceFirst("-dev\\.jar$", ".jar")) +} + +tasks.named("assemble").configure { + dependsOn("remapShadowJar") +} From 3d4025c75738731c7ac1b8c51f0e1dd9be38f663 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 17:45:33 -0700 Subject: [PATCH 07/15] Migrate Forge to Kotlin DSL --- buildSrc/src/main/kotlin/GradleExtras.kt | 6 ++ buildSrc/src/main/kotlin/PlatformConfig.kt | 8 +- worldedit-fabric/build.gradle.kts | 2 - worldedit-forge/build.gradle | 106 -------------------- worldedit-forge/build.gradle.kts | 110 +++++++++++++++++++++ 5 files changed, 119 insertions(+), 113 deletions(-) delete mode 100644 worldedit-forge/build.gradle create mode 100644 worldedit-forge/build.gradle.kts diff --git a/buildSrc/src/main/kotlin/GradleExtras.kt b/buildSrc/src/main/kotlin/GradleExtras.kt index 5358f6b37..e7d1e0ede 100644 --- a/buildSrc/src/main/kotlin/GradleExtras.kt +++ b/buildSrc/src/main/kotlin/GradleExtras.kt @@ -1,6 +1,12 @@ import org.gradle.api.Project import org.gradle.api.plugins.ExtraPropertiesExtension +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.tasks.SourceSetContainer import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.the val Project.ext: ExtraPropertiesExtension get() = extensions.getByType() + +val Project.sourceSets: SourceSetContainer + get() = the().sourceSets diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index faf7a785a..c57dbdd20 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -11,11 +11,9 @@ import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.getByName -import org.gradle.kotlin.dsl.getPlugin -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.the -import org.gradle.kotlin.dsl.withType import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.withType fun Project.applyPlatformAndCoreConfiguration() { applyCommonConfiguration() @@ -64,7 +62,7 @@ fun Project.applyPlatformAndCoreConfiguration() { tasks.register("sourcesJar") { dependsOn("classes") archiveClassifier.set("sources") - from(project.the().sourceSets["main"].allSource) + from(sourceSets["main"].allSource) } artifacts { diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index f6417686a..acaa4fb25 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -53,8 +53,6 @@ configure { archivesBaseName = "$archivesBaseName-mc$minecraftVersion" } -val sourceSets = project.the().sourceSets - tasks.named("processResources") { // this will ensure that this task is redone when the versions change. inputs.property("version", project.ext["internalVersion"]) diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle deleted file mode 100644 index fc3dcaee8..000000000 --- a/worldedit-forge/build.gradle +++ /dev/null @@ -1,106 +0,0 @@ -PlatformConfigKt.applyPlatformAndCoreConfiguration(project) -PlatformConfigKt.applyShadowConfiguration(project) - -apply plugin: 'eclipse' -apply plugin: 'net.minecraftforge.gradle' - -def minecraftVersion = "1.14.3" -def forgeVersion = "27.0.13" - -configurations.all { Configuration it -> - it.resolutionStrategy { ResolutionStrategy rs -> - rs.force("com.google.guava:guava:21.0") - } -} - -dependencies { - compile project(':worldedit-core') - compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2' - - minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}" - - testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0-rc1' -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -minecraft { - mappings channel: 'snapshot', version: "20190626-${minecraftVersion}" - - runs { - client = { - // recommended logging data for a userdev environment - properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP' - // recommended logging level for the console - properties 'forge.logging.console.level': 'debug' - workingDirectory project.file('run').canonicalPath - source sourceSets.main - } - server = { - // recommended logging data for a userdev environment - properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP' - // recommended logging level for the console - properties 'forge.logging.console.level': 'debug' - workingDirectory project.file('run').canonicalPath - source sourceSets.main - } - } - -} - -project.archivesBaseName = "${project.archivesBaseName}-mc${minecraftVersion}" - -processResources { - // this will ensure that this task is redone when the versions change. - inputs.property 'version', project.internalVersion - inputs.property 'forgeVersion', forgeVersion - - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'META-INF/mods.toml' - - // replace version and mcversion - expand 'version': project.internalVersion, 'forgeVersion': forgeVersion - } - - // copy everything else except the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'META-INF/mods.toml' - } -} - -jar { - manifest { - attributes("WorldEdit-Version": version) - } -} - -shadowJar { - dependencies { - relocate "org.slf4j", "com.sk89q.worldedit.slf4j" - relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" - - include(dependency('org.slf4j:slf4j-api')) - include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) - include(dependency("de.schlichtherle:truezip")) - include(dependency("org.mozilla:rhino")) - } -} - -afterEvaluate { - reobf { - shadowJar { - mappings = createMcpToSrg.output - } - } -} - -task deobfJar(type: Jar) { - from sourceSets.main.output - getArchiveClassifier().set("dev") -} - -artifacts { - archives deobfJar -} diff --git a/worldedit-forge/build.gradle.kts b/worldedit-forge/build.gradle.kts new file mode 100644 index 000000000..25e159344 --- /dev/null +++ b/worldedit-forge/build.gradle.kts @@ -0,0 +1,110 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import net.minecraftforge.gradle.common.util.RunConfig +import net.minecraftforge.gradle.userdev.UserDevExtension +import net.minecraftforge.gradle.userdev.tasks.GenerateSRG +import net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace + +plugins { + id("net.minecraftforge.gradle") +} + +applyPlatformAndCoreConfiguration() +applyShadowConfiguration() + +val minecraftVersion = "1.14.3" +val forgeVersion = "27.0.13" + +configurations.all { + resolutionStrategy { + force("com.google.guava:guava:21.0") + } +} + +dependencies { + "compile"(project(":worldedit-core")) + "compile"("org.apache.logging.log4j:log4j-slf4j-impl:2.11.2") + + "minecraft"("net.minecraftforge:forge:$minecraftVersion-$forgeVersion") + + "testCompile"("org.mockito:mockito-core:1.9.0-rc1") +} + +configure { + mappings(mapOf( + "channel" to "snapshot", + "version" to "20190626-$minecraftVersion" + )) + + runs { + val runConfig = Action { + properties(mapOf( + "forge.logging.markers" to "SCAN,REGISTRIES,REGISTRYDUMP", + "forge.logging.console.level" to "debug" + )) + workingDirectory = project.file("run").canonicalPath + source(sourceSets["main"]) + } + create("client", runConfig) + create("server", runConfig) + } + +} + +configure { + archivesBaseName = "$archivesBaseName-mc$minecraftVersion" +} + +tasks.named("processResources") { + // this will ensure that this task is redone when the versions change. + inputs.property("version", project.ext["internalVersion"]) + inputs.property("forgeVersion", forgeVersion) + + // replace stuff in mcmod.info, nothing else + from(sourceSets["main"].resources.srcDirs) { + include("META-INF/mods.toml") + + // replace version and mcversion + expand( + "version" to project.ext["internalVersion"], + "forgeVersion" to forgeVersion + ) + } + + // copy everything else except the mcmod.info + from(sourceSets["main"].resources.srcDirs) { + exclude("META-INF/mods.toml") + } +} + +tasks.named("jar") { + manifest { + attributes("Class-Path" to "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", + "WorldEdit-Version" to project.version) + } +} + +tasks.named("shadowJar") { + dependencies { + relocate("org.slf4j", "com.sk89q.worldedit.slf4j") + relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge") + + include(dependency("org.slf4j:slf4j-api")) + include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + } +} + +afterEvaluate { + val reobf = extensions.getByName>("reobf") + reobf.maybeCreate("shadowJar").run { + mappings = tasks.getByName("createMcpToSrg").output + } +} + +tasks.register("deobfJar") { + from(sourceSets["main"].output) + archiveClassifier.set("dev") +} + +artifacts { + add("archives", tasks.named("deobfJar")) +} From 3bdc1c1cf2e838b9d8d074970d715c052a6f2699 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 17:48:31 -0700 Subject: [PATCH 08/15] Fixup after shade rhino merge --- worldedit-core/build.gradle.kts | 2 +- worldedit-forge/build.gradle.kts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 6d268e843..939679383 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -15,7 +15,7 @@ configurations.all { dependencies { "compile"(project(":worldedit-libs:core")) "compile"("de.schlichtherle:truezip:6.8.3") - "compile"("rhino:js:1.7R2") + "compile"("org.mozilla:rhino:1.7R5") "compile"("org.yaml:snakeyaml:1.9") "compile"("com.google.guava:guava:21.0") "compile"("com.google.code.findbugs:jsr305:1.3.9") diff --git a/worldedit-forge/build.gradle.kts b/worldedit-forge/build.gradle.kts index 25e159344..76abc2ac7 100644 --- a/worldedit-forge/build.gradle.kts +++ b/worldedit-forge/build.gradle.kts @@ -90,6 +90,9 @@ tasks.named("shadowJar") { include(dependency("org.slf4j:slf4j-api")) include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + include(dependency("de.schlichtherle:truezip")) + include(dependency("org.mozilla:rhino")) + } } From 5a14693aa95f24026a68e69350032f59f73008fd Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 17:59:23 -0700 Subject: [PATCH 09/15] Migrate Sponge, Libs to Kotlin DSL --- worldedit-forge/build.gradle.kts | 3 +- worldedit-libs/build.gradle | 3 -- worldedit-libs/build.gradle.kts | 3 ++ worldedit-sponge/build.gradle | 52 ------------------------------ worldedit-sponge/build.gradle.kts | 53 +++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 57 deletions(-) delete mode 100644 worldedit-libs/build.gradle create mode 100644 worldedit-libs/build.gradle.kts delete mode 100644 worldedit-sponge/build.gradle create mode 100644 worldedit-sponge/build.gradle.kts diff --git a/worldedit-forge/build.gradle.kts b/worldedit-forge/build.gradle.kts index 76abc2ac7..78c23c898 100644 --- a/worldedit-forge/build.gradle.kts +++ b/worldedit-forge/build.gradle.kts @@ -78,8 +78,7 @@ tasks.named("processResources") { tasks.named("jar") { manifest { - attributes("Class-Path" to "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", - "WorldEdit-Version" to project.version) + attributes("WorldEdit-Version" to project.version) } } diff --git a/worldedit-libs/build.gradle b/worldedit-libs/build.gradle deleted file mode 100644 index 29c096e2d..000000000 --- a/worldedit-libs/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -tasks.register("build") { - dependsOn(subprojects.collect { it.tasks.named("build") }) -} diff --git a/worldedit-libs/build.gradle.kts b/worldedit-libs/build.gradle.kts new file mode 100644 index 000000000..40b3746a9 --- /dev/null +++ b/worldedit-libs/build.gradle.kts @@ -0,0 +1,3 @@ +tasks.register("build") { + dependsOn(subprojects.map { it.tasks.named("build") }) +} diff --git a/worldedit-sponge/build.gradle b/worldedit-sponge/build.gradle deleted file mode 100644 index 81d445a5d..000000000 --- a/worldedit-sponge/build.gradle +++ /dev/null @@ -1,52 +0,0 @@ -plugins { - id("org.spongepowered.plugin") -} - -PlatformConfigKt.applyPlatformAndCoreConfiguration(project) -PlatformConfigKt.applyShadowConfiguration(project) - -repositories { - maven { url "https://repo.codemc.org/repository/maven-public" } -} - -dependencies { - compile project(':worldedit-core') - compile project(':worldedit-libs:sponge') - compile 'org.spongepowered:spongeapi:7.1.0' - compile 'org.bstats:bstats-sponge:1.5' - testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1' -} - -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -sponge { - plugin { - id = 'worldedit' - } -} - -jar { - manifest { - attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", - "WorldEdit-Version": version) - } -} - -shadowJar { - dependencies { - relocate ("org.bstats", "com.sk89q.worldedit.sponge.bstats") { - include(dependency('org.bstats:bstats-sponge:1.5')) - } - } -} - -if (project.hasProperty("signing")) { - apply plugin: 'signing' - - signing { - sign shadowJar - } - - build.dependsOn('signShadowJar') -} \ No newline at end of file diff --git a/worldedit-sponge/build.gradle.kts b/worldedit-sponge/build.gradle.kts new file mode 100644 index 000000000..1c5fa9453 --- /dev/null +++ b/worldedit-sponge/build.gradle.kts @@ -0,0 +1,53 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id("org.spongepowered.plugin") +} + +applyPlatformAndCoreConfiguration() +applyShadowConfiguration() + +repositories { + maven { url = uri("https://repo.codemc.org/repository/maven-public") } +} + +dependencies { + compile(project(":worldedit-core")) + compile(project(":worldedit-libs:sponge")) + compile("org.spongepowered:spongeapi:7.1.0") + compile("org.bstats:bstats-sponge:1.5") + testCompile("org.mockito:mockito-core:1.9.0-rc1") +} + +sponge { + plugin { + id = "worldedit" + } +} + +tasks.named("jar") { + manifest { + attributes("Class-Path" to "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", + "WorldEdit-Version" to project.version) + } +} + +tasks.named("shadowJar") { + dependencies { + relocate ("org.bstats", "com.sk89q.worldedit.sponge.bstats") { + include(dependency("org.bstats:bstats-sponge:1.5")) + } + } +} + +if (project.hasProperty("signing")) { + apply(plugin = "signing") + + configure { + sign("shadowJar") + } + + tasks.named("build").configure { + dependsOn("signShadowJar") + } +} \ No newline at end of file From 5277f99bf28d57ada505dedfb1c425948bcc1c84 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 10 Jul 2019 18:55:09 -0700 Subject: [PATCH 10/15] Minor fixes for craftscripts in Forge --- worldedit-core/build.gradle.kts | 2 +- .../MinecraftHidingClassShutter.java | 41 +++++ .../scripting/RhinoCraftScriptEngine.java | 1 + .../scripting/java/RhinoScriptEngine.java | 134 --------------- .../java/RhinoScriptEngineFactory.java | 153 ------------------ worldedit-forge/build.gradle.kts | 4 +- 6 files changed, 46 insertions(+), 289 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 939679383..6a9266247 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -15,7 +15,7 @@ configurations.all { dependencies { "compile"(project(":worldedit-libs:core")) "compile"("de.schlichtherle:truezip:6.8.3") - "compile"("org.mozilla:rhino:1.7R5") + "compile"("org.mozilla:rhino:1.7.11") "compile"("org.yaml:snakeyaml:1.9") "compile"("com.google.guava:guava:21.0") "compile"("com.google.code.findbugs:jsr305:1.3.9") diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java new file mode 100644 index 000000000..20324ed59 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java @@ -0,0 +1,41 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.scripting; + +import org.mozilla.javascript.ClassShutter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Hides Minecraft's obfuscated & de-obfuscated names from scripts. + */ +class MinecraftHidingClassShutter implements ClassShutter { + + private static final Logger LOGGER = LoggerFactory.getLogger(MinecraftHidingClassShutter.class); + + @Override + public boolean visibleToScripts(String fullClassName) { + if (!fullClassName.contains(".")) { + // Default package -- probably Minecraft + return false; + } + return !fullClassName.startsWith("net.minecraft"); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java index 79d51cefb..8cad2670b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java @@ -50,6 +50,7 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine { throws ScriptException, Throwable { RhinoContextFactory factory = new RhinoContextFactory(timeLimit); Context cx = factory.enterContext(); + cx.setClassShutter(new MinecraftHidingClassShutter()); ScriptableObject scriptable = new ImporterTopLevel(cx); Scriptable scope = cx.initStandardObjects(scriptable); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java deleted file mode 100644 index afab20c3a..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.scripting.java; - -import com.sk89q.worldedit.scripting.RhinoContextFactory; -import org.mozilla.javascript.Context; -import org.mozilla.javascript.ImporterTopLevel; -import org.mozilla.javascript.JavaScriptException; -import org.mozilla.javascript.RhinoException; -import org.mozilla.javascript.Scriptable; -import org.mozilla.javascript.ScriptableObject; - -import java.io.IOException; -import java.io.Reader; - -import javax.script.AbstractScriptEngine; -import javax.script.Bindings; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineFactory; -import javax.script.ScriptException; -import javax.script.SimpleBindings; - -public class RhinoScriptEngine extends AbstractScriptEngine { - private ScriptEngineFactory factory; - private Context cx; - - public RhinoScriptEngine() { - RhinoContextFactory factory = new RhinoContextFactory(3000); - factory.enterContext(); - } - - @Override - public Bindings createBindings() { - return new SimpleBindings(); - } - - @Override - public Object eval(String script, ScriptContext context) - throws ScriptException { - - Scriptable scope = setupScope(cx, context); - - String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null - ? "" : filename; - - try { - return cx.evaluateString(scope, script, filename, 1, null); - } catch (RhinoException e) { - String msg; - int line = (line = e.lineNumber()) == 0 ? -1 : line; - - if (e instanceof JavaScriptException) { - msg = String.valueOf(((JavaScriptException) e).getValue()); - } else { - msg = e.getMessage(); - } - - ScriptException scriptException = - new ScriptException(msg, e.sourceName(), line); - scriptException.initCause(e); - - throw scriptException; - } finally { - Context.exit(); - } - } - - @Override - public Object eval(Reader reader, ScriptContext context) - throws ScriptException { - - Scriptable scope = setupScope(cx, context); - - String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null - ? "" : filename; - - try { - return cx.evaluateReader(scope, reader, filename, 1, null); - } catch (RhinoException e) { - String msg; - int line = (line = e.lineNumber()) == 0 ? -1 : line; - - if (e instanceof JavaScriptException) { - msg = String.valueOf(((JavaScriptException) e).getValue()); - } else { - msg = e.getMessage(); - } - - ScriptException scriptException = - new ScriptException(msg, e.sourceName(), line); - scriptException.initCause(e); - - throw scriptException; - } catch (IOException e) { - throw new ScriptException(e); - } finally { - Context.exit(); - } - } - - @Override - public ScriptEngineFactory getFactory() { - if (factory != null) { - return factory; - } else { - return new RhinoScriptEngineFactory(); - } - } - - private Scriptable setupScope(Context cx, ScriptContext context) { - ScriptableObject scriptable = new ImporterTopLevel(cx); - Scriptable scope = cx.initStandardObjects(scriptable); - //ScriptableObject.putProperty(scope, "argv", Context.javaToJS(args, scope)); - return scope; - } -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java deleted file mode 100644 index ee312229c..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.scripting.java; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.script.ScriptEngine; -import javax.script.ScriptEngineFactory; - -public class RhinoScriptEngineFactory implements ScriptEngineFactory { - private static List names; - private static List mimeTypes; - private static List extensions; - - static { - names = new ArrayList<>(5); - names.add("ECMAScript"); - names.add("ecmascript"); - names.add("JavaScript"); - names.add("javascript"); - names.add("js"); - names = Collections.unmodifiableList(names); - - mimeTypes = new ArrayList<>(4); - mimeTypes.add("application/ecmascript"); - mimeTypes.add("text/ecmascript"); - mimeTypes.add("application/javascript"); - mimeTypes.add("text/javascript"); - mimeTypes = Collections.unmodifiableList(mimeTypes); - - extensions = new ArrayList<>(2); - extensions.add("emcascript"); - extensions.add("js"); - extensions = Collections.unmodifiableList(extensions); - } - - @Override - public String getEngineName() { - return "Rhino JavaScript Engine (SK)"; - } - - @Override - public String getEngineVersion() { - return "unknown"; - } - - @Override - public List getExtensions() { - return extensions; - } - - @Override - public String getLanguageName() { - return "EMCAScript"; - } - - @Override - public String getLanguageVersion() { - return "1.8"; - } - - @Override - public String getMethodCallSyntax(String obj, String m, String... args) { - StringBuilder s = new StringBuilder(); - s.append(obj); - s.append("."); - s.append(m); - s.append("("); - - for (int i = 0; i < args.length; ++i) { - s.append(args[i]); - if (i < args.length - 1) { - s.append(","); - } - } - - s.append(")"); - - return s.toString(); - } - - @Override - public List getMimeTypes() { - return mimeTypes; - } - - @Override - public List getNames() { - return names; - } - - @Override - public String getOutputStatement(String str) { - return "print(" + str.replace("\\", "\\\\") - .replace("\"", "\\\\\"") - .replace(";", "\\\\;") + ")"; - } - - @Override - public Object getParameter(String key) { - switch (key) { - case ScriptEngine.ENGINE: - return getEngineName(); - case ScriptEngine.ENGINE_VERSION: - return getEngineVersion(); - case ScriptEngine.NAME: - return getEngineName(); - case ScriptEngine.LANGUAGE: - return getLanguageName(); - case ScriptEngine.LANGUAGE_VERSION: - return getLanguageVersion(); - case "THREADING": - return "MULTITHREADED"; - default: - throw new IllegalArgumentException("Invalid key"); - } - } - - @Override - public String getProgram(String... statements) { - StringBuilder s = new StringBuilder(); - for (String stmt : statements) { - s.append(stmt); - s.append(";"); - } - return s.toString(); - } - - @Override - public ScriptEngine getScriptEngine() { - return new RhinoScriptEngine(); - } - -} diff --git a/worldedit-forge/build.gradle.kts b/worldedit-forge/build.gradle.kts index 78c23c898..235900181 100644 --- a/worldedit-forge/build.gradle.kts +++ b/worldedit-forge/build.gradle.kts @@ -91,7 +91,9 @@ tasks.named("shadowJar") { include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) include(dependency("de.schlichtherle:truezip")) include(dependency("org.mozilla:rhino")) - + } + minimize { + exclude(dependency("org.mozilla:rhino")) } } From 52a62b984ba5ce29c14bd0a90e9fb78ef4db553b Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sat, 13 Jul 2019 22:16:16 -0700 Subject: [PATCH 11/15] Improve logging, update to 5.5.1 --- build.gradle.kts | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7088d0893..07b943531 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ import org.ajoberstar.grgit.Grgit -println(""" +logger.lifecycle(""" ******************************************* You are building WorldEdit! @@ -19,9 +19,9 @@ applyRootArtifactoryConfig() if (!project.hasProperty("gitCommitHash")) { apply(plugin = "org.ajoberstar.grgit") ext["gitCommitHash"] = try { - (ext["grgit"] as Grgit).head().abbreviatedId + (ext["grgit"] as Grgit?)?.head()?.abbreviatedId } catch (e: Exception) { - println("Error getting commit hash: " + e.message) + logger.warn("Error getting commit hash", e) "no_git_id" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e0c4de36d..430dfabc5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 58863c22e8d79602f50dc9b667866bdc1e2c1316 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sat, 13 Jul 2019 23:26:31 -0700 Subject: [PATCH 12/15] Try downgrading fabric --- worldedit-fabric/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index acaa4fb25..f0843a651 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -15,7 +15,7 @@ buildscript { } dependencies { - "classpath"("net.fabricmc:fabric-loom:0.2.4-SNAPSHOT") + "classpath"("net.fabricmc:fabric-loom:0.2.3-SNAPSHOT") "classpath"("org.spongepowered:mixin:0.7.11-SNAPSHOT") } } From 98e29f634fc0cf57181b9147ccc1cc59b3d5976c Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sun, 14 Jul 2019 00:00:11 -0700 Subject: [PATCH 13/15] Fix fabric output jar --- worldedit-fabric/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index f0843a651..d41010624 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -99,7 +99,7 @@ tasks.register("remapShadowJar") { val shadowJar = tasks.getByName("shadowJar") dependsOn(shadowJar) setInput(shadowJar.archiveFile) - setOutput(shadowJar.archiveFile.get().asFile.getAbsolutePath().replaceFirst("-dev\\.jar$", ".jar")) + setOutput(shadowJar.archiveFile.get().asFile.absolutePath.replace(Regex("-dev\\.jar$"), ".jar")) } tasks.named("assemble").configure { From ad5dcbea5864f4fbc21ae4e66b378e0341a7a9e5 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Mon, 15 Jul 2019 09:14:02 -0700 Subject: [PATCH 14/15] Attempt to fix ASM conflict --- buildSrc/build.gradle.kts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 658143d8d..1d1da51c1 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -15,7 +15,11 @@ repositories { configurations.all { resolutionStrategy { // Fabric needs this. - force("commons-io:commons-io:2.5", "org.ow2.asm:asm:7.1") + force( + "commons-io:commons-io:2.5", + "org.ow2.asm:asm:7.1", + "org.ow2.asm:asm-commons:7.1" + ) } } From 5fa311be48e18f24a67f1bc8a12fd36d3133b8c2 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Mon, 15 Jul 2019 09:42:28 -0700 Subject: [PATCH 15/15] Account for IntelliJ bug --- worldedit-fabric/build.gradle.kts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index d41010624..7b11f0aca 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -1,5 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import net.fabricmc.loom.task.RemapJarTask +import kotlin.reflect.KClass buildscript { repositories { @@ -95,11 +96,16 @@ artifacts { add("archives", tasks.named("deobfJar")) } -tasks.register("remapShadowJar") { - val shadowJar = tasks.getByName("shadowJar") - dependsOn(shadowJar) - setInput(shadowJar.archiveFile) - setOutput(shadowJar.archiveFile.get().asFile.absolutePath.replace(Regex("-dev\\.jar$"), ".jar")) +// intellij has trouble detecting RemapJarTask as a subclass of Task +@Suppress("UNCHECKED_CAST") +val remapJarIntellijHack = RemapJarTask::class as KClass +tasks.register("remapShadowJar", remapJarIntellijHack) { + (this as RemapJarTask).run { + val shadowJar = tasks.getByName("shadowJar") + dependsOn(shadowJar) + setInput(shadowJar.archiveFile) + setOutput(shadowJar.archiveFile.get().asFile.absolutePath.replace(Regex("-dev\\.jar$"), ".jar")) + } } tasks.named("assemble").configure {