1- import io.papermc.hangarpublishplugin.model.Platforms
2-
31plugins {
42 `java- library`
53 id(" io.github.goooler.shadow" ) version " 8.1.7"
@@ -11,10 +9,10 @@ plugins {
119}
1210
1311group = " fr.formiko.mc.underilla"
14- version = " 2.1.6 "
12+ version = " 2.1.7 "
1513description= " Generate vanilla cave in custom world."
16- val mainMinecraftVersion = " 1.21.6 "
17- val supportedMinecraftVersions = " 1.21.3 - 1.21.6 "
14+ val mainMinecraftVersion = " 1.21.8 "
15+ val supportedMinecraftVersions = " 1.21.3 - 1.21.8 "
1816val voidWorldGeneratorVersion = " 1.3.2"
1917val chunkyVersion = " 1.4.28"
2018
@@ -30,7 +28,7 @@ repositories {
3028
3129
3230dependencies {
33- // compileOnly("io.papermc.paper:paper-api:1.20.4 -R0.1-SNAPSHOT") // without paperweight
31+ // compileOnly("io.papermc.paper:paper-api:$mainMinecraftVersion -R0.1-SNAPSHOT") // without paperweight
3432 paperweight.paperDevBundle(" $mainMinecraftVersion -R0.1-SNAPSHOT" )
3533 implementation(" fr.formiko.mc.biomeutils:biomeutils:1.1.8" )
3634 implementation(" com.github.FormikoLudo:Utils:0.0.9" )
@@ -126,21 +124,83 @@ tasks.register("echoReleaseName") {
126124 }
127125}
128126
127+ val extractChangelog = tasks.register(" extractChangelog" ) {
128+ group = " documentation"
129+ description = " Extracts the changelog for the current project version from CHANGELOG.md, including the version header."
130+
131+ val changelog = project.objects.property(String ::class )
132+ outputs.upToDateWhen { false }
133+
134+ doLast {
135+ val version = project.version.toString()
136+ val changelogFile = project.file(" CHANGELOG.md" )
137+
138+ if (! changelogFile.exists()) {
139+ println (" CHANGELOG.md not found." )
140+ changelog.set(" No changelog found." )
141+ return @doLast
142+ }
143+
144+ val lines = changelogFile.readLines()
145+ val entries = mutableListOf<String >()
146+ var foundVersion = false
147+
148+ for (line in lines) {
149+ when {
150+ // Include the version line itself
151+ line.trim().equals(" # $version " , ignoreCase = true ) -> {
152+ foundVersion = true
153+ entries.add(line)
154+ }
155+ // Stop collecting at the next version header
156+ foundVersion && line.trim().startsWith(" # " ) -> break
157+ // Collect lines after the version header
158+ foundVersion -> entries.add(line)
159+ }
160+ }
161+
162+ val result = if (entries.isEmpty()) {
163+ " Update to $version ."
164+ } else {
165+ entries.joinToString(" \n " ).trim()
166+ }
167+
168+ // println("Changelog for version $version:\n$result")
169+ changelog.set(result)
170+ }
171+
172+ // Make changelog accessible from other tasks
173+ extensions.add(" changelog" , changelog)
174+ }
175+
176+ tasks.register(" echoLatestVersionChangelog" ) {
177+ group = " documentation"
178+ description = " Displays the latest version change."
179+
180+ dependsOn(tasks.named(" extractChangelog" ))
181+
182+ doLast {
183+ println ((extractChangelog.get().extensions.getByName(" changelog" ) as Property <String >).get())
184+ }
185+ }
186+
129187val versionString: String = version as String
130188val isRelease: Boolean = ! versionString.contains(" SNAPSHOT" )
131189
132190hangarPublish { // ./gradlew publishPluginPublicationToHangar
133191 publications.register(" plugin" ) {
134192 version.set(project.version as String )
135193 channel.set(if (isRelease) " Release" else " Snapshot" )
136- // id.set(project.name as String)
137- id.set(" Underilla" )
194+ id.set(project.name)
138195 apiKey.set(System .getenv(" HANGAR_API_TOKEN" ))
196+ changelog.set(
197+ extractChangelog.map {
198+ (it.extensions.getByName(" changelog" ) as Property <String >).get()
199+ }
200+ )
139201 platforms {
140- register(Platforms .PAPER ) {
141- jar.set(tasks.shadowJar.flatMap { it.archiveFile })
142- // jar.set(File("build/libs/${project.name}-${project.version}.jar"))
143- // externalDownloadUrl.set("https://github.com/HydrolienF/Underilla/releases/download/1.6.14/Underilla-1.6.14.jar")
202+ register(io.papermc.hangarpublishplugin.model.Platforms .PAPER ) {
203+ url = " https://github.com/HydrolienF/" + project.name+ " /releases/download/" + versionString+ " /" + project.name+ " -" + versionString+ " .jar"
144204
145205 // Set platform versions from gradle.properties file
146206 val versions: List <String > = supportedMinecraftVersions.replace(" " , " " ).split(" ," )
0 commit comments