Skip to content

Commit

Permalink
Always remap files known to be mods
Browse files Browse the repository at this point in the history
Also improve RemapJar task
  • Loading branch information
MsRandom committed Feb 16, 2025
1 parent 8b78dc9 commit 15b672e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ org.gradle.configuration-cache=true
# org.gradle.unsafe.isolated-projects=true

group=net.msrandom
version=0.5.10
version=0.5.11
kotlin.code.style=official
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ abstract class RemapAction : TransformAction<RemapAction.Parameters> {
abstract val filterMods: Property<Boolean>
@Input get

abstract val modFiles: ConfigurableFileCollection
@PathSensitive(PathSensitivity.ABSOLUTE)
@InputFiles
get

abstract val cacheDirectory: DirectoryProperty
@Internal get

Expand All @@ -57,9 +62,6 @@ abstract class RemapAction : TransformAction<RemapAction.Parameters> {
}
}

abstract val execOperations: ExecOperations
@Inject get

abstract val objectFactory: ObjectFactory
@Inject get

Expand All @@ -76,7 +78,7 @@ abstract class RemapAction : TransformAction<RemapAction.Parameters> {
override fun transform(outputs: TransformOutputs) {
val input = inputFile.get().asFile

if (parameters.filterMods.get() && !isMod(input.toPath())) {
if (parameters.filterMods.get() && input !in parameters.modFiles && !isMod(input.toPath())) {
outputs.file(inputFile)

return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.bundling.Jar
import org.gradle.jvm.tasks.Jar
import org.gradle.language.base.plugins.LifecycleBasePlugin

abstract class RemapJar : Jar() {
Expand All @@ -37,32 +37,35 @@ abstract class RemapJar : Jar() {
@CompileClasspath
get

abstract val remappedClasses: DirectoryProperty
@Internal get

abstract val cacheDirectory: DirectoryProperty
@Internal get

init {
run {
group = LifecycleBasePlugin.BUILD_GROUP
group = LifecycleBasePlugin.BUILD_GROUP

sourceNamespace.convention(MinecraftCodevRemapperPlugin.NAMED_MAPPINGS_NAMESPACE)
sourceNamespace.convention(MinecraftCodevRemapperPlugin.NAMED_MAPPINGS_NAMESPACE)

cacheDirectory.set(getGlobalCacheDirectoryProvider(project))
}
}
cacheDirectory.set(getGlobalCacheDirectoryProvider(project))
remappedClasses.set(temporaryDir)

from(remappedClasses)

@TaskAction
fun remap() {
val mappings = MemoryMappingTree()
doFirst {
val mappings = MemoryMappingTree()

Tiny2Reader.read(this.mappings.asFile.get().reader(), mappings)
Tiny2Reader.read(this.mappings.asFile.get().reader(), mappings)

JarRemapper.remap(
mappings,
sourceNamespace.get(),
targetNamespace.get(),
input.getAsPath(),
archiveFile.get().toPath(),
classpath,
)
JarRemapper.remap(
mappings,
sourceNamespace.get(),
targetNamespace.get(),
input.getAsPath(),
archiveFile.get().toPath(),
classpath,
)
}
}
}

0 comments on commit 15b672e

Please sign in to comment.