1- import org.jetbrains.changelog.Changelog
2-
31plugins {
42 id ' java'
53 id ' java-library'
64 id ' maven-publish'
7- id ' com.gradleup.shadow' version ' 9.0.0-rc3' // Remove this line and shadowJar task if you don't need shadow
8- id ' org.jetbrains.changelog' version ' 2.2.1'
5+ id ' com.gradleup.shadow' version ' 9.0.2'
96 id ' xyz.wagyourtail.unimined' version ' 1.4.1'
7+ id ' net.kyori.blossom' version ' 2.1.0'
108}
119
1210apply from : ' gradle/scripts/helpers.gradle'
@@ -17,10 +15,6 @@ assertProperty 'root_package'
1715assertProperty ' mod_id'
1816assertProperty ' mod_name'
1917
20- if (propertyBool(' generate_reference_class' )) {
21- generateReferenceClass()
22- }
23-
2418assertSubProperties ' use_access_transformer' , ' access_transformer_locations'
2519assertSubProperties ' is_coremod' , ' coremod_includes_mod' , ' coremod_plugin_class_name'
2620assertSubProperties ' use_asset_mover' , ' asset_mover_version'
@@ -56,7 +50,9 @@ configurations {
5650 implementation. extendsFrom(embed)
5751 implementation. extendsFrom(contain)
5852 modCompileOnly
59- compileOnly. extendsFrom modCompileOnly
53+ compileOnly. extendsFrom(modCompileOnly)
54+ modRuntimeOnly
55+ runtimeOnly. extendsFrom(modRuntimeOnly)
6056}
6157
6258unimined. minecraft {
@@ -155,6 +151,23 @@ processResources {
155151 rename ' (.+_at.cfg)' , ' META-INF/$1'
156152}
157153
154+ sourceSets {
155+ main {
156+ blossom {
157+ javaSources {
158+ property(' mod_id' , propertyString(' mod_id' ))
159+ property(' mod_name' , propertyString(' mod_name' ))
160+ property(' mod_version' , propertyString(' mod_version' ))
161+ property(' package' , " ${ root_package} .${ mod_id} " )
162+ }
163+ }
164+ }
165+ }
166+
167+ if (! propertyBool(' enable_shadow' )) {
168+ shadowJar. enabled = false
169+ }
170+
158171jar {
159172 duplicatesStrategy = DuplicatesStrategy . EXCLUDE
160173 if (configurations. contain. size() > 0 ) {
@@ -196,6 +209,15 @@ shadowJar {
196209 archiveClassifier = " shadow"
197210}
198211
212+ remapJar {
213+ doFirst {
214+ logging. captureStandardOutput LogLevel . INFO
215+ }
216+ doLast {
217+ logging. captureStandardOutput LogLevel . QUIET
218+ }
219+ }
220+
199221compileTestJava {
200222 sourceCompatibility = targetCompatibility = JavaVersion . VERSION_21
201223}
@@ -212,31 +234,6 @@ test {
212234 }
213235}
214236
215- String parserChangelog () {
216- if (! file(' CHANGELOG.md' ). exists()) {
217- throw new GradleException (' publish_with_changelog is true, but CHANGELOG.md does not exist in the workspace!' )
218- }
219- String parsedChangelog = changelog. renderItem(
220- changelog. get(propertyString(' mod_version' )). withHeader(false ). withEmptySections(false ),
221- Changelog.OutputType . MARKDOWN )
222- if (parsedChangelog. isEmpty()) {
223- throw new GradleException (' publish_with_changelog is true, but the changelog for the latest version is empty!' )
224- }
225- return parsedChangelog
226- }
227-
228- def generateReferenceClass () {
229- var target = new File (" ${ rootProject.projectDir} /src/main/java/${ root_package.replace('.', '/')} /${ mod_id} /Reference.java" )
230- var template = new File (" ${ rootProject.projectDir} /template/Reference.java" )
231- var replaceMap = [$package : " ${ root_package} .${ mod_id} " , $mod_id : mod_id, $mod_name : mod_name, $mod_version : mod_version]
232- target. withWriter { var writer ->
233- template. eachLine { var line ->
234- replaceMap. each {if (line. contains(it. key)) line = line. replace(it. key, it. value)}
235- writer. write(line + " \n " );
236- }
237- }
238- }
239-
240237tasks. withType(JavaCompile ). configureEach {
241238 options. encoding = ' UTF-8'
242239}
0 commit comments