From 61494fd76e8dad947efff8a57ea5e29be91b538c Mon Sep 17 00:00:00 2001 From: wizjany Date: Mon, 29 Jul 2019 23:25:13 -0400 Subject: [PATCH] Migrate gradle to kotlin dsl. --- HEADER.txt | 16 +++ build.gradle | 136 ------------------ build.gradle.kts | 26 ++++ buildSrc/build.gradle.kts | 19 +++ buildSrc/src/main/kotlin/ArtifactoryConfig.kt | 40 ++++++ buildSrc/src/main/kotlin/CommonConfig.kt | 18 +++ buildSrc/src/main/kotlin/GradleExtras.kt | 12 ++ buildSrc/src/main/kotlin/LibsConfig.kt | 98 +++++++++++++ buildSrc/src/main/kotlin/PlatformConfig.kt | 115 +++++++++++++++ buildSrc/src/main/kotlin/Versions.kt | 6 + config/checkstyle/checkstyle.xml | 6 - config/checkstyle/header.txt | 18 --- gradle.properties | 2 + gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 3 - settings.gradle.kts | 7 + worldguard-bukkit/build.gradle | 55 ------- worldguard-bukkit/build.gradle.kts | 57 ++++++++ .../src/main/resources/plugin.yml | 2 +- worldguard-core/build.gradle | 30 ---- worldguard-core/build.gradle.kts | 33 +++++ .../formatting/component/BlacklistNotify.java | 1 + .../util/formatting/component/Notify.java | 1 + worldguard-libs/build.gradle.kts | 3 + worldguard-libs/bukkit/build.gradle.kts | 1 + worldguard-libs/core/build.gradle.kts | 5 + worldguard-sponge/build.gradle | 16 --- 27 files changed, 462 insertions(+), 266 deletions(-) create mode 100644 HEADER.txt delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 buildSrc/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 delete mode 100644 config/checkstyle/header.txt create mode 100644 gradle.properties delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts delete mode 100644 worldguard-bukkit/build.gradle create mode 100644 worldguard-bukkit/build.gradle.kts delete mode 100644 worldguard-core/build.gradle create mode 100644 worldguard-core/build.gradle.kts create mode 100644 worldguard-libs/build.gradle.kts create mode 100644 worldguard-libs/bukkit/build.gradle.kts create mode 100644 worldguard-libs/core/build.gradle.kts delete mode 100644 worldguard-sponge/build.gradle diff --git a/HEADER.txt b/HEADER.txt new file mode 100644 index 00000000..b80194ec --- /dev/null +++ b/HEADER.txt @@ -0,0 +1,16 @@ +WorldGuard, a suite of tools for Minecraft +Copyright (C) sk89q +Copyright (C) WorldGuard 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 . diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 7b09d203..00000000 --- a/build.gradle +++ /dev/null @@ -1,136 +0,0 @@ -println """ -******************************************* - You are building WorldGuard! - - 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 IRC! irc.esper.net #sk89q - - Output files will be in [subproject]/build/libs -******************************************* -""" - -buildscript { - repositories { - mavenCentral() - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } - jcenter() - } - - configurations.all { - resolutionStrategy { - force 'com.google.guava:guava:21.0' - } - } - - dependencies { - classpath "com.github.jengelman.gradle.plugins:shadow:4.0.3" - classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5' - classpath 'org.ajoberstar:gradle-git:1.7.2' - } -} - -allprojects { - group = 'com.sk89q.worldguard' - 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")) { - try { - def repo = org.ajoberstar.grgit.Grgit.open(project.file('.')) - ext.gitCommitHash = repo.head().abbreviatedId - } catch (Exception e) { - 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 - - } - } -} -artifactoryPublish.skip = true - -subprojects { - apply plugin: 'java' - apply plugin: 'java-library' - apply plugin: 'maven' - apply plugin: 'checkstyle' - apply plugin: 'com.github.johnrengelman.shadow' - apply plugin: 'com.jfrog.artifactory' - - 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' - - repositories { - mavenLocal() - mavenCentral() - maven { url "https://repo.spongepowered.org/maven/" } - maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } - maven { url "https://maven.sk89q.com/repo/" } - maven { url "https://repo.maven.apache.org/maven2" } - } - - if (JavaVersion.current().isJava8Compatible()) { - // Java 8 turns on doclint which we fail - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - - artifacts { - archives jar - archives sourcesJar - archives javadocJar - } - - build.dependsOn(checkstyleMain) - build.dependsOn(checkstyleTest) - build.dependsOn(sourcesJar) - build.dependsOn(javadocJar) - - shadowJar { - classifier 'dist' - dependencies { - include(dependency('org.khelekore:prtree:1.5.0')) - include(dependency('com.sk89q:squirrelid:0.2.0')) - include(dependency('org.flywaydb:flyway-core:3.0')) - } - exclude 'GradleStart**' - exclude '.cache' - exclude 'LICENSE*' - } - - artifactoryPublish { - publishConfigs('archives') - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..95099a36 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,26 @@ +import org.ajoberstar.grgit.Grgit + +logger.lifecycle(""" +******************************************* + You are building WorldGuard! + If you encounter trouble: + 1) Try running 'build' in a separate Gradle run + 2) Use gradlew and not gradle + 3) 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) { + logger.warn("Error getting commit hash", e) + + "no_git_id" + } +} \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..16dfb8a2 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + `kotlin-dsl` + kotlin("jvm") version embeddedKotlinVersion +} + +repositories { + jcenter() + gradlePluginPortal() +} + +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") +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ArtifactoryConfig.kt b/buildSrc/src/main/kotlin/ArtifactoryConfig.kt new file mode 100644 index 00000000..baa32b20 --- /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() { + val named = tasks.named("artifactoryPublish") { + publishConfigs("archives") + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt new file mode 100644 index 00000000..e93f4a2d --- /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 00000000..e7d1e0ed --- /dev/null +++ b/buildSrc/src/main/kotlin/GradleExtras.kt @@ -0,0 +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/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt new file mode 100644 index 00000000..51782c3b --- /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}.worldguard-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("com.sk89q.squirrelid", "com.sk89q.worldguard.util.profile") + } + 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("(.*)com/sk89q/squirrelid((?:/|$).*)") + val textPattern = Regex("com\\.sk89q\\.squirrelid") + eachFile { + filter { + it.replaceFirst(textPattern, "com.sk89q.worldguard.util.profile") + } + path = path.replaceFirst(filePattern, "$1com/sk89q/worldguard/util/profile$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 00000000..88494956 --- /dev/null +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -0,0 +1,115 @@ +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.api.tasks.testing.Test +import org.gradle.external.javadoc.CoreJavadocOptions +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.getByName +import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.withType + +fun Project.applyPlatformAndCoreConfiguration() { + applyCommonConfiguration() + apply(plugin = "java") + apply(plugin = "eclipse") + apply(plugin = "idea") + 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" + } + + tasks.withType().configureEach { + useJUnit() + } + + dependencies { + "testImplementation"("junit:junit:${Versions.JUNIT}") + "testRuntime"("junit:junit:${Versions.JUNIT}") + // TODO switch to jupiter - doesn't support abstract test classes so tests need rewriting + //"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}") + //"testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}") + } + + // 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 == "worldguard-core" || name == "worldguard-bukkit") { + tasks.register("sourcesJar") { + dependsOn("classes") + archiveClassifier.set("sources") + from(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(":worldguard-libs:core")) + include(project(":worldguard-libs:${project.name.replace("worldguard-", "")}")) + include(project(":worldguard-core")) + } + exclude("GradleStart**") + exclude(".cache") + exclude("LICENSE*") + } +} diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt new file mode 100644 index 00000000..9d98de41 --- /dev/null +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -0,0 +1,6 @@ +object Versions { +// const val PISTON = "0.4.3" +// const val AUTO_VALUE = "1.6.5" + const val JUNIT = "4.11" + const val SQUIRRELID = "0.2.0" +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 9d3768f2..56240316 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -58,10 +58,4 @@ - - - - - - diff --git a/config/checkstyle/header.txt b/config/checkstyle/header.txt deleted file mode 100644 index c15c43b1..00000000 --- a/config/checkstyle/header.txt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard 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 . - */ diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..c528387a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +group=com.sk89q.worldguard +version=7.0.1-SNAPSHOT diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 75b8c7c8..430dfabc 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.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 2b53ed70..00000000 --- a/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = 'worldguard' - -include 'worldguard-core', 'worldguard-bukkit' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..43f7c966 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,7 @@ +rootProject.name = "worldguard" + +include("worldguard-libs") +include("worldguard-libs:core") +include("worldguard-core") +include("worldguard-libs:bukkit") +include("worldguard-bukkit") diff --git a/worldguard-bukkit/build.gradle b/worldguard-bukkit/build.gradle deleted file mode 100644 index c45453e7..00000000 --- a/worldguard-bukkit/build.gradle +++ /dev/null @@ -1,55 +0,0 @@ -apply plugin: 'eclipse' -apply plugin: 'idea' - -repositories { - maven { - name = 'bstats repo' - url = 'https://repo.codemc.org/repository/maven-public' - } -} - -dependencies { - compile project(path: ':worldguard-core', configuration: 'shadow') - api 'org.bukkit:bukkit:1.14.2-R0.1-SNAPSHOT' - api ('com.sk89q.worldedit:worldedit-bukkit:7.0.1-SNAPSHOT') { - exclude group: 'io.papermc', module: 'paperlib' - } - implementation ('com.sk89q:commandbook:2.3') { - exclude group: 'com.sk89q', module: 'worldedit' - exclude group: 'com.zachsthings.libcomponents' - exclude group: 'org.bukkit' - exclude group: 'net.sf.opencsv' - } - implementation 'org.bstats:bstats-bukkit:1.5' -} - -processResources { - from (sourceSets.main.resources.srcDirs) { - expand project.properties - include 'plugin.yml' - } - - from (sourceSets.main.resources.srcDirs) { - exclude 'plugin.yml' - } -} - -jar { - manifest { - attributes("Implementation-Version": version) - } -} - -shadowJar { - dependencies { - include(dependency(':worldguard-core')) - relocate ("org.bstats", "com.sk89q.worldguard.bukkit.bstats") { - include(dependency("org.bstats:bstats-bukkit:1.5")) - } - } - - relocate('org.flywaydb', 'com.sk89q.worldguard.internal.flywaydb') - -} - -build.dependsOn(shadowJar) diff --git a/worldguard-bukkit/build.gradle.kts b/worldguard-bukkit/build.gradle.kts new file mode 100644 index 00000000..2920ae15 --- /dev/null +++ b/worldguard-bukkit/build.gradle.kts @@ -0,0 +1,57 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id("java-library") + id("net.ltgt.apt-eclipse") + id("net.ltgt.apt-idea") +} + +applyPlatformAndCoreConfiguration() +applyShadowConfiguration() + +repositories { + maven { + name = "spigot" + url = uri("https://hub.spigotmc.org/nexus/content/groups/public") + } + maven { + name = "bstats" + url = uri("https://repo.codemc.org/repository/maven-public") + } +} + +dependencies { + "compile"(project(":worldguard-core")) + "compile"(project(":worldguard-libs:bukkit")) + "api"("org.bukkit:bukkit:1.14.2-R0.1-SNAPSHOT") + "api"("com.sk89q.worldedit:worldedit-bukkit:7.0.1-SNAPSHOT") { isTransitive = false } + "implementation"("com.sk89q:commandbook:2.3") { isTransitive = false } + "implementation"("org.bstats:bstats-bukkit:1.5") +} + +tasks.named("processResources") { + filesMatching("plugin.yml") { + expand("internalVersion" to project.ext["internalVersion"]) + } +} + +tasks.named("jar") { + manifest { + attributes("Implementation-Version" to project.version) + } +} + +tasks.named("shadowJar") { + dependencies { + include(dependency(":worldguard-core")) + include(dependency(":worldguard-libs:core")) + include(dependency(":worldguard-libs:bukkit")) + relocate("org.bstats", "com.sk89q.worldguard.bukkit.bstats") { + include(dependency("org.bstats:bstats-bukkit:1.5")) + } + } +} + +tasks.named("assemble").configure { + dependsOn("shadowJar") +} \ No newline at end of file diff --git a/worldguard-bukkit/src/main/resources/plugin.yml b/worldguard-bukkit/src/main/resources/plugin.yml index 71121ba4..1acb421e 100644 --- a/worldguard-bukkit/src/main/resources/plugin.yml +++ b/worldguard-bukkit/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: WorldGuard main: com.sk89q.worldguard.bukkit.WorldGuardPlugin -version: "${project.internalVersion}" +version: "${internalVersion}" depend: [WorldEdit] softdepend: [CommandBook] api-version: 1.13 diff --git a/worldguard-core/build.gradle b/worldguard-core/build.gradle deleted file mode 100644 index 230a991b..00000000 --- a/worldguard-core/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -apply plugin: 'eclipse' -apply plugin: 'idea' - -dependencies { - api 'com.sk89q.worldedit:worldedit-core:7.0.1-SNAPSHOT' - implementation 'com.sk89q:squirrelid:0.2.0' - implementation 'org.flywaydb:flyway-core:3.0' - implementation 'org.khelekore:prtree:1.5.0' - - api 'com.google.code.findbugs:jsr305:1.3.9' - testImplementation 'junit:junit:4.11' - testImplementation 'org.hamcrest:hamcrest-library:1.2.1' -} - -sourceSets { - main { - java { - srcDir 'src/main/java' - } - resources { - srcDir 'src/main/resources' - } - } -} - -shadowJar { - relocate('com.sk89q.squirrelid', 'com.sk89q.worldguard.util.profile') -} - -build.dependsOn(shadowJar { classifier = null }) diff --git a/worldguard-core/build.gradle.kts b/worldguard-core/build.gradle.kts new file mode 100644 index 00000000..b617f504 --- /dev/null +++ b/worldguard-core/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + id("java-library") + id("net.ltgt.apt-eclipse") + id("net.ltgt.apt-idea") +} + +applyPlatformAndCoreConfiguration() + +dependencies { + "compile"(project(":worldguard-libs:core")) + "compile"("com.sk89q.worldedit:worldedit-core:7.0.1-SNAPSHOT") + "implementation"("com.sk89q:squirrelid:0.2.0") + "implementation"("org.flywaydb:flyway-core:3.0") + "implementation"("org.khelekore:prtree:1.5.0") + + "compileOnly"("com.google.code.findbugs:jsr305:1.3.9") + "testImplementation"("org.hamcrest:hamcrest-library:1.2.1") +} + +tasks.withType().configureEach { + dependsOn(":worldguard-libs:build") +} + +sourceSets { + main { + java { + srcDir("src/main/java") + } + resources { + srcDir("src/main/resources") + } + } +} \ No newline at end of file diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/BlacklistNotify.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/BlacklistNotify.java index 805e064e..b4edbea7 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/BlacklistNotify.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/BlacklistNotify.java @@ -16,6 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ + package com.sk89q.worldguard.util.formatting.component; import com.sk89q.worldedit.util.formatting.text.TextComponent; diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/Notify.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/Notify.java index 7faabefe..9b9cdf4a 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/Notify.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/Notify.java @@ -16,6 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ + package com.sk89q.worldguard.util.formatting.component; import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; diff --git a/worldguard-libs/build.gradle.kts b/worldguard-libs/build.gradle.kts new file mode 100644 index 00000000..33c839af --- /dev/null +++ b/worldguard-libs/build.gradle.kts @@ -0,0 +1,3 @@ +tasks.register("build") { + dependsOn(subprojects.map { it.tasks.named("build") }) +} \ No newline at end of file diff --git a/worldguard-libs/bukkit/build.gradle.kts b/worldguard-libs/bukkit/build.gradle.kts new file mode 100644 index 00000000..388618ce --- /dev/null +++ b/worldguard-libs/bukkit/build.gradle.kts @@ -0,0 +1 @@ +applyLibrariesConfiguration() diff --git a/worldguard-libs/core/build.gradle.kts b/worldguard-libs/core/build.gradle.kts new file mode 100644 index 00000000..5ed38566 --- /dev/null +++ b/worldguard-libs/core/build.gradle.kts @@ -0,0 +1,5 @@ +applyLibrariesConfiguration() + +dependencies { + "shade"("com.sk89q:squirrelid:${Versions.SQUIRRELID}") +} diff --git a/worldguard-sponge/build.gradle b/worldguard-sponge/build.gradle deleted file mode 100644 index db5786f3..00000000 --- a/worldguard-sponge/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -apply plugin: 'eclipse' -apply plugin: 'idea' - -dependencies { - compile project(':worldguard-core') - compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT' -} - -shadowJar { - dependencies { - include(dependency(':worldguard-core')) - } - -} - -build.dependsOn(shadowJar)