@@ -4,8 +4,11 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
4
4
plugins {
5
5
`java- library`
6
6
id(" com.github.johnrengelman.shadow" ) version " 7.1.2"
7
+ id(" io.papermc.hangar-publish-plugin" ) version " 0.1.2"
7
8
}
8
9
10
+ java.sourceCompatibility = JavaVersion .VERSION_17
11
+
9
12
repositories {
10
13
mavenCentral()
11
14
mavenLocal()
@@ -51,57 +54,93 @@ dependencies {
51
54
compileOnly(" io.th0rgal:oraxen:1.173.0" )
52
55
}
53
56
54
- tasks.withType<ShadowJar > {
55
- val projectVersion: String by project
56
- archiveFileName.set(" AuraSkills-${projectVersion} .jar" )
57
-
58
- relocate(" co.aikar.commands" , " dev.aurelium.auraskills.acf" )
59
- relocate(" co.aikar.locales" , " dev.aurelium.auraskills.locales" )
60
- relocate(" de.tr7zw.changeme.nbtapi" , " dev.aurelium.auraskills.nbtapi" )
61
- relocate(" org.bstats" , " dev.aurelium.auraskills.bstats" )
62
- relocate(" com.ezylang.evalex" , " dev.aurelium.auraskills.evalex" )
63
- relocate(" net.kyori" , " dev.aurelium.auraskills.kyori" )
64
- relocate(" com.zaxxer.hikari" , " dev.aurelium.auraskills.hikari" )
65
- relocate(" dev.aurelium.slate" , " dev.aurelium.auraskills.slate" )
66
- relocate(" org.spongepowered.configurate" , " dev.aurelium.auraskills.configurate" )
67
- relocate(" io.leangen.geantyref" , " dev.aurelium.auraskills.geantyref" )
68
- relocate(" net.querz" , " dev.aurelium.auraskills.querz" )
69
- relocate(" com.archyx.polyglot" , " dev.aurelium.auraskills.polyglot" )
70
- relocate(" org.atteo.evo.inflector" , " dev.aurelium.auraskills.inflector" )
71
-
72
- exclude(" acf-*.properties" )
73
-
74
- finalizedBy(" copyJar" )
75
- }
57
+ tasks {
58
+ withType<ShadowJar > {
59
+ val projectVersion: String by project
60
+ archiveFileName.set(" AuraSkills-${projectVersion} .jar" )
76
61
77
- java.sourceCompatibility = JavaVersion .VERSION_17
62
+ relocate(" co.aikar.commands" , " dev.aurelium.auraskills.acf" )
63
+ relocate(" co.aikar.locales" , " dev.aurelium.auraskills.locales" )
64
+ relocate(" de.tr7zw.changeme.nbtapi" , " dev.aurelium.auraskills.nbtapi" )
65
+ relocate(" org.bstats" , " dev.aurelium.auraskills.bstats" )
66
+ relocate(" com.ezylang.evalex" , " dev.aurelium.auraskills.evalex" )
67
+ relocate(" net.kyori" , " dev.aurelium.auraskills.kyori" )
68
+ relocate(" com.zaxxer.hikari" , " dev.aurelium.auraskills.hikari" )
69
+ relocate(" dev.aurelium.slate" , " dev.aurelium.auraskills.slate" )
70
+ relocate(" org.spongepowered.configurate" , " dev.aurelium.auraskills.configurate" )
71
+ relocate(" io.leangen.geantyref" , " dev.aurelium.auraskills.geantyref" )
72
+ relocate(" net.querz" , " dev.aurelium.auraskills.querz" )
73
+ relocate(" com.archyx.polyglot" , " dev.aurelium.auraskills.polyglot" )
74
+ relocate(" org.atteo.evo.inflector" , " dev.aurelium.auraskills.inflector" )
78
75
79
- tasks.register<Copy >(" copyJar" ) {
80
- val projectVersion : String by project
81
- from(" build/libs/AuraSkills-${projectVersion} .jar" )
82
- into(" ../build/libs" )
83
- }
76
+ exclude(" acf-*.properties" )
77
+
78
+ finalizedBy(" copyJar" )
79
+ }
80
+
81
+ register<Copy >(" copyJar" ) {
82
+ val projectVersion : String by project
83
+ from(" build/libs/AuraSkills-${projectVersion} .jar" )
84
+ into(" ../build/libs" )
85
+ }
84
86
85
- tasks {
86
87
build {
87
88
dependsOn(shadowJar)
88
89
}
90
+
89
91
javadoc {
90
92
options {
91
93
(this as CoreJavadocOptions ).addStringOption(" Xdoclint:none" , " -quiet" )
92
94
}
93
95
}
94
- }
95
96
96
- tasks.withType<JavaCompile > {
97
- options.encoding = " UTF-8"
98
- options.compilerArgs.add(" -parameters" )
99
- options.isFork = true
100
- options.forkOptions.executable = " javac"
97
+ withType<JavaCompile > {
98
+ options.encoding = " UTF-8"
99
+ options.compilerArgs.add(" -parameters" )
100
+ options.isFork = true
101
+ options.forkOptions.executable = " javac"
102
+ }
103
+
104
+ processResources {
105
+ filesMatching(" plugin.yml" ) {
106
+ expand(" projectVersion" to project.version)
107
+ }
108
+ }
101
109
}
102
110
103
- tasks.processResources {
104
- filesMatching(" plugin.yml" ) {
105
- expand(" projectVersion" to project.version)
111
+ val supportedVersions = (project.property(" supportedMCVersions" ) as String ).split(" ," ).map { it.trim() }
112
+
113
+ if (project.hasProperty(" hangarApiKey" )) {
114
+ hangarPublish {
115
+ publications.register(" AuraSkills" ) {
116
+ val projectVersion = project.version as String
117
+
118
+ version.set(projectVersion)
119
+ id.set(" AuraSkills" )
120
+ channel.set(" Release" )
121
+ changelog.set(extractChangelog(projectVersion))
122
+
123
+ apiKey.set(project.property(" hangarApiKey" ) as String )
124
+
125
+ platforms {
126
+ paper {
127
+ jar.set(tasks.shadowJar.flatMap { it.archiveFile })
128
+ platformVersions.set(supportedVersions)
129
+ }
130
+ }
131
+ }
106
132
}
107
133
}
134
+
135
+ fun extractChangelog (version : String ): String {
136
+ val heading = Regex .escape(version)
137
+ val path = if (System .getProperty(" user.dir" ).endsWith(" bukkit" )) " ../Changelog.md" else " Changelog.md"
138
+
139
+ val fullChangelog = File (path).readText()
140
+ val headingPattern = Regex (" ## $heading \\ R+([\\ s\\ S]*?)\\ R+##\\ s" , RegexOption .DOT_MATCHES_ALL )
141
+ val result = headingPattern.find(fullChangelog)
142
+
143
+ return result?.groupValues?.get(1 )?.trim()
144
+ ? : throw IllegalArgumentException (" Failed to extract changelog section for version $version " )
145
+ }
146
+
0 commit comments