Skip to content

build: Update to ScreamingPluginBuilder 2.0.0 #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

25 changes: 13 additions & 12 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -20,26 +23,24 @@ 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 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*.jar
!plugin/*/build/libs/BedWars*-unshaded.jar
protocol/build/libs/BedWars*.jar
!protocol/build/libs/BedWars*-unshaded.jar
!plugin/common/**/*
28 changes: 28 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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
with:
add-job-summary-as-pr-comment: on-failure
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean checkLicenses build --stacktrace --warning-mode all
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

# Gradle
/.gradle
/build
/*/build/
/plugin/*/build/
/plugin/universal/test-environment/
/plugin/*/test-environment/
gradle-app.setting
!gradle-wrapper.jar
.gradletasknamecache
File renamed without changes.
94 changes: 0 additions & 94 deletions build.gradle

This file was deleted.

107 changes: 107 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import io.freefair.gradle.plugins.lombok.LombokPlugin
import org.screamingsandals.gradle.builder.*
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")

subprojects {
apply<JavaPlugin>()
apply<BuilderPlugin>()
apply<LombokPlugin>()

repositories {
mavenCentral()
maven("https://repo.screamingsandals.org/public/")
maven("https://repo.papermc.io/repository/maven-snapshots/")
maven("https://repo.onarandombox.com/content/groups/public")
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://repo.alessiodp.com/releases/")
}

dependencies {
"compileOnly"(rootProject.libs.jetbrains.annotations)
}

tasks.withType<Jar> {
archiveClassifier.set(System.getenv("BUILD_NUMBER") ?: "dev")
}

if (project.name != "BedWars-protocol") {
configureShadowPlugin {
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")
}
}

configureLicenser()
if (project.name != "BedWars-common") { // do not publish the common artifact, only API, protocol, platform artifacts and universal artifact
// TODO: figure out how to relocate api-utils in Javadoc and sourceJar of BedWars-API (to the package defined in SLibExtension)
val buildSources = project.name == "BedWars-API" || project.name == "BedWars-protocol"
if (buildSources) {
configureSourcesJar()
}
val buildJavadoc = !version.toString().endsWith("-SNAPSHOT") && project.name == "BedWars-API"
if (buildJavadoc) {
configureJavadocTasks()
}
setupMavenPublishing(addSourceJar=buildSources, addJavadocJar=buildJavadoc)
setupMavenRepositoriesFromProperties()
}

configureJavac(JavaVersion.VERSION_11)

// TODO: check if this is needed (and probably remove it later)
configurations.all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}

if (project.name == "BedWars-protocol") {
// Not an slib project
return@subprojects
}

apply<SLibPlugin>()

extensions.configure<SLibExtension> {
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)
}
}
}
}
11 changes: 8 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ parties-api = "3.2.6"
perworldinventory-old = "1.11.5"
perworldinventory-kt = "2.3.1"
multiverse = "4.0.0"
jetbrains-annotations = "26.0.1"

# plugins
screaming-plugin-builder = "1.0.86"
buildconfig = "3.0.2"
screaming-plugin-builder = "2.0.0-SNAPSHOT"
buildconfig = "5.5.1"
lombok = "8.11"

configurate = "4.1.2"
configurate-patched-gson = "4.1.2-sandals-patch"
Expand All @@ -36,8 +38,11 @@ perworldinventory-kt = { group = "me.ebonjaeger", name = "perworldinventory-kt",
multiverse = { group = "com.onarandombox.multiversecore", name = "Multiverse-Core", version.ref = "multiverse" }
configurate-gson = { group = "org.spongepowered", name = "configurate-gson", version.ref = "configurate-patched-gson" }
configurate-yaml = { group = "org.spongepowered", name = "configurate-yaml", version.ref = "configurate" }
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" }

[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" }
buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" }
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" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
8 changes: 5 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -203,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Loading