mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 13:30:08 +00:00
Chained mod target overlays
- Mod targets list an ordered overlay chain; later overlays replace earlier ones and earlier source replacements apply to inherited files - Forge and NeoForge metadata take their loader version range from the target - The Fabric permissions library is bundled only for targets that declare it - Dropped the 1.21.1 mods.toml copies that only differed in the loader range
This commit is contained in:
1 parent
03c2630497
commit
79e7b0c79e
9 files changed
+116
-58
No files matched your search
@@ -181,6 +181,8 @@ dependencies {
|
|||||||
fabricApi = ((Map<String, String>) irisModTarget.fabricModules).collect { String module, String moduleVersion ->
|
fabricApi = ((Map<String, String>) irisModTarget.fabricModules).collect { String module, String moduleVersion ->
|
||||||
"net.fabricmc.fabric-api:${module}:${moduleVersion}".toString()
|
"net.fabricmc.fabric-api:${module}:${moduleVersion}".toString()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (irisModTarget.fabricPermissions != null) {
|
||||||
fabricApi.add("me.lucko:fabric-permissions-api:${irisModTarget.fabricPermissions}".toString())
|
fabricApi.add("me.lucko:fabric-permissions-api:${irisModTarget.fabricPermissions}".toString())
|
||||||
}
|
}
|
||||||
fabricApi.each { Object notation ->
|
fabricApi.each { Object notation ->
|
||||||
@@ -296,6 +298,8 @@ if (irisModTarget.fabricModules != null) {
|
|||||||
nestedFabricApiJars = ((Map<String, String>) irisModTarget.fabricModules).collectEntries { String module, String ignored ->
|
nestedFabricApiJars = ((Map<String, String>) irisModTarget.fabricModules).collectEntries { String module, String ignored ->
|
||||||
[(module): "${module}.jar".toString()]
|
[(module): "${module}.jar".toString()]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (irisModTarget.fabricPermissions != null) {
|
||||||
nestedFabricApiJars.put('fabric-permissions-api', 'fabric-permissions-api.jar')
|
nestedFabricApiJars.put('fabric-permissions-api', 'fabric-permissions-api.jar')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,8 +263,9 @@ tasks.named('test').configure {
|
|||||||
processResources {
|
processResources {
|
||||||
inputs.property('version', irisVersion)
|
inputs.property('version', irisVersion)
|
||||||
inputs.property('minecraftVersion', minecraftVersion)
|
inputs.property('minecraftVersion', minecraftVersion)
|
||||||
|
inputs.property('loaderRange', irisModTarget.forgeRange.toString())
|
||||||
filesMatching('META-INF/mods.toml') {
|
filesMatching('META-INF/mods.toml') {
|
||||||
expand('version': irisVersion, 'minecraftVersion': minecraftVersion)
|
expand('version': irisVersion, 'minecraftVersion': minecraftVersion, 'loaderRange': irisModTarget.forgeRange.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
modLoader = "javafml"
|
modLoader = "javafml"
|
||||||
loaderVersion = "[66,67)"
|
loaderVersion = "${loaderRange}"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
issueTrackerURL = "https://github.com/VolmitSoftware/Iris/issues"
|
issueTrackerURL = "https://github.com/VolmitSoftware/Iris/issues"
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ logoFile = "assets/irisworldgen/icon.png"
|
|||||||
[[dependencies.irisworldgen]]
|
[[dependencies.irisworldgen]]
|
||||||
modId = "forge"
|
modId = "forge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[66,67)"
|
versionRange = "${loaderRange}"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
|
|||||||
@@ -264,8 +264,9 @@ tasks.named('test').configure {
|
|||||||
processResources {
|
processResources {
|
||||||
inputs.property('version', irisVersion)
|
inputs.property('version', irisVersion)
|
||||||
inputs.property('minecraftVersion', minecraftVersion)
|
inputs.property('minecraftVersion', minecraftVersion)
|
||||||
|
inputs.property('loaderRange', irisModTarget.neoForgeRange.toString())
|
||||||
filesMatching('META-INF/neoforge.mods.toml') {
|
filesMatching('META-INF/neoforge.mods.toml') {
|
||||||
expand('version': irisVersion, 'minecraftVersion': minecraftVersion)
|
expand('version': irisVersion, 'minecraftVersion': minecraftVersion, 'loaderRange': irisModTarget.neoForgeRange.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ logoFile = "assets/irisworldgen/icon.png"
|
|||||||
[[dependencies.irisworldgen]]
|
[[dependencies.irisworldgen]]
|
||||||
modId = "neoforge"
|
modId = "neoforge"
|
||||||
type = "required"
|
type = "required"
|
||||||
versionRange = "[26.3.0.65-beta,26.4)"
|
versionRange = "${loaderRange}"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ Map<String, Object> target = targets.get(targetMinecraft)
|
|||||||
if (target == null) {
|
if (target == null) {
|
||||||
throw new GradleException("Unsupported Iris mod target ${targetMinecraft}; choose ${targets.keySet().join(', ')}")
|
throw new GradleException("Unsupported Iris mod target ${targetMinecraft}; choose ${targets.keySet().join(', ')}")
|
||||||
}
|
}
|
||||||
|
targets.each { String minecraft, Map<String, Object> candidate ->
|
||||||
|
candidate.put('overlays', candidate.get('overlays') ?: [minecraft])
|
||||||
|
}
|
||||||
ext.irisModTarget = target
|
ext.irisModTarget = target
|
||||||
ext.irisModTargets = targets
|
ext.irisModTargets = targets
|
||||||
if (project.name.startsWith('iris-')) {
|
if (project.name.startsWith('iris-')) {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
"fabricRemap": true,
|
"fabricRemap": true,
|
||||||
"fabricLoader": "0.19.5",
|
"fabricLoader": "0.19.5",
|
||||||
"forge": "1.21.1-52.1.20",
|
"forge": "1.21.1-52.1.20",
|
||||||
|
"forgeRange": "[52,53)",
|
||||||
"neoForge": "21.1.262",
|
"neoForge": "21.1.262",
|
||||||
|
"neoForgeRange": "[21.1,21.2)",
|
||||||
"nativeAccess": "minecraft1_21_1",
|
"nativeAccess": "minecraft1_21_1",
|
||||||
"fabricModules": {
|
"fabricModules": {
|
||||||
"fabric-api-base": "0.4.42+6573ed8c19",
|
"fabric-api-base": "0.4.42+6573ed8c19",
|
||||||
@@ -25,7 +27,9 @@
|
|||||||
"fabricRemap": false,
|
"fabricRemap": false,
|
||||||
"fabricLoader": "0.19.5",
|
"fabricLoader": "0.19.5",
|
||||||
"forge": "26.3-66.0.8",
|
"forge": "26.3-66.0.8",
|
||||||
|
"forgeRange": "[66,67)",
|
||||||
"neoForge": "26.3.0.83",
|
"neoForge": "26.3.0.83",
|
||||||
|
"neoForgeRange": "[26.3.0.65-beta,26.4)",
|
||||||
"nativeAccess": "minecraft26_2",
|
"nativeAccess": "minecraft26_2",
|
||||||
"slf4j": "2.0.17"
|
"slf4j": "2.0.17"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
|
|
||||||
String sourceMinecraftVersion = providers.gradleProperty('minecraftVersion').getOrElse('26.3')
|
List<String> sourceOverlays = (List<String>) irisModTarget.overlays
|
||||||
List<File> adapterSourceRoots = [projectDir, file('../modded-common'), file('../client-common')]
|
List<File> adapterSourceRoots = [projectDir, file('../modded-common'), file('../client-common')]
|
||||||
|
|
||||||
tasks.named('compileTestJava', JavaCompile).configure {
|
tasks.named('compileTestJava', JavaCompile).configure {
|
||||||
@@ -12,20 +12,33 @@ tasks.withType(Test).configureEach {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
['java', 'resources'].each { String kind ->
|
Closure<List<File>> overlayDirectories = { File adapter, String kind ->
|
||||||
List<File> overlays = adapterSourceRoots.collect { File adapter ->
|
sourceOverlays.collect { String overlay -> new File(adapter, "src/versions/${overlay}/${kind}") }
|
||||||
new File(adapter, "src/versions/${sourceMinecraftVersion}/${kind}")
|
}
|
||||||
|
Closure<Integer> overlayOrigin = { List<File> overlays, String path ->
|
||||||
|
for (int index = overlays.size() - 1; index >= 0; index--) {
|
||||||
|
if (new File(overlays.get(index), path).isFile()) {
|
||||||
|
return index
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!overlays.any { File directory -> directory.isDirectory() }) {
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
['java', 'resources'].each { String kind ->
|
||||||
|
if (!adapterSourceRoots.any { File adapter -> overlayDirectories(adapter, kind).any { File directory -> directory.isDirectory() } }) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
TaskProvider<Sync> prepareSources = tasks.register("prepareVersion${kind.capitalize()}", Sync) {
|
TaskProvider<Sync> prepareSources = tasks.register("prepareVersion${kind.capitalize()}", Sync) {
|
||||||
adapterSourceRoots.each { File adapter ->
|
adapterSourceRoots.each { File adapter ->
|
||||||
File overlay = new File(adapter, "src/versions/${sourceMinecraftVersion}/${kind}")
|
List<File> overlays = overlayDirectories(adapter, kind)
|
||||||
from(new File(adapter, "src/main/${kind}")) {
|
from(new File(adapter, "src/main/${kind}")) {
|
||||||
exclude { FileTreeElement entry -> new File(overlay, entry.path).isFile() }
|
exclude { FileTreeElement entry -> overlayOrigin(overlays, entry.path) >= 0 }
|
||||||
|
}
|
||||||
|
overlays.eachWithIndex { File overlay, int index ->
|
||||||
|
from(overlay) {
|
||||||
|
exclude { FileTreeElement entry -> !entry.directory && overlayOrigin(overlays, entry.path) != index }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
from(overlay)
|
|
||||||
}
|
}
|
||||||
includeEmptyDirs = false
|
includeEmptyDirs = false
|
||||||
into(layout.buildDirectory.dir("generated/sources/iris/${kind}"))
|
into(layout.buildDirectory.dir("generated/sources/iris/${kind}"))
|
||||||
@@ -41,37 +54,49 @@ tasks.withType(Test).configureEach {
|
|||||||
tasks.named('verifyNativeBoundary').configure { dependsOn(prepareSources) }
|
tasks.named('verifyNativeBoundary').configure { dependsOn(prepareSources) }
|
||||||
}
|
}
|
||||||
|
|
||||||
File testRulesFile = file("../modded-common/src/versions/${sourceMinecraftVersion}/test/source-replacements.json")
|
List<File> testRulesFiles = sourceOverlays.collect { String overlay ->
|
||||||
if (testRulesFile.isFile()) {
|
file("../modded-common/src/versions/${overlay}/test/source-replacements.json")
|
||||||
Map<String, Object> testRules = (Map<String, Object>) new JsonSlurper().parse(testRulesFile)
|
}
|
||||||
|
boolean testOverlays = testRulesFiles.any { File rules -> rules.isFile() } || adapterSourceRoots.any { File adapter ->
|
||||||
|
overlayDirectories(adapter, 'test/java').any { File directory -> directory.isDirectory() }
|
||||||
|
}
|
||||||
|
if (testOverlays) {
|
||||||
|
List<Map<String, Object>> testRules = testRulesFiles.collect { File rules ->
|
||||||
|
rules.isFile() ? (Map<String, Object>) new JsonSlurper().parse(rules) : [:]
|
||||||
|
}
|
||||||
TaskProvider<Sync> prepareTests = tasks.register('prepareVersionTests', Sync) {
|
TaskProvider<Sync> prepareTests = tasks.register('prepareVersionTests', Sync) {
|
||||||
inputs.file(testRulesFile)
|
testRulesFiles.findAll { File rules -> rules.isFile() }.each { File rules -> inputs.file(rules) }
|
||||||
adapterSourceRoots.each { File adapter ->
|
adapterSourceRoots.each { File adapter ->
|
||||||
File overlay = new File(adapter, "src/versions/${sourceMinecraftVersion}/test/java")
|
List<File> overlays = overlayDirectories(adapter, 'test/java')
|
||||||
from(new File(adapter, 'src/test/java')) {
|
from(new File(adapter, 'src/test/java')) {
|
||||||
exclude { FileTreeElement entry -> new File(overlay, entry.path).isFile() }
|
exclude { FileTreeElement entry -> overlayOrigin(overlays, entry.path) >= 0 }
|
||||||
|
}
|
||||||
|
overlays.eachWithIndex { File overlay, int index ->
|
||||||
|
from(overlay) {
|
||||||
|
exclude { FileTreeElement entry -> !entry.directory && overlayOrigin(overlays, entry.path) != index }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
from(overlay)
|
|
||||||
}
|
}
|
||||||
includeEmptyDirs = false
|
includeEmptyDirs = false
|
||||||
into(layout.buildDirectory.dir('generated/sources/iris/test'))
|
into(layout.buildDirectory.dir('generated/sources/iris/test'))
|
||||||
doLast {
|
doLast {
|
||||||
List<Map<String, String>> rules = (List<Map<String, String>>) (testRules.get('global') ?: [])
|
|
||||||
Map<String, List<Map<String, String>>> fileRules = (Map<String, List<Map<String, String>>>) (testRules.get('files') ?: [:])
|
|
||||||
project.fileTree(destinationDir).matching { include('**/*.java') }.each { File source ->
|
project.fileTree(destinationDir).matching { include('**/*.java') }.each { File source ->
|
||||||
String path = destinationDir.toPath().relativize(source.toPath()).toString().replace(File.separator, '/')
|
String path = destinationDir.toPath().relativize(source.toPath()).toString().replace(File.separator, '/')
|
||||||
boolean overridden = adapterSourceRoots.any { File adapter ->
|
int origin = adapterSourceRoots.collect { File adapter ->
|
||||||
new File(adapter, "src/versions/${sourceMinecraftVersion}/test/java/${path}").isFile()
|
overlayOrigin(overlayDirectories(adapter, 'test/java'), path)
|
||||||
}
|
}.max()
|
||||||
if (!overridden) {
|
String content = source.getText('UTF-8')
|
||||||
String content = source.getText('UTF-8')
|
String rewritten = content
|
||||||
String rewritten = content
|
for (int index = origin + 1; index < testRules.size(); index++) {
|
||||||
|
Map<String, Object> replacements = testRules.get(index)
|
||||||
|
List<Map<String, String>> rules = (List<Map<String, String>>) (replacements.get('global') ?: [])
|
||||||
|
Map<String, List<Map<String, String>>> fileRules = (Map<String, List<Map<String, String>>>) (replacements.get('files') ?: [:])
|
||||||
for (Map<String, String> rule : rules + (fileRules.get(path) ?: [])) {
|
for (Map<String, String> rule : rules + (fileRules.get(path) ?: [])) {
|
||||||
rewritten = rewritten.replaceAll(rule.pattern, rule.replacement)
|
rewritten = rewritten.replaceAll(rule.pattern, rule.replacement)
|
||||||
}
|
}
|
||||||
if (content != rewritten) {
|
}
|
||||||
source.setText(rewritten, 'UTF-8')
|
if (content != rewritten) {
|
||||||
}
|
source.setText(rewritten, 'UTF-8')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
Configuration nativeMinecraftSources = configurations.create('nativeMinecraftSources') {
|
Configuration nativeMinecraftSources = configurations.create('nativeMinecraftSources') {
|
||||||
@@ -8,31 +9,42 @@ Configuration nativeMinecraftSources = configurations.create('nativeMinecraftSou
|
|||||||
|
|
||||||
String nativeSourceLoader = extensions.extraProperties.get('nativeSourceLoader')
|
String nativeSourceLoader = extensions.extraProperties.get('nativeSourceLoader')
|
||||||
String nativeSourceImplementation = 'minecraft26_2'
|
String nativeSourceImplementation = 'minecraft26_2'
|
||||||
String nativeSourceMinecraftVersion = providers.gradleProperty('minecraftVersion').getOrElse('26.3')
|
List<String> nativeSourceOverlays = (List<String>) irisModTarget.overlays
|
||||||
String versionPrefix = "versions/${nativeSourceMinecraftVersion}/"
|
List<String> versionPrefixes = nativeSourceOverlays.collect { String overlay -> "versions/${overlay}/".toString() }
|
||||||
extensions.extraProperties.set('nativeSourceImplementation', nativeSourceImplementation)
|
extensions.extraProperties.set('nativeSourceImplementation', nativeSourceImplementation)
|
||||||
dependencies.add(nativeMinecraftSources.name,
|
dependencies.add(nativeMinecraftSources.name,
|
||||||
"com.github.VolmitSoftware.VolmLib:native-${nativeSourceImplementation}-sources:master-SNAPSHOT")
|
"com.github.VolmitSoftware.VolmLib:native-${nativeSourceImplementation}-sources:master-SNAPSHOT")
|
||||||
|
|
||||||
Set<String> overrides = new HashSet<>()
|
List<Set<String>> overlayEntries = versionPrefixes.collect { String ignored -> new HashSet<String>() }
|
||||||
Map<String, Object> replacements = [:]
|
List<Map<String, Object>> overlayReplacements = versionPrefixes.collect { String ignored -> new HashMap<String, Object>() }
|
||||||
|
Closure<Integer> overlayOrigin = { String path ->
|
||||||
|
for (int index = overlayEntries.size() - 1; index >= 0; index--) {
|
||||||
|
if (overlayEntries.get(index).contains(path)) {
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
TaskProvider<Sync> unpackNativeMinecraftSources = tasks.register('unpackNativeMinecraftSources', Sync) {
|
TaskProvider<Sync> unpackNativeMinecraftSources = tasks.register('unpackNativeMinecraftSources', Sync) {
|
||||||
dependsOn(nativeMinecraftSources)
|
dependsOn(nativeMinecraftSources)
|
||||||
inputs.property('minecraftVersion', nativeSourceMinecraftVersion)
|
inputs.property('overlays', nativeSourceOverlays)
|
||||||
inputs.property('loader', nativeSourceLoader)
|
inputs.property('loader', nativeSourceLoader)
|
||||||
doFirst {
|
doFirst {
|
||||||
overrides.clear()
|
overlayEntries.each { Set<String> entries -> entries.clear() }
|
||||||
|
overlayReplacements.each { Map<String, Object> rules -> rules.clear() }
|
||||||
for (File artifact : nativeMinecraftSources) {
|
for (File artifact : nativeMinecraftSources) {
|
||||||
new ZipFile(artifact).withCloseable { ZipFile archive ->
|
new ZipFile(artifact).withCloseable { ZipFile archive ->
|
||||||
archive.entries().each { entry ->
|
versionPrefixes.eachWithIndex { String versionPrefix, int index ->
|
||||||
if (entry.name.startsWith(versionPrefix)) {
|
archive.entries().each { ZipEntry entry ->
|
||||||
overrides.add(entry.name.substring(versionPrefix.length()))
|
if (entry.name.startsWith(versionPrefix)) {
|
||||||
|
overlayEntries.get(index).add(entry.name.substring(versionPrefix.length()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
ZipEntry rules = archive.getEntry(versionPrefix + 'source-replacements.json')
|
||||||
java.util.zip.ZipEntry rules = archive.getEntry(versionPrefix + 'source-replacements.json')
|
if (rules != null) {
|
||||||
if (rules != null) {
|
archive.getInputStream(rules).withCloseable { InputStream stream ->
|
||||||
archive.getInputStream(rules).withCloseable { InputStream stream ->
|
overlayReplacements.get(index).putAll((Map<String, Object>) new JsonSlurper().parse(stream))
|
||||||
replacements = (Map<String, Object>) new JsonSlurper().parse(stream)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,32 +54,40 @@ TaskProvider<Sync> unpackNativeMinecraftSources = tasks.register('unpackNativeMi
|
|||||||
include('art/**', 'modded/**', "${nativeSourceLoader}/**",
|
include('art/**', 'modded/**', "${nativeSourceLoader}/**",
|
||||||
'resources/modded/**', "resources/${nativeSourceLoader}/**")
|
'resources/modded/**', "resources/${nativeSourceLoader}/**")
|
||||||
eachFile { FileCopyDetails source ->
|
eachFile { FileCopyDetails source ->
|
||||||
if (overrides.contains(source.path)) {
|
if (overlayOrigin(source.path) >= 0) {
|
||||||
source.exclude()
|
source.exclude()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
from(provider { nativeMinecraftSources.collect { File artifact -> zipTree(artifact) } }) {
|
versionPrefixes.eachWithIndex { String versionPrefix, int index ->
|
||||||
include("${versionPrefix}art/**", "${versionPrefix}modded/**", "${versionPrefix}${nativeSourceLoader}/**",
|
from(provider { nativeMinecraftSources.collect { File artifact -> zipTree(artifact) } }) {
|
||||||
"${versionPrefix}resources/modded/**", "${versionPrefix}resources/${nativeSourceLoader}/**")
|
include("${versionPrefix}art/**", "${versionPrefix}modded/**", "${versionPrefix}${nativeSourceLoader}/**",
|
||||||
eachFile { FileCopyDetails source -> source.path = source.path.substring(versionPrefix.length()) }
|
"${versionPrefix}resources/modded/**", "${versionPrefix}resources/${nativeSourceLoader}/**")
|
||||||
|
eachFile { FileCopyDetails source ->
|
||||||
|
source.path = source.path.substring(versionPrefix.length())
|
||||||
|
if (overlayOrigin(source.path) != index) {
|
||||||
|
source.exclude()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
includeEmptyDirs = false
|
includeEmptyDirs = false
|
||||||
into(layout.buildDirectory.dir('generated/sources/native-minecraft'))
|
into(layout.buildDirectory.dir('generated/sources/native-minecraft'))
|
||||||
doLast {
|
doLast {
|
||||||
List<Map<String, String>> rules = (List<Map<String, String>>) (replacements.get('global') ?: [])
|
|
||||||
Map<String, List<Map<String, String>>> fileRules = (Map<String, List<Map<String, String>>>) (replacements.get('files') ?: [:])
|
|
||||||
project.fileTree(destinationDir).matching { include('**/*.java') }.each { File source ->
|
project.fileTree(destinationDir).matching { include('**/*.java') }.each { File source ->
|
||||||
String path = destinationDir.toPath().relativize(source.toPath()).toString().replace(File.separator, '/')
|
String path = destinationDir.toPath().relativize(source.toPath()).toString().replace(File.separator, '/')
|
||||||
if (!overrides.contains(path)) {
|
String content = source.getText('UTF-8')
|
||||||
String content = source.getText('UTF-8')
|
String rewritten = content
|
||||||
String rewritten = content
|
for (int index = overlayOrigin(path) + 1; index < overlayReplacements.size(); index++) {
|
||||||
|
Map<String, Object> replacements = overlayReplacements.get(index)
|
||||||
|
List<Map<String, String>> rules = (List<Map<String, String>>) (replacements.get('global') ?: [])
|
||||||
|
Map<String, List<Map<String, String>>> fileRules = (Map<String, List<Map<String, String>>>) (replacements.get('files') ?: [:])
|
||||||
for (Map<String, String> rule : rules + (fileRules.get(path) ?: [])) {
|
for (Map<String, String> rule : rules + (fileRules.get(path) ?: [])) {
|
||||||
rewritten = rewritten.replaceAll(rule.pattern, rule.replacement)
|
rewritten = rewritten.replaceAll(rule.pattern, rule.replacement)
|
||||||
}
|
}
|
||||||
if (content != rewritten) {
|
}
|
||||||
source.setText(rewritten, 'UTF-8')
|
if (content != rewritten) {
|
||||||
}
|
source.setText(rewritten, 'UTF-8')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user