1.12.2 buildscript
This commit is contained in:
@@ -0,0 +1,233 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'com.gradleup.shadow' version '9.2.2'
|
||||
id 'xyz.wagyourtail.unimined' version '1.4.9-kappa'
|
||||
id 'net.kyori.blossom' version '2.1.0'
|
||||
}
|
||||
|
||||
apply from: 'gradle/scripts/helpers.gradle'
|
||||
|
||||
// Early Assertions
|
||||
assertProperty 'mod_version'
|
||||
assertProperty 'maven_group'
|
||||
assertProperty 'mod_id'
|
||||
assertProperty 'mod_name'
|
||||
|
||||
version = propertyString('mod_version')
|
||||
group = propertyString('maven_group')
|
||||
|
||||
//base {
|
||||
// archivesName.set(propertyString('mod_id'))
|
||||
//}
|
||||
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
//propertyBool('generate_sources_jar')
|
||||
if (true) {
|
||||
withSourcesJar()
|
||||
}
|
||||
//propertyBool('generate_javadocs_jar')
|
||||
if (false) {
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
embed
|
||||
contain
|
||||
implementation.extendsFrom(embed)
|
||||
implementation.extendsFrom(contain)
|
||||
modCompileOnly
|
||||
compileOnly.extendsFrom(modCompileOnly)
|
||||
modRuntimeOnly
|
||||
runtimeOnly.extendsFrom(modRuntimeOnly)
|
||||
}
|
||||
|
||||
unimined.minecraft {
|
||||
version "1.12.2"
|
||||
|
||||
mappings {
|
||||
mcp("stable", "39-1.12")
|
||||
}
|
||||
|
||||
cleanroom {
|
||||
loader "0.3.31-alpha"
|
||||
runs.auth.username = "Developer"
|
||||
runs.all {
|
||||
systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json")
|
||||
def extraArgs = ''
|
||||
if (extraArgs != null && !extraArgs.trim().isEmpty()) {
|
||||
jvmArgs += extraArgs.split { "\\s+" }.toList()
|
||||
}
|
||||
if (propertyBool('enable_foundation_debug')) {
|
||||
systemProperty("foundation.dump", "true")
|
||||
systemProperty("foundation.verbose", "true")
|
||||
}
|
||||
//propertyBool('is_coremod')
|
||||
if (true) {
|
||||
//coremod_plugin_class_name
|
||||
systemProperty("fml.coreMods.load", propertyString('com.seibel.distanthorizons.forge.DistantHorizonsLoadingPlugin'))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
defaultRemapJar = false
|
||||
|
||||
if (propertyBool('enable_shadow')) {
|
||||
remap(tasks.shadowJar) {
|
||||
mixinRemap {
|
||||
enableBaseMixin()
|
||||
enableMixinExtra()
|
||||
disableRefmap()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
remap(tasks.jar) {
|
||||
mixinRemap {
|
||||
enableBaseMixin()
|
||||
enableMixinExtra()
|
||||
disableRefmap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mods {
|
||||
remap(configurations.modCompileOnly)
|
||||
remap(configurations.modRuntimeOnly)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
//propertyBool('enable_junit_testing')
|
||||
if (true) {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
inputs.property 'mod_id', propertyString('mod_id')
|
||||
inputs.property 'mod_name', propertyString('mod_name')
|
||||
inputs.property 'mod_version', propertyString('mod_version')
|
||||
inputs.property 'mod_description', propertyString('mod_description')
|
||||
inputs.property 'mod_authors', "${propertyStringList('mod_authors', ',').join(', ')}"
|
||||
inputs.property 'mod_credits', propertyString('mod_credits')
|
||||
inputs.property 'mod_url', propertyString('mod_url')
|
||||
inputs.property 'mod_update_json', propertyString('mod_update_json')
|
||||
inputs.property 'mod_logo_path', propertyString('mod_logo_path')
|
||||
|
||||
def filterList = ['mcmod.info', 'pack.mcmeta']
|
||||
|
||||
filesMatching(filterList) { fcd ->
|
||||
fcd.expand(
|
||||
'mod_id': propertyString('mod_id'),
|
||||
'mod_name': propertyString('mod_name'),
|
||||
'mod_version': propertyString('mod_version'),
|
||||
'mod_description': propertyString('mod_description'),
|
||||
'mod_authors': "${propertyStringList('mod_authors', ',').join(', ')}",
|
||||
'mod_credits': propertyString('mod_credits'),
|
||||
'mod_url': propertyString('mod_url'),
|
||||
'mod_update_json': propertyString('mod_update_json'),
|
||||
'mod_logo_path': propertyString('mod_logo_path'),
|
||||
)
|
||||
}
|
||||
|
||||
rename '(.+_at.cfg)', 'META-INF/$1'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property('mod_id', propertyString('mod_id'))
|
||||
property('mod_name', propertyString('mod_name'))
|
||||
property('mod_version', propertyString('mod_version'))
|
||||
property('package', "${maven_group}.${mod_id}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!propertyBool('enable_shadow')) {
|
||||
shadowJar.enabled = false
|
||||
}
|
||||
|
||||
jar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
if (configurations.contain.size() > 0) {
|
||||
into('/') {
|
||||
from configurations.contain
|
||||
}
|
||||
}
|
||||
doFirst {
|
||||
manifest {
|
||||
def attribute_map = [:]
|
||||
attribute_map['ModType'] = "CRL"
|
||||
attribute_map['MixinConfigs'] = "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json"
|
||||
if (configurations.contain.size() > 0) {
|
||||
attribute_map['ContainedDeps'] = configurations.contain.collect { it.name }.join(' ')
|
||||
attribute_map['NonModDeps'] = true
|
||||
}
|
||||
//propertyBool('is_coremod')
|
||||
if (true) {
|
||||
//coremod_plugin_class_name
|
||||
attribute_map['FMLCorePlugin'] = propertyString('com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin')
|
||||
//coremod_includes_mod
|
||||
if (true) {
|
||||
attribute_map['FMLCorePluginContainsFMLMod'] = true
|
||||
}
|
||||
}
|
||||
if (propertyBool('use_access_transformer')) {
|
||||
attribute_map['FMLAT'] = propertyString('access_transformer_locations')
|
||||
}
|
||||
attributes(attribute_map)
|
||||
}
|
||||
}
|
||||
if (propertyBool('enable_shadow')) {
|
||||
finalizedBy(tasks.named("remapShadowJar"))
|
||||
} else {
|
||||
finalizedBy(tasks.named("remapJar"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadow]
|
||||
archiveClassifier = "shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
doFirst {
|
||||
logging.captureStandardOutput LogLevel.INFO
|
||||
}
|
||||
doLast {
|
||||
logging.captureStandardOutput LogLevel.QUIET
|
||||
}
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
javaLauncher.set(javaToolchains.launcherFor {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
})
|
||||
if (propertyBool('show_testing_output')) {
|
||||
testLogging {
|
||||
showStandardStreams = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
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!")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user