@@ -23,14 +23,26 @@ runtimeTestProductionMods.transitive = false
2323
2424[configurations. modImplementation, configurations. modRuntimeOnly]. each { sourceConfiguration ->
2525 sourceConfiguration. dependencies. each { dependency ->
26- if (! (dependency instanceof org.gradle.api.artifacts. ModuleDependency )) {
26+ if (! (dependency instanceof ModuleDependency )) {
2727 return
2828 }
29- def productionDependency = project . dependencies . create( [
29+ def productionNotation = [
3030 group : dependency. group,
3131 name : dependency. name,
3232 version : dependency. version
33- ])
33+ ]
34+ if (! dependency. artifacts. empty) {
35+ def requestedArtifact = dependency. artifacts. iterator(). next()
36+ if (requestedArtifact. classifier != null ) {
37+ productionNotation. classifier = requestedArtifact. classifier
38+ }
39+ if (requestedArtifact. extension != null ) {
40+ productionNotation. ext = requestedArtifact. extension
41+ }
42+ }
43+ def productionDependency = project. dependencies. create(
44+ productionNotation
45+ )
3446 productionDependency. transitive = false
3547 runtimeTestProductionMods. dependencies. add(productionDependency)
3648 }
@@ -44,17 +56,19 @@ def runtimeTestMinecraftDir = providers.gradleProperty('runtimeTestMinecraftDir'
4456def runtimeTestSupportDir = layout. buildDirectory. dir(' runtime-test/support' )
4557def runtimeTestClientModsDir = layout. buildDirectory. dir(' runtime-test/client-mods' )
4658def runtimeRemappedDir = layout. buildDirectory. dir(' runtime-test/remapped-mods' )
47- def runtimeInputDir = layout. buildDirectory. dir(' runtime-test/inputs' )
59+ def runtimeMcpRemapMarker = layout. buildDirectory. file(
60+ ' runtime-test/runtime-mcp-remap.marker'
61+ )
62+ def runtimeRemapSchema = ' runtime-mcp-remap-v2'
4863
4964def runtimeProductionFiles = []
50- def runtimeRemapTasks = []
51- def runtimeDependencyIndex = 0
52- def namespaceAttribute = org.gradle.api.attributes.Attribute . of(
65+ def runtimeTestMcpDependencies = []
66+ def namespaceAttribute = Attribute . of(
5367 ' com.gtnewhorizons.retrofuturagradle.obfuscation' ,
5468 String
5569)
5670runtimeTestProductionMods. incoming. artifactView {}. artifacts. each { artifact ->
57- if (artifact. file. name. endsWith(' .jar' ) == false
71+ if (! artifact. file. name. endsWith(' .jar' )
5872 || artifact. file. name. endsWith(' -sources.jar' )) {
5973 return
6074 }
@@ -67,35 +81,89 @@ runtimeTestProductionMods.incoming.artifactView {}.artifacts.each { artifact ->
6781 return
6882 }
6983
70- def index = runtimeDependencyIndex ++
71- def inputTask = tasks . register( " runtimeTestInput ${ index } " , Jar ) {
72- archiveFileName = " runtime-test-input- ${ index } .jar "
73- destinationDirectory = runtimeInputDir
74- from { zipTree(artifact . file) }
84+ def moduleId = artifact . variant . owner
85+ if ( ! (moduleId instanceof ModuleComponentIdentifier ) ) {
86+ throw new GradleException (
87+ " Runtime test artifact is not an external module: ${ artifact.file } "
88+ )
7589 }
76- def remapTask = minecraftConfig. remap(inputTask. get(), " runtimeTestRemap${ index} " ) {
77- devNamespace ' mcp'
78- prodNamespace productionNamespace. name
79- mixinRemap {
80- enableBaseMixin()
81- enableMixinExtra()
82- disableRefmap()
83- }
90+ def dependencyNotation = [
91+ group : moduleId. group,
92+ name : moduleId. module,
93+ version : moduleId. version
94+ ]
95+ if (artifact. file. name. endsWith(' -dev.jar' )) {
96+ dependencyNotation. classifier = ' dev'
97+ }
98+ runtimeTestMcpDependencies. add(
99+ project. dependencies. create(dependencyNotation)
100+ )
101+ }
102+
103+ def runtimeTestMcpMods = configurations. maybeCreate(' runtimeTestMcpMods' )
104+ runtimeTestMcpMods. canBeConsumed = false
105+ runtimeTestMcpMods. canBeResolved = true
106+ runtimeTestMcpMods. transitive = false
107+ runtimeTestMcpMods. dependencies. addAll(runtimeTestMcpDependencies)
108+
109+ minecraftConfig. mods. remap(runtimeTestMcpMods) {
110+ namespace ' mcp'
111+ mixinRemap {
112+ enableBaseMixin()
113+ enableMixinExtra()
114+ disableRefmap()
84115 }
85- remapTask. configure {
86- destinationDirectory = runtimeRemappedDir
87- archiveFileName = artifact. file. name. replaceFirst(' -dev(?=\\ .jar$)' , ' ' )
116+ }
117+
118+ def runtimeMcpRemapTask = tasks. register(' runtimeTestRemapMcp' ) {
119+ inputs. files(runtimeTestMcpMods)
120+ inputs. property(' runtimeRemapSchema' , runtimeRemapSchema)
121+ inputs. property(' minecraftVersion' , minecraftVersion)
122+ inputs. property(' cleanroomVersion' , cleanroomVersion)
123+ inputs. property(' productionNamespace' , productionNamespace. name)
124+ inputs. file(layout. projectDirectory. file(
125+ ' .gradle/unimined/local/mappings/srg2mcp.tsrg'
126+ )). optional()
127+ outputs. dir(runtimeRemappedDir)
128+ outputs. file(runtimeMcpRemapMarker)
129+ doLast {
130+ def inputFiles = runtimeTestMcpMods. resolve() as Set
131+ logger. lifecycle(
132+ " [RuntimeTest] Remapping ${ inputFiles.size()} MCP mod(s) " +
133+ " from mcp to ${ productionNamespace.name} in one batch"
134+ )
135+ def remappedDir = runtimeRemappedDir. get(). asFile
136+ project. delete(remappedDir)
137+ remappedDir. mkdirs()
138+ def remappedFiles = minecraftConfig. mods. getClasspathAs(
139+ productionNamespace,
140+ inputFiles
141+ )
142+ project. copy {
143+ from remappedFiles
144+ into remappedDir
145+ include ' *.jar'
146+ rename { fileName ->
147+ fileName. replaceFirst(' -dev(?=\\ .jar$)' , ' ' )
148+ }
149+ }
150+ runtimeMcpRemapMarker. get(). asFile. text = inputFiles. collect {
151+ it. name + ' :' + it. length() + ' :' + it. lastModified()
152+ }. sort(). join(' \n ' ) + ' \n '
153+ logger. lifecycle(
154+ " [RuntimeTest] Finished MCP remap; produced " +
155+ " ${ remappedFiles.size()} file(s)"
156+ )
88157 }
89- runtimeRemapTasks. add(remapTask)
90158}
91159
92160tasks. register(' stageRuntimeTestMods' , Sync ) {
93161 dependsOn productionJarTask
94- dependsOn runtimeRemapTasks
162+ dependsOn(runtimeMcpRemapTask)
95163 from(productionJarTask. flatMap { it. archiveFile })
96164 from(runtimeProductionFiles)
97- runtimeRemapTasks . each { remapTask ->
98- from(remapTask . flatMap { it . archiveFile })
165+ from(runtimeRemappedDir) {
166+ include ' *.jar '
99167 }
100168 into(runtimeTestModsDir)
101169 include ' *.jar'
@@ -114,12 +182,26 @@ tasks.register('stageRuntimeTestClientMods', Sync) {
114182
115183tasks. register(' installRuntimeTestClient' , JavaExec ) {
116184 dependsOn cleanroomInstaller
185+ dependsOn ' stageRuntimeTestClientMods'
117186 classpath = cleanroomInstaller
118187 mainClass = ' net.minecraftforge.installer.SimpleInstaller'
119188 def installDir = runtimeTestMinecraftDir. get(). asFile
189+ def profile = new File (
190+ installDir,
191+ " versions/${ minecraftVersion} -Cleanroom-${ cleanroomVersion} /" +
192+ " ${ minecraftVersion} -Cleanroom-${ cleanroomVersion} .json"
193+ )
194+ def cleanroomJar = new File (
195+ installDir,
196+ " libraries/com/cleanroommc/cleanroom/${ cleanroomVersion} /" +
197+ " cleanroom-${ cleanroomVersion} .jar"
198+ )
120199 def marker = layout. buildDirectory. file(' runtime-test/cleanroom-client-installed.marker' ). get(). asFile
121200 onlyIf {
122- ! marker. exists() || marker. text. trim() != " ${ minecraftVersion} -Cleanroom-${ cleanroomVersion} "
201+ ! marker. exists()
202+ || marker. text. trim() != " ${ minecraftVersion} -Cleanroom-${ cleanroomVersion} "
203+ || ! profile. isFile()
204+ || ! cleanroomJar. isFile()
123205 }
124206 doFirst {
125207 installDir. mkdirs()
0 commit comments