c82fcee8aa
* Debug mode for publishing artifacts * Jabel * Generation of mod meta, pack meta and mixin jsons * Fixed runObfServer using 1.7's main class rather than 1.12's - Allows changing of source without it being regenerated in dev * ExampleMod + fixing tag collection * Template expanding for mcmod.info + pack.mcmeta + remove redundant tasks - Now supports arbitrary script blocks to retrieve value `${{ }}` from directly in gradle.properties * Deployment via tasks/actions + changelog support + script folder * Fixed mixin json generating condition * Fix ATs not being applied * Allow mixinbooter & configanytime to be prioritized in obf runs * Remove redundant coremod arg addition as manifest is read at runtime * Allow processResources to work correctly * refactor: make parser changelog as method instead of job * fix: ensure correct header parser for changelog (2to2 and 3to3) * fix: no env available due to Github don't automatic inject env value to GHA * refactor: standardize mod version with SemVer, remove unnecessary changelog block in `build.gradle` * refactor: mixin config template and generator, resource filter * Updated Gradle to 8.7 + RetroFuturaGradle to 1.3.35 * Update MixinBooter to 9.1 + provide wiki link Co-authored-by: Oganesson897 <101081378+Darknight123MC@users.noreply.github.com> Co-authored-by: Li <nhatlinh.l195@gmail.com> Co-authored-by: Li <li.hvktqs@gmail.com>
96 lines
3.1 KiB
Groovy
96 lines
3.1 KiB
Groovy
import groovy.text.SimpleTemplateEngine
|
|
import org.codehaus.groovy.runtime.MethodClosure
|
|
|
|
ext.propertyString = this.&propertyString as MethodClosure
|
|
ext.propertyBool = this.&propertyBool as MethodClosure
|
|
ext.propertyStringList = this.&propertyStringList as MethodClosure
|
|
ext.interpolate = this.&interpolate as MethodClosure
|
|
ext.assertProperty = this.&assertProperty as MethodClosure
|
|
ext.assertSubProperties = this.&assertSubProperties as MethodClosure
|
|
ext.setDefaultProperty = this.&setDefaultProperty as MethodClosure
|
|
ext.assertEnvironmentVariable = this.&assertEnvironmentVariable as MethodClosure
|
|
|
|
String propertyString(String key) {
|
|
return $property(key).toString()
|
|
}
|
|
|
|
boolean propertyBool(String key) {
|
|
return propertyString(key).toBoolean()
|
|
}
|
|
|
|
Collection<String> propertyStringList(String key) {
|
|
return propertyStringList(key, ' ')
|
|
}
|
|
|
|
Collection<String> propertyStringList(String key, String delimit) {
|
|
return propertyString(key).split(delimit).findAll { !it.isEmpty() }
|
|
}
|
|
|
|
private Object $property(String key) {
|
|
def value = project.findProperty(key)
|
|
if (value instanceof String) {
|
|
return interpolate(value)
|
|
}
|
|
return value
|
|
}
|
|
|
|
String interpolate(String value) {
|
|
if (value.startsWith('${{') && value.endsWith('}}')) {
|
|
value = value.substring(3, value.length() - 2)
|
|
Binding newBinding = new Binding(this.binding.getVariables())
|
|
newBinding.setProperty('it', this)
|
|
return new GroovyShell(this.getClass().getClassLoader(), newBinding).evaluate(value)
|
|
}
|
|
if (value.contains('${')) {
|
|
return new SimpleTemplateEngine().createTemplate(value).make(project.properties).toString()
|
|
}
|
|
return value
|
|
}
|
|
|
|
void assertProperty(String propertyName) {
|
|
def property = property(propertyName)
|
|
if (property == null) {
|
|
throw new GradleException("Property ${propertyName} is not defined!")
|
|
}
|
|
if (property.isEmpty()) {
|
|
throw new GradleException("Property ${propertyName} is empty!")
|
|
}
|
|
}
|
|
|
|
void assertSubProperties(String propertyName, String... subPropertyNames) {
|
|
assertProperty(propertyName)
|
|
if (propertyBool(propertyName)) {
|
|
for (String subPropertyName : subPropertyNames) {
|
|
assertProperty(subPropertyName)
|
|
}
|
|
}
|
|
}
|
|
|
|
void setDefaultProperty(String propertyName, boolean warn, defaultValue) {
|
|
def property = property(propertyName)
|
|
def exists = true
|
|
if (property == null) {
|
|
exists = false
|
|
if (warn) {
|
|
project.logger.log(LogLevel.WARN, "Property ${propertyName} is not defined!")
|
|
}
|
|
} else if (property.isEmpty()) {
|
|
exists = false
|
|
if (warn) {
|
|
project.logger.log(LogLevel.WARN, "Property ${propertyName} is empty!")
|
|
}
|
|
}
|
|
if (!exists) {
|
|
project.setProperty(propertyName, defaultValue.toString())
|
|
}
|
|
}
|
|
|
|
void assertEnvironmentVariable(String propertyName) {
|
|
def property = System.getenv(propertyName)
|
|
if (property == null) {
|
|
throw new GradleException("System Environment Variable $propertyName is not defined!")
|
|
}
|
|
if (property.isEmpty()) {
|
|
throw new GradleException("Property $propertyName is empty!")
|
|
}
|
|
}
|