@@ -45,6 +45,7 @@ import org.gradle.api.file.ConfigurableFileCollection
4545import org.gradle.api.file.DirectoryProperty
4646import org.gradle.api.file.RegularFileProperty
4747import org.gradle.api.provider.ListProperty
48+ import org.gradle.api.provider.Property
4849import org.gradle.api.tasks.*
4950import org.gradle.kotlin.dsl.*
5051import org.gradle.workers.WorkAction
@@ -101,6 +102,9 @@ abstract class RemapSources : JavaLauncherTask() {
101102 @get:OutputFile
102103 abstract val spigotRecompiledClasses: RegularFileProperty
103104
105+ @get:Input
106+ abstract val sourceCompatibility: Property <Int >
107+
104108 override fun init () {
105109 super .init ()
106110
@@ -109,6 +113,7 @@ abstract class RemapSources : JavaLauncherTask() {
109113 testsOutputZip.convention(defaultOutput(" $name -tests" , " jar" ))
110114 generatedAt.convention(defaultOutput(" at" ))
111115 spigotRecompiledClasses.convention(defaultOutput(" spigotRecompiledClasses" , " txt" ))
116+ sourceCompatibility.convention(17 )
112117 }
113118
114119 @TaskAction
@@ -140,6 +145,8 @@ abstract class RemapSources : JavaLauncherTask() {
140145
141146 outputDir.set(srcOut)
142147 generatedAtOutput.set(generatedAt.path)
148+
149+ sourceCompat.set(sourceCompatibility.orNull)
143150 }
144151
145152 val testSrc = spigotServerDir.path.resolve(" src/test/java" )
@@ -160,6 +167,8 @@ abstract class RemapSources : JavaLauncherTask() {
160167 cacheDir.set(this @RemapSources.layout.cache)
161168
162169 outputDir.set(testOut)
170+
171+ sourceCompat.set(sourceCompatibility.orNull)
163172 }
164173
165174 queue.await()
@@ -210,7 +219,7 @@ abstract class RemapSources : JavaLauncherTask() {
210219
211220 // Remap any references Spigot maps to mojmap+yarn
212221 Mercury ().let { merc ->
213- merc.sourceCompatibility = JavaCore .VERSION_17
222+ merc.sourceCompatibility = parameters.sourceCompat.map { it.toString() }.orNull ? : JavaCore .VERSION_17
214223 merc.isGracefulClasspathChecks = true
215224 merc.classPath.addAll(parameters.classpath.map { it.toPath() })
216225
@@ -265,6 +274,8 @@ abstract class RemapSources : JavaLauncherTask() {
265274 val cacheDir: RegularFileProperty
266275 val generatedAtOutput: RegularFileProperty
267276 val outputDir: RegularFileProperty
277+
278+ val sourceCompat: Property <Int >
268279 }
269280
270281 object ExplicitThisAdder : SourceRewriter {
0 commit comments