Skip to content

Commit 0bca75c

Browse files
authored
Update mc/spigot/gradle/kotlin/java and fix lost name tags (#28)
1 parent 73a34f1 commit 0bca75c

21 files changed

+188
-138
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.{kt,kts}]
10+
ktlint_code_style = intellij_idea
11+
12+
[*{.yml,yaml}]
13+
indent_style = space
14+
indent_size = 2

.github/workflows/build-workflow.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,27 @@ on:
99
jobs:
1010
build:
1111
name: Gradle Build
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313
outputs:
1414
version: ${{ steps.version.outputs.version }}
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 0
19-
- uses: gradle/gradle-build-action@v2
19+
- name: Setup Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: 21
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@v4
2026
- name: Gradle Build
21-
run: ./gradlew build
27+
run: ./gradlew build shadowJar
2228
- name: Get Version
2329
id: version
2430
run: echo "version=$(./gradlew --console plain --quiet currentVersion -Prelease.quiet)" >> $GITHUB_OUTPUT
2531
- name: Upload build
26-
uses: actions/upload-artifact@v3
32+
uses: actions/upload-artifact@v4
2733
with:
2834
name: build
2935
path: build/libs/*.jar
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create Release
1+
name: Create Version
22

33
on:
44
workflow_dispatch:
@@ -17,22 +17,26 @@ on:
1717
jobs:
1818
release:
1919
name: Gradle Release
20-
runs-on: ubuntu-22.04
20+
runs-on: ubuntu-24.04
2121
outputs:
2222
version: ${{ steps.version.outputs.version }}
2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525
with:
26-
token: "${{ secrets.PAT }}"
26+
ssh-key: "${{ secrets.COMMIT_KEY }}"
2727
fetch-depth: 0
28-
- uses: gradle/gradle-build-action@v2
28+
- uses: webfactory/ssh-agent@v0.9.0
29+
with:
30+
ssh-private-key: ${{ secrets.COMMIT_KEY }}
31+
- name: Setup Java
32+
uses: actions/setup-java@v4
33+
with:
34+
distribution: 'temurin'
35+
java-version: 21
36+
- uses: gradle/actions/setup-gradle@v4
2937
- name: Gradle Release
3038
if: ${{ inputs.versionIncrementer == 'default' }}
31-
env:
32-
DEPLOY_KEY: ${{ secrets.COMMIT_KEY }}
3339
run: ./gradlew release
3440
- name: Gradle Release w/ Increment Override
3541
if: ${{ inputs.versionIncrementer != 'default' }}
36-
env:
37-
DEPLOY_KEY: ${{ secrets.COMMIT_KEY }}
3842
run: ./gradlew release -Prelease.versionIncrementer=${{ inputs.versionIncrementer }}

.github/workflows/publish-workflow.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@ jobs:
1111
release:
1212
needs: build
1313
name: Create Release
14-
runs-on: ubuntu-22.04
14+
runs-on: ubuntu-24.04
1515
steps:
16-
- uses: actions/checkout@v3
17-
with:
18-
fetch-depth: 0
19-
- uses: gradle/gradle-build-action@v2
2016
- name: Download build
21-
uses: actions/download-artifact@v3
17+
uses: actions/download-artifact@v4
2218
with:
2319
name: build
2420
path: build
2521
- name: Release
26-
uses: docker://antonyurchenko/git-release:v5
22+
uses: docker://antonyurchenko/git-release:v6
2723
env:
2824
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2925
RELEASE_NAME: ${{ needs.build.outputs.version }}
@@ -32,5 +28,4 @@ jobs:
3228
UNRELEASED_TAG: latest-snapshot
3329
ALLOW_EMPTY_CHANGELOG: ${{ github.ref_type == 'branch' && 'true' || 'false' }}
3430
with:
35-
args: |
36-
build/*.jar
31+
args: build/*.jar

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Changed
5+
- MC 1.21, Kotlin 2.1, Gradle 8.12 (@tajobe)
6+
7+
### Fixed
8+
- Prevent name healthbar from overwriting name tags (@tajobe)
49

510
## [0.3.1] - 2023-03-08
611
### Changed

build.gradle.kts

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,78 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
21
import org.yaml.snakeyaml.DumperOptions
32
import org.yaml.snakeyaml.Yaml
43
import pl.allegro.tech.build.axion.release.domain.hooks.HookContext
54
import java.time.OffsetDateTime
65
import java.time.ZoneOffset
76
import java.time.format.DateTimeFormatter
87

9-
buildscript {
10-
repositories {
11-
mavenCentral()
12-
}
13-
dependencies {
14-
classpath("org.yaml:snakeyaml:2.0")
15-
}
16-
}
17-
188
plugins {
19-
kotlin("jvm")
20-
id("com.github.johnrengelman.shadow") version "8.0.0"
21-
id("pl.allegro.tech.build.axion-release") version "1.14.4"
22-
id("org.jlleitschuh.gradle.ktlint") version "11.2.0"
9+
alias(libs.plugins.axionRelease)
10+
alias(libs.plugins.kotlin)
11+
alias(libs.plugins.ktlint)
12+
alias(libs.plugins.shadow)
2313
}
2414

25-
group = "org.simplemc"
26-
version = scmVersion.version
27-
28-
val mcApiVersion: String by project
29-
val repoRef: String by project
30-
3115
scmVersion {
3216
versionIncrementer("incrementMinorIfNotOnRelease", mapOf("releaseBranchPattern" to "release/.+"))
17+
unshallowRepoOnCI.set(true)
3318

3419
hooks {
20+
// Automate moving `[Unreleased]` changelog entries into `[<version>]` on release
3521
// FIXME - workaround for Kotlin DSL issue https://github.com/allegro/axion-release-plugin/issues/500
22+
val changelogPattern =
23+
"\\[Unreleased\\]([\\s\\S]+?)\\n" +
24+
"(?:^\\[Unreleased\\]: https:\\/\\/github\\.com\\/(\\S+\\/\\S+)\\/compare\\/[^\\n]*\$([\\s\\S]*))?\\z"
3625
pre(
3726
"fileUpdate",
3827
mapOf(
3928
"file" to "CHANGELOG.md",
40-
"pattern" to KotlinClosure2<String, HookContext, String>({ v, _ ->
41-
"\\[Unreleased\\]([\\s\\S]+?)\\n(?:^\\[Unreleased\\]: https:\\/\\/github\\.com\\/$repoRef\\/compare\\/[^\\n]*\$([\\s\\S]*))?\\z"
42-
}),
43-
"replacement" to KotlinClosure2<String, HookContext, String>({ v, c ->
29+
"pattern" to KotlinClosure2<String, HookContext, String>({ _, _ -> changelogPattern }),
30+
"replacement" to KotlinClosure2<String, HookContext, String>({ version, context ->
31+
// github "diff" for previous version
32+
val previousVersionDiffLink =
33+
when (context.previousVersion == version) {
34+
true -> "releases/tag/v$version" // no previous, just link to the version
35+
false -> "compare/v${context.previousVersion}...v$version"
36+
}
4437
"""
4538
\[Unreleased\]
4639
47-
## \[$v\] - ${currentDateString()}$1
48-
\[Unreleased\]: https:\/\/github\.com\/$repoRef\/compare\/v$v...HEAD
49-
\[$v\]: https:\/\/github\.com\/$repoRef\/${if (c.previousVersion == v) "releases/tag/v$v" else "compare/v${c.previousVersion}...v$v"}${'$'}2
40+
## \[$version\] - $currentDateString$1
41+
\[Unreleased\]: https:\/\/github\.com\/$2\/compare\/v$version...HEAD
42+
\[$version\]: https:\/\/github\.com\/$2\/$previousVersionDiffLink$3
5043
""".trimIndent()
51-
})
52-
)
44+
}),
45+
),
5346
)
5447

5548
pre("commit")
5649
}
5750
}
5851

59-
fun currentDateString() = OffsetDateTime.now(ZoneOffset.UTC).toLocalDate().format(DateTimeFormatter.ISO_DATE)
52+
group = "org.simplemc"
53+
version = scmVersion.version
6054

61-
java {
62-
toolchain {
63-
languageVersion.set(JavaLanguageVersion.of(17))
64-
}
65-
}
55+
val currentDateString: String
56+
get() = OffsetDateTime.now(ZoneOffset.UTC).toLocalDate().format(DateTimeFormatter.ISO_DATE)
6657

67-
repositories {
68-
mavenCentral()
69-
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
70-
maven("https://oss.sonatype.org/content/repositories/snapshots")
58+
kotlin {
59+
jvmToolchain(21)
7160
}
7261

7362
dependencies {
74-
implementation(kotlin("stdlib-jdk8"))
75-
compileOnly(group = "org.spigotmc", name = "spigot-api", version = "$mcApiVersion+")
63+
compileOnly(libs.spigot)
7664
}
7765

7866
tasks {
7967
wrapper {
80-
gradleVersion = "8.0.1"
8168
distributionType = Wrapper.DistributionType.ALL
8269
}
8370

8471
processResources {
8572
val placeholders = mapOf(
8673
"version" to version,
87-
"apiVersion" to mcApiVersion,
88-
"kotlinVersion" to project.properties["kotlinVersion"]
74+
"apiVersion" to libs.versions.mcApi.get(),
75+
"kotlinVersion" to libs.versions.kotlin.get(),
8976
)
9077

9178
filesMatching("plugin.yml") {
@@ -117,15 +104,9 @@ tasks {
117104
archiveClassifier.set("offline")
118105
exclude("plugin.yml")
119106
rename("offline-plugin.yml", "plugin.yml")
120-
}
121-
122-
// avoid classpath conflicts/pollution via relocation
123-
val configureShadowRelocation by registering(ConfigureShadowRelocation::class) {
124-
target = shadowJar.get()
125-
prefix = "${project.group}.${project.name.lowercase()}.libraries"
126-
}
127107

128-
build {
129-
dependsOn(shadowJar).dependsOn(configureShadowRelocation)
108+
// avoid classpath conflicts/pollution via relocation
109+
isEnableRelocation = true
110+
relocationPrefix = "${project.group}.${project.name.lowercase()}.libraries"
130111
}
131112
}

gradle.properties

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
kotlin.code.style=official
2-
3-
kotlinVersion=1.8.10
4-
mcApiVersion=1.19
5-
repoRef=SimpleMC/SimpleHealthbars2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#This file is generated by updateDaemonJvm
2+
toolchainVersion=21

gradle/libs.versions.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[versions]
2+
axionRelease = "1.18.16"
3+
kotlin = "2.1.10"
4+
ktlintGradle = "12.1.2"
5+
mcApi = "1.21"
6+
shadow = "8.3.6"
7+
spigot = "1.21.+"
8+
9+
[plugins]
10+
axionRelease = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionRelease"}
11+
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"}
12+
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintGradle"}
13+
shadow = { id = "com.gradleup.shadow", version.ref = "shadow"}
14+
15+
[libraries]
16+
spigot = { group = "org.spigotmc", name = "spigot-api", version.ref = "spigot" }

gradle/wrapper/gradle-wrapper.jar

-17.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)