mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-11 19:14:11 +00:00
- The build resolves VolmLib master-SNAPSHOT when no sibling checkout is substituted - The native runtime manifest, roots and keep rules come from the embedded natives - The packed jar natives are verified against the embedded provider shas - Every jar carries META-INF/volmit/volmlib.properties - The build logs the resolved VolmLib once - publishedNativeRuntime, the loader coordinate flags, mavenLocal and publish-volmlib are gone
151 lines
6.9 KiB
Groovy
151 lines
6.9 KiB
Groovy
/*
|
|
* Iris is a World Generator for Minecraft Servers
|
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/*
|
|
* Shared VolmLib source resolution, applied by every Iris settings file:
|
|
*
|
|
* root settings.gradle
|
|
* adapters/fabric settings.gradle
|
|
* adapters/forge settings.gradle
|
|
* adapters/neoforge settings.gradle
|
|
*
|
|
* Apply with an explicit File so the path never depends on the invocation directory:
|
|
*
|
|
* apply from: new File(settingsDir, 'gradle/volmlib-resolution.settings.gradle') // root
|
|
* apply from: new File(settingsDir, '../../gradle/volmlib-resolution.settings.gradle').canonicalFile // adapters
|
|
*
|
|
* `settingsDir` resolves against the *including* build, so the upward search for a sibling
|
|
* VolmLib checkout works from the repo root and from a nested adapter build alike.
|
|
*
|
|
* Behaviour:
|
|
* -PuseLocalVolmLib=false disables source substitution (CI uses this).
|
|
* -PlocalVolmLibDirectory=<path> explicit VolmLib checkout (relative paths resolve
|
|
* against the including build's settings directory).
|
|
* VOLMLIB_DIR=<path> same, via environment.
|
|
* otherwise walk up from settingsDir looking for a `VolmLib` directory
|
|
* that contains a settings script.
|
|
*
|
|
* When nothing is found, or substitution is disabled, every VolmLib coordinate resolves the published
|
|
* master-SNAPSHOT from JitPack instead, re-checked on every build like the rest of the plugin fleet.
|
|
*
|
|
* The outcome is logged once per top-level build and handed to the build scripts through `gradle`
|
|
* extra properties: `volmLibDirectory` (the substituted checkout, or null) and `volmLibStamp` (the
|
|
* content of META-INF/volmit/volmlib.properties in every shipped jar).
|
|
*/
|
|
|
|
import org.gradle.api.artifacts.Configuration
|
|
import org.gradle.process.ExecOutput
|
|
|
|
import java.io.File
|
|
|
|
boolean irisHasVolmLibSettings(File directory) {
|
|
if (directory == null) {
|
|
return false
|
|
}
|
|
|
|
new File(directory, 'settings.gradle.kts').exists() || new File(directory, 'settings.gradle').exists()
|
|
}
|
|
|
|
File irisResolveLocalVolmLibDirectory() {
|
|
String configuredPath = providers.gradleProperty('localVolmLibDirectory')
|
|
.orElse(providers.environmentVariable('VOLMLIB_DIR'))
|
|
.orNull
|
|
if (configuredPath != null && !configuredPath.isBlank()) {
|
|
File configuredDirectory = new File(configuredPath)
|
|
if (!configuredDirectory.isAbsolute()) {
|
|
configuredDirectory = new File(settingsDir, configuredPath)
|
|
}
|
|
if (irisHasVolmLibSettings(configuredDirectory)) {
|
|
return configuredDirectory
|
|
}
|
|
}
|
|
|
|
File currentDirectory = settingsDir
|
|
while (currentDirectory != null) {
|
|
File candidate = new File(currentDirectory, 'VolmLib')
|
|
if (irisHasVolmLibSettings(candidate)) {
|
|
return candidate
|
|
}
|
|
|
|
currentDirectory = currentDirectory.parentFile
|
|
}
|
|
|
|
null
|
|
}
|
|
|
|
boolean irisUseLocalVolmLib = providers.gradleProperty('useLocalVolmLib')
|
|
.orElse('true')
|
|
.map { String value -> value.equalsIgnoreCase('true') }
|
|
.get()
|
|
File irisLocalVolmLibDirectory = irisUseLocalVolmLib ? irisResolveLocalVolmLibDirectory() : null
|
|
|
|
String irisGit(File directory, String... arguments) {
|
|
try {
|
|
ExecOutput result = providers.exec {
|
|
commandLine(['git', '-C', directory.absolutePath] + arguments.toList())
|
|
ignoreExitValue = true
|
|
}
|
|
return result.result.get().exitValue == 0 ? result.standardOutput.asText.get().trim() : null
|
|
} catch (Exception ignored) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
Map<String, String> irisVolmLibStamp
|
|
String irisVolmLibDescription
|
|
if (irisLocalVolmLibDirectory == null) {
|
|
irisVolmLibStamp = [source: 'published master-SNAPSHOT']
|
|
irisVolmLibDescription = 'published master-SNAPSHOT'
|
|
gradle.allprojects { Project project ->
|
|
project.buildscript.configurations.configureEach { Configuration configuration ->
|
|
configuration.resolutionStrategy.cacheChangingModulesFor(0, 'seconds')
|
|
}
|
|
project.configurations.configureEach { Configuration configuration ->
|
|
configuration.resolutionStrategy.cacheChangingModulesFor(0, 'seconds')
|
|
}
|
|
}
|
|
} else {
|
|
String commit = irisGit(irisLocalVolmLibDirectory, 'rev-parse', 'HEAD')
|
|
String status = commit == null ? null : irisGit(irisLocalVolmLibDirectory, 'status', '--porcelain')
|
|
String dirty = status == null ? 'unknown' : String.valueOf(!status.isEmpty())
|
|
irisVolmLibStamp = [source: 'local', commit: commit ?: 'unknown', dirty: dirty]
|
|
irisVolmLibDescription = "${irisLocalVolmLibDirectory.canonicalPath} @ ${commit == null ? 'unknown' : commit.take(7)}${dirty == 'true' ? '+dirty' : ''}"
|
|
}
|
|
gradle.extensions.extraProperties.set('volmLibDirectory', irisLocalVolmLibDirectory)
|
|
gradle.extensions.extraProperties.set('volmLibStamp', irisVolmLibStamp)
|
|
if (gradle.parent == null) {
|
|
logger.lifecycle("VolmLib: ${irisVolmLibDescription}")
|
|
}
|
|
|
|
if (irisLocalVolmLibDirectory != null) {
|
|
includeBuild(irisLocalVolmLibDirectory) {
|
|
dependencySubstitution {
|
|
substitute(module('com.github.VolmitSoftware:VolmLib')).using(project(':shared'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:shared')).using(project(':shared'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:packaging')).using(project(':packaging'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:volmlib-shared')).using(project(':shared'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:native-api')).using(project(':native-api'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:native-common')).using(project(':native-common'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:native-terrain-api')).using(project(':native-terrain-api'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:native-v26_2_R1')).using(project(':native:v26_2_R1'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:native-v26_3_R1')).using(project(':native:v26_3_R1'))
|
|
substitute(module('com.github.VolmitSoftware.VolmLib:native-minecraft26_2-sources')).using(project(':native-minecraft26_2-sources'))
|
|
}
|
|
}
|
|
}
|