From e80c18389450230604e39494b465bdd0cfb5fc7e Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Thu, 7 Feb 2019 17:10:08 -0800 Subject: [PATCH] Cleanup and fix some of the gradle scripts. Add shadows to retain dependencies. Signed-off-by: Gabriel Harris-Rouquette --- build.gradle.kts | 11 ++++--- bukkit/build.gradle.kts | 29 +++++++++++++++---- gradle.properties | 4 +-- settings.gradle.kts | 8 +++++ sponge/build.gradle.kts | 26 ++++++++--------- .../java/com/gmail/nossr50/SpongePlugin.java | 3 +- 6 files changed, 56 insertions(+), 25 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 688ad4cc1..77ba789c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,7 @@ buildscript { - repositories { - mavenLocal() - mavenCentral() + dependencies { + classpath("com.github.jengelman.gradle.plugins:shadow:4.0.4") } - } group = properties["pluginGroup"]!! @@ -14,6 +12,7 @@ plugins { java } +// Set up defaults for all projects, maven repositories, java compatibility level and compiling encoding allprojects { apply(plugin="java-library") @@ -30,4 +29,8 @@ allprojects { targetCompatibility = JavaVersion.VERSION_1_8 } + tasks.getting(JavaCompile::class) { + options.encoding = "UTF-8" + } + } diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 3e95fadf3..300a9d603 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -1,3 +1,14 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath("com.github.jengelman.gradle.plugins:shadow:4.0.4") + } +} + repositories { // Spigot & Bukkit @@ -5,36 +16,44 @@ repositories { maven("https://oss.sonatype.org/content/repositories/snapshots") mavenLocal() // For nms variants - } plugins { java + id("com.github.johnrengelman.shadow") } dependencies { implementation("org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT") // Spigot API implementation("com.sk89q.worldguard", "worldguard-core", "7.0.0-SNAPSHOT") // WorldGuard implementation("com.sk89q.worldguard", "worldguard-legacy", "7.0.0-SNAPSHOT") // NEEDED - implementation("org.bstats", "bstats-bukkit", "1.4") // Bukkit bstats + compile("org.bstats", "bstats-bukkit", "1.4") // Bukkit bstats implementation("org.apache.tomcat", "tomcat-jdbc", "7.0.52") // tomcat JDBC implementation("org.apache.tomcat", "tomcat-juli", "7.0.52") // tomcat juli implementation("junit", "junit", "4.12") + compile(project(":core")) } java { sourceSets { create("nms") } - } val jar by tasks.getting(Jar::class) { manifest { attributes(mapOf( - "Implementation-Title" to project.name, - "Implementation-Version" to project.version, + "Implementation-Title" to "mcMMO", + "Implementation-Version" to rootProject.properties["pluginVersion"]!!, "Main-Class" to "com.gmail.nossr50.mcMMO" // Main plugin class for bukkit )) } +} + +val shadowJar by tasks.getting(ShadowJar::class) { + dependencies { + include(project(":core")) + include(dependency("org.bstats:bstats-bukkit:1.4")) + } + relocate("org.bstats", "com.gmail.nossr50.metrics.bstat") } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 758ba6c65..ed8e3f612 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -pluginGroup="com.gmail.nossr50" -pluginVersion="2.2.0-SNAPSHOT" +pluginGroup=com.gmail.nossr50 +pluginVersion=2.2.0-SNAPSHOT diff --git a/settings.gradle.kts b/settings.gradle.kts index 5a88e8183..6e1d1b992 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,3 +8,11 @@ */ rootProject.name = "mcMMO" include("core", "bukkit", "sponge") + +pluginManagement { + repositories { + jcenter() + maven("https://repo.spongepowered.org/maven/") + gradlePluginPortal() + } +} diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts index 3667ebaba..8c31ac372 100644 --- a/sponge/build.gradle.kts +++ b/sponge/build.gradle.kts @@ -1,30 +1,30 @@ -buildscript { - repositories { - maven("https://repo.spongepowered.org/maven") - } -} +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { java - id("org.spongepowered.plugin") version "0.9.0" + id("org.spongepowered.plugin") version "0.9.0" // supplies sponge repo and plugin metadata creation tasks + id("com.github.johnrengelman.shadow") } dependencies { compile("org.spongepowered", "spongeapi", "7.1.0") // SpongeAPI + compile(project(":core")) - implementation("org.bstats", "bstats-sponge", "1.4") // Sponge bstats + compile("org.bstats", "bstats-sponge", "1.4") // Sponge bstats } description = "mcMMO for Sponge" -val compileJava by tasks.getting(JavaCompile::class) { - options.encoding = "UTF-8" -} - val jar by tasks.getting(Jar::class) { manifest { attributes(mapOf( - "Implementation-Title" to project.name, - "Implementation-Version" to project.version + "Implementation-Title" to "mcMMO", + "Implementation-Version" to rootProject.properties["pluginVersion"]!! )) } +} + +val shadowJar by tasks.getting(ShadowJar::class) { + dependencies { + include(project(":core")) + } } \ No newline at end of file diff --git a/sponge/src/main/java/com/gmail/nossr50/SpongePlugin.java b/sponge/src/main/java/com/gmail/nossr50/SpongePlugin.java index 5960aeecb..e75259805 100644 --- a/sponge/src/main/java/com/gmail/nossr50/SpongePlugin.java +++ b/sponge/src/main/java/com/gmail/nossr50/SpongePlugin.java @@ -9,7 +9,8 @@ import org.spongepowered.api.plugin.Plugin; authors = {"nossr50", "gabizou", "bloodmage"}, version = "2.2.0-SNAPSHOT", name = "mcMMO", - url = "https://www.mcmmo.org/" + url = "https://www.mcmmo.org/", + description = "mcMMO plugin for Sponge" ) public class SpongePlugin {