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 {
@@ -154,6 +150,23 @@ processResources {
154150 rename ' (.+_at.cfg)' , ' META-INF/$1'
155151}
156152
153+ sourceSets {
154+ main {
155+ blossom {
156+ javaSources {
157+ property(' mod_id' , propertyString(' mod_id' ))
158+ property(' mod_name' , propertyString(' mod_name' ))
159+ property(' mod_version' , propertyString(' mod_version' ))
160+ property(' package' , " ${ root_package} .${ mod_id} " )
161+ }
162+ }
163+ }
164+ }
165+
166+ if (! propertyBool(' enable_shadow' )) {
167+ shadowJar. enabled = false
168+ }
169+
157170jar {
158171 duplicatesStrategy = DuplicatesStrategy . EXCLUDE
159172 if (configurations. contain. size() > 0 ) {
@@ -194,6 +207,15 @@ shadowJar {
194207 archiveClassifier = " shadow"
195208}
196209
210+ remapJar {
211+ doFirst {
212+ logging. captureStandardOutput LogLevel . INFO
213+ }
214+ doLast {
215+ logging. captureStandardOutput LogLevel . QUIET
216+ }
217+ }
218+
197219compileTestJava {
198220 sourceCompatibility = targetCompatibility = JavaVersion . VERSION_21
199221}
@@ -210,31 +232,6 @@ test {
210232 }
211233}
212234
213- String parserChangelog () {
214- if (! file(' CHANGELOG.md' ). exists()) {
215- throw new GradleException (' publish_with_changelog is true, but CHANGELOG.md does not exist in the workspace!' )
216- }
217- String parsedChangelog = changelog. renderItem(
218- changelog. get(propertyString(' mod_version' )). withHeader(false ). withEmptySections(false ),
219- Changelog.OutputType . MARKDOWN )
220- if (parsedChangelog. isEmpty()) {
221- throw new GradleException (' publish_with_changelog is true, but the changelog for the latest version is empty!' )
222- }
223- return parsedChangelog
224- }
225-
226- def generateReferenceClass () {
227- var target = new File (" ${ rootProject.projectDir} /src/main/java/${ root_package.replace('.', '/')} /${ mod_id} /Reference.java" )
228- var template = new File (" ${ rootProject.projectDir} /template/Reference.java" )
229- var replaceMap = [$package : " ${ root_package} .${ mod_id} " , $mod_id : mod_id, $mod_name : mod_name, $mod_version : mod_version]
230- target. withWriter { var writer ->
231- template. eachLine { var line ->
232- replaceMap. each {if (line. contains(it. key)) line = line. replace(it. key, it. value)}
233- writer. write(line + " \n " );
234- }
235- }
236- }
237-
238235tasks. withType(JavaCompile ). configureEach {
239236 options. encoding = ' UTF-8'
240237}
0 commit comments