From 55792ee067bd5fb136ac5578642e89305663b47b Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 25 Feb 2026 13:23:41 -0400 Subject: [PATCH 1/3] Add Nexus deploy workflow and Maven publishing Add a GitHub Actions workflow to deploy artifacts to Negative Games Nexus for release and snapshot branches. The workflow sets up JDK 21 and Gradle, injects Nexus credentials into ~/.gradle/gradle.properties from secrets, adjusts module apiVersion for release/snapshot branches, and runs ./gradlew publish with an isRelease flag. Update root build.gradle.kts to apply maven-publish and configure a nexus repository that selects snapshots or releases based on the isRelease property and reads credentials from gradle.properties. Add maven-publish and shadow publishing configuration to common and paper modules: set module ids, domain, apiVersion, Java 21 toolchain, disable the plain jar, configure shadowJar as the published artifact, and include POM metadata (license, developer, url). --- .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++++++++++++ build.gradle.kts | 25 +++++++++++++++ common/build.gradle.kts | 56 +++++++++++++++++++++++++++++++++ paper/build.gradle.kts | 56 +++++++++++++++++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..0212e8b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy to Negative Games Nexus (Gradle) + +on: + push: + branches: + - release + - snapshot + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Configure Gradle / Nexus credentials + run: | + mkdir -p ~/.gradle + cat << 'EOF' > ~/.gradle/gradle.properties + nexusUsername=${{ secrets.NEXUS_USERNAME }} + nexusPassword=${{ secrets.NEXUS_PASSWORD }} + nexusSnapshotsUrl=https://repo.negative.games/repository/maven-snapshots + nexusReleasesUrl=https://repo.negative.games/repository/maven-releases + EOF + + # Modify version for release branch (remove -SNAPSHOT) + - name: Modify version for release + if: github.ref == 'refs/heads/release' + run: | + find . -name "build.gradle" -type f -exec sed -i "s/\(def apiVersion = '[^']*\)-SNAPSHOT'/\1'/" {} + + + # Modify version for snapshot branch (add -SNAPSHOT if not present) + - name: Modify version for snapshot + if: github.ref == 'refs/heads/snapshot' + run: | + find . -name "build.gradle" -type f -exec sed -i "/-SNAPSHOT'/! s/\(def apiVersion = '[^']*\)'/\1-SNAPSHOT'/" {} + + + # Make gradlew executable + - name: Make gradlew executable + run: chmod +x ./gradlew + + # Deploy to RELEASES on release branch + - name: Build and deploy release + if: github.ref == 'refs/heads/release' + run: ./gradlew clean publish -PisRelease=true + + # Deploy to SNAPSHOTS on snapshot branch + - name: Build and deploy snapshot + if: github.ref == 'refs/heads/snapshot' + run: ./gradlew clean publish -PisRelease=false \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 76f114a..1836acd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { id("java") + id("maven-publish") } subprojects { @@ -23,3 +24,27 @@ subprojects { tasks.withType() { enabled = false } + + +subprojects { + plugins.withId("maven-publish") { + configure { + repositories { + maven { + name = "nexus" + + val snapshotsUrl = findProperty("nexusSnapshotsUrl") as String? ?: "https://repo.negative.games/repository/maven-snapshots" + val releasesUrl = findProperty("nexusReleasesUrl") as String? ?: "https://repo.negative.games/repository/maven-releases" + + val isRelease = (findProperty("isRelease") == "true") + url = uri(if (isRelease) releasesUrl else snapshotsUrl) + + credentials { + username = findProperty("nexusUsername") as String? + password = findProperty("nexusPassword") as String? + } + } + } + } + } +} \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 1ed51f2..36d3ef8 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,7 +1,13 @@ plugins { id("java") + id("maven-publish") + id("com.gradleup.shadow") version("9.2.2") } +var id = "plugin-engine-common" +var domain = "games.negative.engine" +var apiVersion = "1.0.0" + repositories { mavenCentral() } @@ -33,4 +39,54 @@ dependencies { // Lombok compileOnly("org.projectlombok:lombok:1.18.32") annotationProcessor("org.projectlombok:lombok:1.18.32") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + +tasks.jar { + enabled = false +} + +tasks.shadowJar { + archiveBaseName.set(id) + archiveVersion.set(apiVersion) + archiveClassifier.set("") +} + +publishing { + publications { + create("mavenJava") { + artifact(tasks.shadowJar) { + builtBy(tasks.shadowJar) + } + + groupId = domain + artifactId = id + version = apiVersion + + pom { + name.set(id) + description.set(project.description) + url.set("https://github.com/negative-games/plugin-engine") + + licenses { + license { + name.set("The MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("ericlmao") + name.set("Eric") + } + } + } + } + } } \ No newline at end of file diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index fcdf873..49a3616 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -1,7 +1,13 @@ plugins { id("java") + id("maven-publish") + id("com.gradleup.shadow") version("9.2.2") } +var id = "plugin-engine-paper" +var domain = "games.negative.engine" +var apiVersion = "1.0.0" + repositories { mavenCentral() } @@ -33,4 +39,54 @@ dependencies { // Lombok compileOnly("org.projectlombok:lombok:1.18.32") annotationProcessor("org.projectlombok:lombok:1.18.32") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + +tasks.jar { + enabled = false +} + +tasks.shadowJar { + archiveBaseName.set(id) + archiveVersion.set(apiVersion) + archiveClassifier.set("") +} + +publishing { + publications { + create("mavenJava") { + artifact(tasks.shadowJar) { + builtBy(tasks.shadowJar) + } + + groupId = domain + artifactId = id + version = apiVersion + + pom { + name.set(id) + description.set(project.description) + url.set("https://github.com/negative-games/plugin-engine") + + licenses { + license { + name.set("The MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("ericlmao") + name.set("Eric") + } + } + } + } + } } \ No newline at end of file From 2999e9bd3fb4182067b80e3c332be7751e401b21 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 25 Feb 2026 13:45:04 -0400 Subject: [PATCH 2/3] Update deploy workflow for Kotlin DSL builds Switch sed targets from build.gradle to build.gradle.kts and update the regexes to match Kotlin DSL variable declarations (var apiVersion = "...") for both release and snapshot branches. This ensures version bump/removal works for build.gradle.kts files. Also add a missing newline at end of file. --- .github/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0212e8b..2f26a94 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,13 +37,13 @@ jobs: - name: Modify version for release if: github.ref == 'refs/heads/release' run: | - find . -name "build.gradle" -type f -exec sed -i "s/\(def apiVersion = '[^']*\)-SNAPSHOT'/\1'/" {} + + find . -name "build.gradle.kts" -type f -exec sed -i "s/\\(var apiVersion = \\\"[^\\\"]*\\)-SNAPSHOT\\\"/\\1\\\"/" {} + # Modify version for snapshot branch (add -SNAPSHOT if not present) - name: Modify version for snapshot if: github.ref == 'refs/heads/snapshot' run: | - find . -name "build.gradle" -type f -exec sed -i "/-SNAPSHOT'/! s/\(def apiVersion = '[^']*\)'/\1-SNAPSHOT'/" {} + + find . -name "build.gradle.kts" -type f -exec sed -i "/var apiVersion = \\\".*-SNAPSHOT\\\"/! s/\\(var apiVersion = \\\"[^\\\"]*\\)\\\"/\\1-SNAPSHOT\\\"/" {} + # Make gradlew executable - name: Make gradlew executable @@ -57,4 +57,4 @@ jobs: # Deploy to SNAPSHOTS on snapshot branch - name: Build and deploy snapshot if: github.ref == 'refs/heads/snapshot' - run: ./gradlew clean publish -PisRelease=false \ No newline at end of file + run: ./gradlew clean publish -PisRelease=false From e0e106177228d8b835018a71e70bd33ab4fa1c3e Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 25 Feb 2026 13:48:46 -0400 Subject: [PATCH 3/3] Remove disabling of tasks.jar Delete the tasks.jar { enabled = false } block from common/build.gradle.kts so the default jar task is no longer disabled. This restores normal jar packaging behavior while keeping the shadowJar configuration (archiveBaseName and archiveVersion) intact. --- common/build.gradle.kts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 36d3ef8..5435a1f 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -47,10 +47,6 @@ java { } } -tasks.jar { - enabled = false -} - tasks.shadowJar { archiveBaseName.set(id) archiveVersion.set(apiVersion)