Skip to content

Commit 21f771d

Browse files
committed
Make RemapSources sourceCompatibility a property
1 parent 0b3688c commit 21f771d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

  • paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks

paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RemapSources.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import org.gradle.api.file.ConfigurableFileCollection
4545
import org.gradle.api.file.DirectoryProperty
4646
import org.gradle.api.file.RegularFileProperty
4747
import org.gradle.api.provider.ListProperty
48+
import org.gradle.api.provider.Property
4849
import org.gradle.api.tasks.*
4950
import org.gradle.kotlin.dsl.*
5051
import 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

Comments
 (0)