diff --git a/.gitignore b/.gitignore index b613fc6fd..da42bba5b 100644 --- a/.gitignore +++ b/.gitignore @@ -67,9 +67,9 @@ hs_err_pid* # When using Gradle or Maven with auto-import, you should exclude module files, # since they will be recreated, and may cause churn. Uncomment if using # auto-import. -# .idea/modules.xml -# .idea/*.iml -# .idea/modules + .idea/modules.xml + .idea/*.iml + .idea/modules # CMake cmake-build-*/ diff --git a/build.gradle.kts b/build.gradle.kts index 77ba789c7..aad894adc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,21 +1,37 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + buildscript { - dependencies { - classpath("com.github.jengelman.gradle.plugins:shadow:4.0.4") + repositories { + jcenter() } } +// Extras +var core by extra { project("core") } +// Bukkit/Spigot plugins +val bukkit by extra { project("bukkit") } +val bukkit_18 by extra { bukkit.project("1_8_8") } +val bukkit_112 by extra { bukkit.project("1_12") } +val bukkit_113 by extra { bukkit.project("1_13") } + +// Sponge plugins +val sponge by extra { project("sponge") } +val sponge_7 by extra { sponge.project("api7") } + + group = properties["pluginGroup"]!! version = properties["pluginVersion"]!! plugins { `java-library` java + id("com.github.johnrengelman.shadow") version "4.0.4" } // Set up defaults for all projects, maven repositories, java compatibility level and compiling encoding allprojects { - apply(plugin="java-library") + apply(plugin="com.github.johnrengelman.shadow") repositories { mavenCentral() @@ -24,13 +40,35 @@ allprojects { // bStats maven("https://repo.codemc.org/repository/maven-public") } + + dependencies { + compile("org.apache.tomcat", "tomcat-jdbc", "7.0.52") // tomcat JDBC + compile("org.apache.tomcat", "tomcat-juli", "7.0.52") // tomcat juli + testCompile("junit", "junit", "4.12") + } java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } - tasks.getting(JavaCompile::class) { options.encoding = "UTF-8" } - +} + +val jar by tasks.getting(Jar::class) { + manifest { + attributes(mapOf( + "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") } diff --git a/bukkit/1_12/build.gradle.kts b/bukkit/1_12/build.gradle.kts new file mode 100644 index 000000000..0fcf65839 --- /dev/null +++ b/bukkit/1_12/build.gradle.kts @@ -0,0 +1,10 @@ + +plugins { + java +} + +dependencies { + implementation("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT") // Spigot API + implementation("com.sk89q.worldguard", "worldguard-legacy", "6.2") // WorldGuard + +} diff --git a/bukkit/1_13/build.gradle.kts b/bukkit/1_13/build.gradle.kts new file mode 100644 index 000000000..2fd5dd30d --- /dev/null +++ b/bukkit/1_13/build.gradle.kts @@ -0,0 +1,10 @@ + +plugins { + `java-library` +} + +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 +} diff --git a/bukkit/1_8_8/build.gradle.kts b/bukkit/1_8_8/build.gradle.kts new file mode 100644 index 000000000..210fd08fe --- /dev/null +++ b/bukkit/1_8_8/build.gradle.kts @@ -0,0 +1,10 @@ + +plugins { + java +} + +dependencies { + implementation("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT") // Spigot API + implementation("com.sk89q.worldguard:worldguard-legacy:6.1.2") // Old worldguard + +} diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 300a9d603..2a781f905 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -1,59 +1,34 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - buildscript { + repositories { jcenter() } + dependencies { classpath("com.github.jengelman.gradle.plugins:shadow:4.0.4") } +} +val bukkit: Project by rootProject.extra +val core: Project by rootProject.extra +// This configures the bukkit/spigot ecosystem repositories, so they all share the same repos +allprojects { repositories { - jcenter() + // Spigot & Bukkit + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + maven("https://oss.sonatype.org/content/repositories/snapshots") + mavenLocal() // For nms variants } + dependencies { - classpath("com.github.jengelman.gradle.plugins:shadow:4.0.4") + compile(core) // includes junit for tests + compile("org.bstats", "bstats-bukkit", "1.4") // Bukkit bstats } } -repositories { - - // Spigot & Bukkit - maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") - maven("https://oss.sonatype.org/content/repositories/snapshots") - - mavenLocal() // For nms variants +subprojects { + dependencies { + // Provide the base bukkit plugin dependency for plugin classloading. + // All "versioned" implementations will be properly classloaded by the bukkit parent + (compile(bukkit) as ModuleDependency).apply { exclude("org.spigotmc") } + } } 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 - - 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 "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/core/build.gradle.kts b/core/build.gradle.kts index 74f816191..811984bae 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -2,14 +2,3 @@ plugins { java } -dependencies { - implementation("junit", "junit", "4.12") -} -val jar by tasks.getting(Jar::class) { - manifest { - attributes(mapOf( - "Implementation-Title" to project.name, - "Implementation-Version" to project.version - )) - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 6e1d1b992..bd035c960 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,7 +7,20 @@ * in the user guide at https://docs.gradle.org/4.9/userguide/multi_project_builds.html */ rootProject.name = "mcMMO" -include("core", "bukkit", "sponge") +include( + // Core abstraction layer of mcMMO + "core", + + // Bukkit/Spigot versions, core bukkit has plugin class + "bukkit", + "bukkit:1_13", + "bukkit:1_12", + "bukkit:1_8_8", + + // Sponge Projects - SpongeAPI follows semver, so API versions can change + "sponge", // Generic plugin class contains references to load specific listeners and registrations between APIs. + "sponge:api7" // API 7 is special for MC 1.12.2 +) pluginManagement { repositories { diff --git a/sponge/api7/build.gradle.kts b/sponge/api7/build.gradle.kts new file mode 100644 index 000000000..f8263c1fd --- /dev/null +++ b/sponge/api7/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + java + // Apply the spongegradle plugin to generate the metadata file + id("org.spongepowered.plugin") version "0.9.0" // supplies sponge repo and plugin metadata creation tasks +} + +dependencies { + compile("org.spongepowered", "spongeapi", "7.1.0") // SpongeAPI + compile("org.bstats", "bstats-sponge", "1.4") // Sponge bstats +} + +description = "mcMMO for Sponge" diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts index 8c31ac372..d1e983435 100644 --- a/sponge/build.gradle.kts +++ b/sponge/build.gradle.kts @@ -1,30 +1,32 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - plugins { java - 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")) - compile("org.bstats", "bstats-sponge", "1.4") // Sponge bstats -} +val core: Project by rootProject.extra +val sponge: Project by rootProject.extra description = "mcMMO for Sponge" -val jar by tasks.getting(Jar::class) { - manifest { - attributes(mapOf( - "Implementation-Title" to "mcMMO", - "Implementation-Version" to rootProject.properties["pluginVersion"]!! - )) +repositories { + // sponge + maven("https://repo.spongepowered.org/maven") +} + +dependencies { + implementation(group="org.spongepowered", name="spongeapi", version="7.1.0") // Base version +} + +allprojects { + dependencies { + compile(core) } } -val shadowJar by tasks.getting(ShadowJar::class) { +subprojects { dependencies { - include(project(":core")) + (compile(sponge) as ModuleDependency).apply { + exclude("org.spongepowered") + } } -} \ No newline at end of file +} +