Merge overhaul branch to be upstream (#24)
* 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>
This commit is contained in:
parent
7db468db1e
commit
c82fcee8aa
16 changed files with 730 additions and 133 deletions
62
gradle/scripts/dependencies.gradle
Normal file
62
gradle/scripts/dependencies.gradle
Normal file
|
@ -0,0 +1,62 @@
|
|||
apply from: 'gradle/scripts/helpers.gradle'
|
||||
|
||||
repositories {
|
||||
// Other repositories described by default:
|
||||
// CleanroomMC: https://maven.cleanroommc.com
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name 'CurseMaven'
|
||||
url 'https://cursemaven.com'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup 'curse.maven'
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name 'Modrinth'
|
||||
url 'https://api.modrinth.com/maven'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup 'maven.modrinth'
|
||||
}
|
||||
}
|
||||
mavenLocal() // Must be last for caching to work
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Example - Dependency descriptor:
|
||||
// 'com.google.code.gson:gson:2.8.6' << group: com.google.code.gson, name:gson, version:2.8.6
|
||||
// 'group:name:version:classifier' where classifier is optional
|
||||
|
||||
// Example - Deobfuscating dependencies:
|
||||
// rfg.deobf('curse.maven:had-enough-items-557549:4543375')
|
||||
// By wrapping a dependency descriptor in rfg.deobf() method call, the dependency is queued for deobfuscation
|
||||
// When deobfuscating, RFG respects the mapping_channel + mapping_version stated in gradle.properties
|
||||
|
||||
// Example - CurseMaven dependencies:
|
||||
// 'curse.maven:had-enough-items-557549:4543375' << had-enough-items = project slug, 557549 = project id, 4543375 = file id
|
||||
// Full documentation: https://cursemaven.com/
|
||||
|
||||
// Example - Modrinth dependencies:
|
||||
// 'maven.modrinth:jei:4.16.1.1000' << jei = project name, 4.16.1.1000 = file version
|
||||
// Full documentation: https://docs.modrinth.com/docs/tutorials/maven/
|
||||
|
||||
// Common dependency types (configuration):
|
||||
// implementation = dependency available at both compile time and runtime
|
||||
// runtimeOnly = runtime dependency
|
||||
// compileOnly = compile time dependency
|
||||
// annotationProcessor = annotation processing dependencies
|
||||
|
||||
// Transitive dependencies:
|
||||
// (Dependencies that your dependency depends on)
|
||||
// If you wish to exclude transitive dependencies in the described dependencies
|
||||
// Use a closure as such:
|
||||
// implementation ('com.google.code.gson:gson:2.8.6') {
|
||||
// transitive = false
|
||||
// }
|
||||
}
|
5
gradle/scripts/extra.gradle
Normal file
5
gradle/scripts/extra.gradle
Normal file
|
@ -0,0 +1,5 @@
|
|||
// You may write any gradle buildscript component in this file
|
||||
// This file is automatically applied after build.gradle + dependencies.gradle is ran
|
||||
|
||||
// If you wish to use the default helper methods, uncomment the line below
|
||||
// apply from: 'gradle/scripts/helpers.gradle'
|
96
gradle/scripts/helpers.gradle
Normal file
96
gradle/scripts/helpers.gradle
Normal file
|
@ -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!")
|
||||
}
|
||||
}
|
107
gradle/scripts/publishing.gradle
Normal file
107
gradle/scripts/publishing.gradle
Normal file
|
@ -0,0 +1,107 @@
|
|||
apply from: 'gradle/scripts/helpers.gradle'
|
||||
|
||||
setDefaultProperty('publish_to_maven', true, false)
|
||||
setDefaultProperty('publish_to_curseforge', true, false)
|
||||
setDefaultProperty('publish_to_modrinth', true, false)
|
||||
|
||||
if (propertyBool('publish_to_maven')) {
|
||||
assertProperty('maven_name')
|
||||
assertProperty('maven_url')
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name propertyString('maven_name').replaceAll("\\s", "")
|
||||
url propertyString('maven_url')
|
||||
credentials(PasswordCredentials)
|
||||
}
|
||||
}
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java // Publish with standard artifacts
|
||||
setGroupId(propertyString('root_package'))// Publish with root package as maven group
|
||||
setArtifactId(propertyString('mod_id')) // Publish artifacts with mod id as the artifact id
|
||||
|
||||
// Custom artifact:
|
||||
// If you want to publish a different artifact to the one outputted when building normally
|
||||
// Create a different gradle task (Jar task), in extra.gradle
|
||||
// Remove the 'from components.java' line above
|
||||
// Add this line (change the task name):
|
||||
// artifacts task_name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Documentation here: https://github.com/matthewprenger/CurseGradle/wiki/
|
||||
if (propertyBool('publish_to_curseforge')) {
|
||||
apply plugin: 'com.matthewprenger.cursegradle'
|
||||
assertProperty('curseforge_project_id')
|
||||
assertProperty('release_type')
|
||||
setDefaultProperty('curseforge_debug', false, false)
|
||||
curseforge {
|
||||
apiKey = System.getenv('CURSEFORGE_TOKEN') == null ? "" : System.getenv('CURSEFORGE_TOKEN')
|
||||
// noinspection GroovyAssignabilityCheck
|
||||
project {
|
||||
id = propertyString('curseforge_project_id')
|
||||
addGameVersion 'Java 8'
|
||||
addGameVersion 'Forge'
|
||||
addGameVersion '1.12.2'
|
||||
releaseType = propertyString('release_type')
|
||||
if (!propertyBool('publish_with_changelog')) {
|
||||
changelog = parserChangelog()
|
||||
changelogType = 'markdown'
|
||||
}
|
||||
mainArtifact tasks.reobfJar, {
|
||||
displayName = "${propertyString('mod_name')} ${propertyString('mod_version')}"
|
||||
if (propertyBool('use_mixins')) {
|
||||
relations {
|
||||
requiredDependency 'mixin-booter'
|
||||
}
|
||||
}
|
||||
if (propertyBool('use_asset_mover')) {
|
||||
relations {
|
||||
requiredDependency 'assetmover'
|
||||
}
|
||||
}
|
||||
}
|
||||
options {
|
||||
debug = propertyBool('curseforge_debug')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Documentation here: https://github.com/modrinth/minotaur
|
||||
if (propertyBool('publish_to_modrinth')) {
|
||||
apply plugin: 'com.modrinth.minotaur'
|
||||
assertProperty('modrinth_project_id')
|
||||
assertProperty('release_type')
|
||||
setDefaultProperty('modrinth_debug', false, false)
|
||||
modrinth {
|
||||
token = System.getenv('MODRINTH_TOKEN') ? "" : System.getenv('MODRINTH_TOKEN')
|
||||
projectId = propertyString('modrinth_project_id')
|
||||
versionNumber = propertyString('mod_version')
|
||||
versionType = propertyString('release_type')
|
||||
uploadFile = tasks.reobfJar
|
||||
gameVersions = ['1.12.2']
|
||||
loaders = ['forge']
|
||||
debugMode = propertyBool('modrinth_debug')
|
||||
if (propertyBool('use_mixins') || propertyBool('use_asset_mover')) {
|
||||
dependencies {
|
||||
if (propertyBool('use_mixins')) {
|
||||
required.project 'mixinbooter'
|
||||
}
|
||||
if (propertyBool('use_asset_mover')) {
|
||||
required.project 'assetmover'
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!propertyBool('publish_with_changelog')) {
|
||||
changelog = parserChangelog()
|
||||
}
|
||||
if (propertyBool('modrinth_sync_readme')) {
|
||||
syncBodyFrom = file('README.md').text
|
||||
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue