Skip to content

Commit e6046c2

Browse files
committed
Setup JvmDowngrader to downgrade to java 8 while keeping java 17 classes as MRJ
1 parent f910496 commit e6046c2

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

build.gradle

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'legacy-looming' version "1.10-SNAPSHOT" // Version must be the same as fabric-loom's
44
id 'maven-publish'
55
id 'com.gradleup.shadow' version '8.3.6'
6+
id 'xyz.wagyourtail.jvmdowngrader' version '1.3.0'
67
id "com.modrinth.minotaur" version "2.+"
78
id 'jacoco'
89
id "org.sonarqube" version "5.0.0.4638"
@@ -62,6 +63,12 @@ dependencies {
6263
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
6364
}
6465

66+
jvmdg {
67+
downgradeTo = JavaVersion.VERSION_1_8
68+
multiReleaseOriginal.set(true)
69+
multiReleaseVersions = [JavaVersion.VERSION_17]
70+
}
71+
6572
base {
6673
archivesName = project.archives_base_name
6774
}
@@ -79,7 +86,7 @@ processResources {
7986
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
8087
tasks.withType(JavaCompile).configureEach {
8188
it.options.encoding = "UTF-8"
82-
if (JavaVersion.current().isJava9Compatible()) it.options.release = 17
89+
it.options.release = 17
8390
}
8491

8592
java {
@@ -94,7 +101,7 @@ java {
94101

95102
shadowJar {
96103
configurations = [project.configurations.shadow]
97-
exclude("META-INF")
104+
exclude("META-INF/**")
98105

99106
relocate 'net.fabricmc.mappingio', 'fr.catcore.modremapperapi.impl.lib.mappingio'
100107
relocate 'net.fabricmc.tinyremapper', 'fr.catcore.modremapperapi.impl.lib.tinyremapper'
@@ -114,6 +121,15 @@ remapJar {
114121
mustRunAfter(shadowJar)
115122
// Set the input jar for the task. Here use the shadow Jar that include the .class of the transitive dependency
116123
input = shadowJar.archiveFile
124+
setArchiveClassifier("remapped")
125+
}
126+
127+
downgradeJar {
128+
inputFile = remapJar.archiveFile
129+
}
130+
131+
shadeDowngradedApi {
132+
setArchiveClassifier("")
117133
}
118134

119135
test {
@@ -157,7 +173,7 @@ Apply method invocation replacers to Interface methods as well.\
157173
Fix possible crash while remapping refmap.\
158174
Add system property to run in development mode for 3rd party remappers.
159175
"""
160-
uploadFile = remapJar
176+
uploadFile = shadeDowngradedApi
161177

162178
dependencies {
163179
embedded.version "spasm", project.spasm_version
@@ -170,4 +186,4 @@ task testmodJar(type: Jar) {
170186
archiveClassifier.set("testmod")
171187
}
172188

173-
build.dependsOn testmodJar
189+
build.dependsOn(testmodJar, shadeDowngradedApi)

0 commit comments

Comments
 (0)