diff --git a/build.gradle.kts b/build.gradle.kts index 9f2909bf7..f30e0b180 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,90 @@ +import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension +import xyz.jpenilla.runpaper.task.RunServer + plugins { id("io.papermc.paperweight.userdev") version "1.5.10" apply false id("com.github.johnrengelman.shadow") version "8.1.1" apply false id("xyz.jpenilla.run-paper") version "2.2.2" apply false } -allprojects { - apply(from = "${rootProject.projectDir}/scripts/gradle/common.gradle") +project.extensions.configure { + buildScan { + if (System.getenv("CI") != null) { + tag("CI") + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + } + } } +allprojects { + pluginManager.withPlugin("java-library") { + configure { + toolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } + withSourcesJar() + withJavadocJar() + } + + tasks.withType { + options.encoding = "UTF-8" + options.release = 17 + } + + tasks.withType { + filteringCharset = "UTF-8" + } + } + + pluginManager.withPlugin("maven-publish") { + configure { + val githubActor = System.getenv("GITHUB_ACTOR") + val githubToken = System.getenv("GITHUB_TOKEN") + + repositories { + if (githubActor != null && githubToken != null) { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/CivMC/Civ") + credentials { + username = githubActor + password = githubToken + } + } + } + } + } + } + + tasks.withType { + minecraftVersion("1.18") + } + + pluginManager.withPlugin("io.papermc.paperweight.userdev") { + tasks.withType { + filesMatching("plugin.yml") { + expand(project.properties) + } + } + + tasks { + named("build") { + dependsOn("reobfJar") + } + } + } + + pluginManager.withPlugin("com.github.johnrengelman.shadow") { + tasks { + named("build") { + dependsOn("shadowJar") + } + } + } +} + +// TODO: We probably don't want to apply this to every subproject subprojects { apply(plugin = "java-library") apply(plugin = "maven-publish") diff --git a/plugins/civspy-paper/build.gradle.kts b/plugins/civspy-paper/build.gradle.kts index cc9f14695..beff96ead 100644 --- a/plugins/civspy-paper/build.gradle.kts +++ b/plugins/civspy-paper/build.gradle.kts @@ -7,8 +7,6 @@ plugins { group = "net.civmc.civspy" version = "2.0.1" -apply(from = "${rootProject.projectDir}/scripts/gradle/paper.gradle") - repositories { maven("https://papermc.io/repo/repository/maven-public/") } diff --git a/scripts/gradle/common.gradle b/scripts/gradle/common.gradle deleted file mode 100644 index 14b0b01d1..000000000 --- a/scripts/gradle/common.gradle +++ /dev/null @@ -1,68 +0,0 @@ -pluginManager.withPlugin("java-library") { - java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) - } - withSourcesJar() - withJavadocJar() - } - - tasks.withType(JavaCompile).configureEach { - options.encoding = "UTF-8" - options.release = 17 - } - - tasks.withType(ProcessResources).configureEach { - filteringCharset = "UTF-8" - } - - // TODO -// tasks.withType(Test).configureEach { -// useJUnitPlatform() -// testLogging { -// events(*TestLogEvent.values()) -// exceptionFormat = TestExceptionFormat.FULL -// showCauses = true -// showExceptions = true -// showStackTraces = true -// } -// } -} - -pluginManager.withPlugin("maven-publish") { - def githubActor = System.getenv("GITHUB_ACTOR") - def githubToken = System.getenv("GITHUB_TOKEN") - - publishing { - repositories { - if (githubActor && githubToken) { - maven { - name = "GitHubPackages" - url = "https://maven.pkg.github.com/CivMC/Civ" - credentials { - username = githubActor - password = githubToken - } - } - } - } - - publications { - mavenJava(MavenPublication) { - from components.java - } - } - } -} - -pluginManager.withPlugin("com.gradle.enterprise") { - gradleEnterprise { - buildScan { - if (System.getenv("CI")) { - it.tag("CI") - it.termsOfServiceUrl = "https://gradle.com/terms-of-service" - it.termsOfServiceAgree = "yes" - } - } - } -} \ No newline at end of file diff --git a/scripts/gradle/paper.gradle b/scripts/gradle/paper.gradle deleted file mode 100644 index fa933f50d..000000000 --- a/scripts/gradle/paper.gradle +++ /dev/null @@ -1,22 +0,0 @@ - -pluginManager.withPlugin("xyz.jpenilla.run-paper") { - tasks { - runServer { - minecraftVersion("1.18") - } - } -} - -pluginManager.withPlugin("io.papermc.paperweight.userdev") { - tasks { - processResources { - filesMatching("plugin.yml") { - expand project.properties - } - } - } - - build { - dependsOn(reobfJar) - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index ff1c14451..b3a6dd629 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,9 @@ rootProject.name = "Civ" +plugins { + id("com.gradle.enterprise") version "3.16.2" +} + include(":plugins:civspy-api") include(":plugins:civspy-paper") include(":plugins:civspy-bungee")