diff --git a/.github/workflows/build-master.yml b/.github/workflows/build-master.yml index 42d682130..60b83cab5 100644 --- a/.github/workflows/build-master.yml +++ b/.github/workflows/build-master.yml @@ -9,7 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v4 - name: Set the Build number id: calculated_build_number env: @@ -20,26 +23,19 @@ jobs: with: distribution: 'temurin' java-version: 17 - cache: 'gradle' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew + run: ./gradlew clean checkLicenses build shadowJar publish --stacktrace --warning-mode all env: NEXUS_URL_RELEASE: ${{ secrets.NEXUS_URL_RELEASE }} NEXUS_URL_SNAPSHOT: ${{ secrets.NEXUS_URL_SNAPSHOT }} NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - JAVADOC_HOST: ${{ secrets.JAVADOC_HOST }} - JAVADOC_SECRET: ${{ secrets.JAVADOC_SECRET }} - JAVADOC_USER: ${{ secrets.JAVADOC_USER }} - OPTIMIZE_FOR_CI_CD: "1" BUILD_NUMBER: ${{ steps.calculated_build_number.outputs.build_n }} - WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} - REPOSILITE_BASE_URL: ${{ secrets.REPOSILITE_BASE_URL }} - GITHUB_ACTIONS_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - GITHUB_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" - name: Upload the final artifact uses: actions/upload-artifact@v4 with: - path: plugin/universal/build/libs/BedWars*[!s].jar + path: plugin/*/build/libs/BedWars*[!s].jar diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 000000000..8d2552292 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,26 @@ +name: BedWars Test CI + +on: [push, pull_request] + +jobs: + build: + # Only run on PRs if the source branch is on a different repo. We do not need to run everything twice. + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew clean checkLicenses build shadowJar --stacktrace --warning-mode all diff --git a/.gitignore b/.gitignore index 1995cf532..a316f0fdc 100644 --- a/.gitignore +++ b/.gitignore @@ -10,9 +10,10 @@ # Gradle /.gradle +/build /*/build/ /plugin/*/build/ -/plugin/universal/test-environment/ +/plugin/*/test-environment/ gradle-app.setting !gradle-wrapper.jar .gradletasknamecache \ No newline at end of file diff --git a/api/build.gradle b/api/build.gradle.kts similarity index 100% rename from api/build.gradle rename to api/build.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 2481f4710..000000000 --- a/build.gradle +++ /dev/null @@ -1,110 +0,0 @@ -import org.screamingsandals.gradle.builder.MavenUtilities -import org.screamingsandals.gradle.builder.Utilities -import org.screamingsandals.gradle.builder.JavadocUtilities - -plugins { - alias libs.plugins.screaming.plugin.builder apply false - alias libs.plugins.screaming.plugin.slib apply false - alias libs.plugins.buildconfig apply false - alias libs.plugins.lombok apply false -} - -defaultTasks 'clean', 'build' - -subprojects { - apply plugin: 'java' - - apply plugin: 'org.screamingsandals.plugin-builder' - - apply plugin: 'io.freefair.lombok' - - def mavenPublication = null - Utilities.configureLicenser(project) - if (project.name == 'BedWars-API' && project.name == 'BedWars' && project.name == 'BedWars-protocol') { - Utilities.configureSourceJarTasks(project) - mavenPublication = MavenUtilities.setupPublishing(project) - if (!version.toString().endsWith('-SNAPSHOT') && project.name == 'BedWars-API') { - JavadocUtilities.configureJavadocTasks(project) - } - Utilities.setupMavenRepositoriesFromProperties(project) - } - - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://repo.screamingsandals.org/public/' } - maven { url 'https://repo.papermc.io/repository/maven-snapshots/' } - maven { url 'https://repo.onarandombox.com/content/groups/public' } - maven { url 'https://repo.codemc.org/repository/maven-public/' } - maven { url 'https://repo.alessiodp.com/releases/' } - } - - dependencies { - compileOnly libs.jetbrains.annotations - } - - sourceCompatibility = '11.0' - - compileJava { - options.encoding = "UTF-8" - } - - if (project.name == 'BedWars-protocol') { - return // not Slib project - } - - apply plugin: 'org.screamingsandals.plugin-slib' - - slib { - version(libs.versions.screaming.lib) - - multiModulePlatforms('BedWars-%s', 'bukkit') - multiModuleUniversalSubproject('BedWars') // custom name - // This also means we cannot create class Wrapper and package types in package org.screamingsandals.bedwars.api - multiModuleApiSubproject('BedWars-API', 'org.screamingsandals.bedwars.api') - useApiConfigurationInsteadOfImplementation(true) - - additionalContent { - module('cloud') - module('hologram') - module('placeholders') - module('sidebar') - module('healthindicator') - module('npc') - module('signs') - module('economy') - module('ai') - module('fakedeath') - - lang() - singleModule('cloud-extras') - - simpleInventories { - version(libs.versions.simple.inventories) - } - } - } - - Utilities.configureShadowPlugin(project, mavenPublication) - - configurations.all { - // Check for updates every build - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - } - - shadowJar { - relocate 'com.zaxxer', 'org.screamingsandals.bedwars.lib.HikariCP' - relocate 'org.bstats', 'org.screamingsandals.bedwars.lib.ext.bstats' - relocate 'org.spongepowered.configurate', 'org.screamingsandals.bedwars.lib.ext.configurate' - relocate 'org.yaml.snakeyaml', 'org.screamingsandals.bedwars.lib.ext.snakeyaml' - relocate 'io.leangen.geantyref', 'org.screamingsandals.bedwars.lib.ext.geantyref' - relocate 'cloud.commandframework', 'org.screamingsandals.bedwars.lib.ext.cloud' - relocate 'me.lucko.commodore', 'org.screamingsandals.bedwars.lib.ext.commodore' - - if (System.getenv('BUILD_NUMBER') != null) { - archiveClassifier.set(System.getenv('BUILD_NUMBER')) - } else { - archiveClassifier.set('dev') - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..7f1bc9078 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,113 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import io.freefair.gradle.plugins.lombok.LombokPlugin +import org.screamingsandals.gradle.builder.BuilderPlugin +import org.screamingsandals.gradle.builder.MavenUtilities +import org.screamingsandals.gradle.builder.Utilities +import org.screamingsandals.gradle.builder.JavadocUtilities +import org.screamingsandals.gradle.slib.SLibPlugin +import org.screamingsandals.gradle.slib.SLibExtension + +plugins { + alias(libs.plugins.screaming.plugin.builder) apply false + alias(libs.plugins.screaming.plugin.slib) apply false + alias(libs.plugins.lombok) apply false +} + +defaultTasks("clean", "build", "shadowJar") + +subprojects { + apply() + apply() + apply() + + var mavenPublication: MavenPublication? = null + Utilities.configureLicenser(project) + if (project.name != "BedWars-common") { + Utilities.configureSourceJarTasks(project) + mavenPublication = MavenUtilities.setupPublishing(project).publication + if (!version.toString().endsWith("-SNAPSHOT") && project.name == "BedWars-API") { + JavadocUtilities.configureJavadocTasks(project) + } + MavenUtilities.setupMavenRepositoriesFromProperties(project) + } + + repositories { + mavenCentral() + maven { url = uri("https://repo.screamingsandals.org/public/") } + maven { url = uri("https://repo.papermc.io/repository/maven-snapshots/") } + maven { url = uri("https://repo.onarandombox.com/content/groups/public") } + maven { url = uri("https://repo.codemc.org/repository/maven-public/") } + maven { url = uri("https://repo.alessiodp.com/releases/") } + } + + dependencies { + "compileOnly"(rootProject.libs.jetbrains.annotations) + } + + extensions.configure { + sourceCompatibility = JavaVersion.VERSION_11 + } + + tasks.withType { + options.compilerArgs.add("-Xlint:deprecation") + } + + if (project.name == "BedWars-protocol") { + return@subprojects + } + + apply() + + extensions.configure { + version(rootProject.libs.versions.screaming.lib) + + multiModulePlatforms("BedWars-%s", "bukkit") + multiModuleUniversalSubproject("BedWars") // custom name + // This also means we cannot create class Wrapper and package types in package org.screamingsandals.bedwars.api + multiModuleApiSubproject("BedWars-API", "org.screamingsandals.bedwars.api") + useApiConfigurationInsteadOfImplementation(true) + + additionalContent { + module("cloud") + module("hologram") + module("placeholders") + module("sidebar") + module("healthindicator") + module("npc") + module("signs") + module("economy") + module("ai") + module("fakedeath") + + lang() + singleModule("cloud-extras") + + simpleInventories { + version(rootProject.libs.versions.simple.inventories) + } + } + } + + Utilities.configureShadowPlugin(project, mavenPublication) + + configurations.all { + // Check for updates every build + resolutionStrategy.cacheChangingModulesFor(0, "seconds") + } + + tasks.withType { + relocate("com.zaxxer", "org.screamingsandals.bedwars.lib.HikariCP") + relocate("org.bstats", "org.screamingsandals.bedwars.lib.ext.bstats") + relocate("org.spongepowered.configurate", "org.screamingsandals.bedwars.lib.ext.configurate") + relocate("org.yaml.snakeyaml", "org.screamingsandals.bedwars.lib.ext.snakeyaml") + relocate("io.leangen.geantyref", "org.screamingsandals.bedwars.lib.ext.geantyref") + relocate("cloud.commandframework", "org.screamingsandals.bedwars.lib.ext.cloud") + relocate("me.lucko.commodore", "org.screamingsandals.bedwars.lib.ext.commodore") + + if (System.getenv("BUILD_NUMBER") != null) { + archiveClassifier.set(System.getenv("BUILD_NUMBER")) + } else { + archiveClassifier.set("dev") + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c311efef8..86d69f046 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,8 +16,8 @@ multiverse = "4.0.0" jetbrains-annotations = "26.0.1" # plugins -screaming-plugin-builder = "1.1.0-SNAPSHOT" -buildconfig = "3.0.2" +screaming-plugin-builder = "2.0.0-SNAPSHOT" +buildconfig = "5.5.1" lombok = "8.11" configurate = "4.1.2" @@ -43,5 +43,6 @@ jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version [plugins] screaming-plugin-builder = { id = "org.screamingsandals.plugin-builder", version.ref = "screaming-plugin-builder" } screaming-plugin-slib = { id = "org.screamingsandals.plugin-slib", version.ref = "screaming-plugin-builder" } +screaming-plugin-run = { id = "org.screamingsandals.plugin-run", version.ref = "screaming-plugin-builder" } buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" } lombok = { id = "io.freefair.lombok", version.ref = "lombok" } \ No newline at end of file diff --git a/plugin/bukkit/build.gradle b/plugin/bukkit/build.gradle deleted file mode 100644 index 1e12b0939..000000000 --- a/plugin/bukkit/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -dependencies { - /* PROVIDED */ - compileOnly libs.paper - compileOnly(libs.perworldinventory.kt) { - exclude group: '*', module: '*' - } - compileOnly(libs.perworldinventory.old) { - exclude group: '*', module: '*' - } - - /* SHADED */ - implementation libs.bstats - implementation(libs.commodore) { // brigadier support for Bukkit/Spigot - exclude group: 'com.mojang', module: 'brigadier' - } -} - -slib { - disableCompilerTricks = true // we have paper in dependencies -} -compileJava.outputs.upToDateWhen {false} \ No newline at end of file diff --git a/plugin/bukkit/build.gradle.kts b/plugin/bukkit/build.gradle.kts new file mode 100644 index 000000000..0778d9021 --- /dev/null +++ b/plugin/bukkit/build.gradle.kts @@ -0,0 +1,55 @@ +plugins { + alias(libs.plugins.screaming.plugin.run) +} + +dependencies { + /* PROVIDED */ + compileOnly(libs.paper) + compileOnly(libs.perworldinventory.kt) { + exclude(group="*", module="*") + } + compileOnly(libs.perworldinventory.old) { + exclude(group="*", module="*") + } + + /* SHADED */ + implementation(libs.bstats) + implementation(libs.commodore) { // brigadier support for Bukkit/Spigot + exclude(group="com.mojang", module="brigadier") + } +} + +runTestServer { + pluginJar(tasks.shadowJar.get().archiveFile) + + versions( + org.screamingsandals.gradle.run.config.Platform.PAPER, + listOf( + "1.21.4", + "1.21.3", + "1.21.1", + "1.20.6", + "1.20.4", + "1.20.2", + "1.20.1", + "1.19.4", + "1.19.3", + "1.18.2", + "1.17.1", + "1.16.5", + "1.15.2", + "1.14.4", + "1.13.2", + "1.12.2", + "1.11.2", + "1.10.2", + "1.9.4", + "1.8.8", + ) + ) { + jvmArgs("-Dio.papermc.paper.suppress.sout.nags=true", "-DPaper.IgnoreJavaVersion=true") + serverProperties { + onlineMode(false) + } + } +} \ No newline at end of file diff --git a/plugin/common/build.gradle b/plugin/common/build.gradle deleted file mode 100644 index 60bf48842..000000000 --- a/plugin/common/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: "com.github.gmazzo.buildconfig" - -dependencies { - /* PROVIDED */ - compileOnly libs.multiverse - compileOnly libs.parties.api - - /* SHADED */ - implementation 'org.screamingsandals.language.bedwars:BedWarsLanguage:' + (project.version =~ /^\d+.\d+/).findAll()?.first() + '-SNAPSHOT' - implementation libs.hikari - - api(libs.configurate.gson) { - exclude(group: '*', module: '*') - } - api libs.configurate.yaml - api project(':BedWars-protocol') -} - -buildConfig { - className('VersionInfo') - packageName('org.screamingsandals.bedwars') - - buildConfigField('String', 'NAME', "\"${project.name}\"") - buildConfigField('String', 'VERSION', "\"${project.version}\"") - buildConfigField('String', 'BUILD_NUMBER', "\"${System.getenv('BUILD_NUMBER') ?: "custom"}\"") -} - -compileJava.outputs.upToDateWhen {false} \ No newline at end of file diff --git a/plugin/common/build.gradle.kts b/plugin/common/build.gradle.kts new file mode 100644 index 000000000..2a26a8c77 --- /dev/null +++ b/plugin/common/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + alias(libs.plugins.buildconfig) +} + +dependencies { + /* PROVIDED */ + compileOnly(libs.multiverse) + compileOnly(libs.parties.api) + + /* SHADED */ + implementation("org.screamingsandals.language.bedwars:BedWarsLanguage:${Regex("^\\d+\\.\\d+").find(project.version.toString())?.value}-SNAPSHOT") + implementation(libs.hikari) + + api(libs.configurate.gson) { + exclude(group="*", module="*") + } + api(libs.configurate.yaml) + api(project(":BedWars-protocol")) +} + +buildConfig { + className("VersionInfo") + packageName("org.screamingsandals.bedwars") + + buildConfigField("String", "NAME", "\"${project.name}\"") + buildConfigField("String", "VERSION", "\"${project.version}\"") + buildConfigField("String", "BUILD_NUMBER", "\"${System.getenv("BUILD_NUMBER") ?: "custom"}\"") +} \ No newline at end of file diff --git a/plugin/universal/build.gradle b/plugin/universal/build.gradle deleted file mode 100644 index 0652e19f1..000000000 --- a/plugin/universal/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -//prepareTestTask() -// .versions('1.21.3', '1.21.1', '1.20.6', '1.20.4', '1.20.2', '1.20.1', '1.19.4', '1.19.3', '1.18.2', '1.17.1', '1.16.5', '1.15.2', '1.14.4', '1.13.2', '1.12.2', '1.11.2', '1.10.2', '1.9.4', '1.8.8') -// .setSubdirectory('paper-master') -// .jvmArgs('-Dio.papermc.paper.suppress.sout.nags=true', '-DPaper.IgnoreJavaVersion=true') // suppress System.out.println nag -// .onlineMode(false) -// .pluginJar(shadowJar.archiveFile.get().asFile.toPath()) -// .build() - -jar { - manifest { - attributes([ - 'paperweight-mappings-namespace': 'mojang' - ]) - } -} - -//discord { -// title = "BedWars Master #${System.getenv('BUILD_NUMBER') ?: "custom"}" -// content = 'New build of BedWars is now available!' -// url = System.getenv('WEBHOOK_URL') -// allowedClassifiersAndExtensions = ['.jar'] -// -// if (System.getenv('GITHUB_ACTIONS_URL')) { -// buildInformationUrl = System.getenv('GITHUB_ACTIONS_URL') -// } -// /*if (System.getenv('GITHUB_COMMIT_MESSAGE')) { -// content = "New build of BedWars is now available!\n\n```\n${System.getenv('GITHUB_COMMIT_MESSAGE')}\n```" -// }*/ -// -// registerTask(project) -//} \ No newline at end of file diff --git a/protocol/build.gradle b/protocol/build.gradle.kts similarity index 100% rename from protocol/build.gradle rename to protocol/build.gradle.kts diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 630fd4ade..000000000 --- a/settings.gradle +++ /dev/null @@ -1,23 +0,0 @@ -pluginManagement { - repositories { - mavenCentral() - mavenLocal() - gradlePluginPortal() - maven { - url = "https://repo.screamingsandals.org/public/" - } - - } -} - -rootProject.name = 'BedWars-parent' -include(':BedWars-API') -project(':BedWars-API').projectDir = file('api') -include(':BedWars') -project(':BedWars').projectDir = file('plugin/universal') -include(':BedWars-protocol') -project(':BedWars-protocol').projectDir = file('protocol') -include(':BedWars-common') -project(':BedWars-common').projectDir = file('plugin/common') -include(':BedWars-bukkit') -project(':BedWars-bukkit').projectDir = file('plugin/bukkit') diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..8131d688b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,22 @@ +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + maven { + url = uri("https://repo.screamingsandals.org/public/") + } + + } +} + +rootProject.name = "BedWars-parent" +include(":BedWars-API") +project(":BedWars-API").projectDir = file("api") +include(":BedWars") +project(":BedWars").projectDir = file("plugin/universal") +include(":BedWars-protocol") +project(":BedWars-protocol").projectDir = file("protocol") +include(":BedWars-common") +project(":BedWars-common").projectDir = file("plugin/common") +include(":BedWars-bukkit") +project(":BedWars-bukkit").projectDir = file("plugin/bukkit")