-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
706ae85
commit 1acbf17
Showing
107 changed files
with
650 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,32 @@ | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
jcenter() | ||
mavenCentral() | ||
maven { url "https://maven.minecraftforge.net/" } | ||
} | ||
dependencies { | ||
classpath 'net.minecraftforge.gradle:ForgeGradle:4.1.+' | ||
} | ||
} | ||
import groovy.json.JsonOutput | ||
|
||
plugins { | ||
id 'java' | ||
id 'maven-publish' | ||
id "net.covers1624.signing" version '1.1.4' | ||
id 'signing' | ||
id 'net.neoforged.gradle' version '[6.0.18,6.2)' | ||
} | ||
|
||
apply plugin: 'net.minecraftforge.gradle' | ||
|
||
group = "codechicken" | ||
group = "io.codechicken" | ||
archivesBaseName = "Translocators" | ||
|
||
java.toolchain.languageVersion = JavaLanguageVersion.of(8) | ||
|
||
sourceSets.main.resources.srcDirs += "src/main/generated" | ||
|
||
file('build.properties').withReader { | ||
def prop = new Properties() | ||
prop.load(it) | ||
project.ext.config = new ConfigSlurper().parse prop | ||
} | ||
|
||
def signProps = [:] | ||
if (System.getenv("KEY_STORE")) { | ||
println "Using Env variables for jar signing." | ||
signProps['keyStore'] = System.getenv("KEY_STORE") | ||
file(System.getenv("KEY_STORE_PROPS")).withReader { | ||
def props = new Properties() | ||
props.load(it) | ||
signProps.putAll(props) | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
} | ||
} else if (project.hasProperty('keyStore')) { | ||
println "Using Project properties for jar signing." | ||
signProps['keyStore'] = project.getProperty('keyStore') | ||
signProps['storePass'] = project.getProperty('keyStorePass') | ||
signProps['alias'] = project.getProperty('keyStoreAlias') | ||
signProps['keyPass'] = project.getProperty('keyStoreKeyPass') | ||
} else { | ||
println 'No signing secrets found, build will not be signed.' | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
|
||
config.mod_version = "${config.mod_version}." + (System.getenv("BUILD_NUMBER") ?: "1") | ||
version = "${config.mc_version}-${config.mod_version}" | ||
println "Starting build of ${archivesBaseName}, Version: ${config.mod_version}" | ||
println "Using Forge: ${config.forge_version}, for Minecraft: ${config.mc_version}" | ||
sourceSets.main.resources.srcDirs += "src/main/generated" | ||
|
||
mod_version = "${mod_version}." + (System.getenv("BUILD_NUMBER") ?: "1") | ||
version = "${mc_version}-${mod_version}" | ||
println "Starting build of ${archivesBaseName}, Version: ${mod_version}" | ||
println "Using Forge: ${forge_version}, for Minecraft: ${mc_version}" | ||
|
||
minecraft { | ||
mappings channel: 'official', version: config.mc_version | ||
mappings channel: 'official', version: mc_version | ||
accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg") | ||
runs { | ||
client { | ||
|
@@ -79,52 +49,67 @@ minecraft { | |
repositories { | ||
mavenLocal() | ||
maven { url = "https://chickenbones.net/maven" } | ||
maven { url = "https://dvs1.progwml6.com/files/maven" } | ||
} | ||
|
||
dependencies { | ||
minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}" | ||
compile "codechicken:CodeChickenLib:${config.mc_version}-${config.ccl_version}:deobf" | ||
compile "codechicken:CBMultipart:${config.mc_version}-${config.cbmp_version}:deobf" | ||
minecraft "net.neoforged:forge:${mc_version}-${forge_version}" | ||
implementation fg.deobf("io.codechicken:CodeChickenLib:${mc_version}-${ccl_version}:universal") | ||
implementation fg.deobf("io.codechicken:CBMultipart:${mc_version}-${cbmp_version}:universal") | ||
} | ||
|
||
signing { | ||
if (!signProps.isEmpty()) { | ||
jars { | ||
sign jar | ||
after 'reobfJar' | ||
|
||
keyStore = signProps.keyStore | ||
alias = signProps.alias | ||
storePass = signProps.storePass | ||
keyPass = signProps.keyPass | ||
} | ||
def publishingMetadata = project.layout.buildDirectory.file("libs/$archivesBaseName-$version-publishing.json") | ||
def publishingMetadataTask = tasks.register("publishingMetadata") { | ||
outputs.file(publishingMetadata) | ||
doFirst { | ||
publishingMetadata.get().asFile.text = JsonOutput.prettyPrint(JsonOutput.toJson([ | ||
[ | ||
'displayName' : "Translocators ${version}", | ||
'mcVersion' : "${mc_version}", | ||
'version' : "${mod_version}", | ||
'classifier' : 'universal', | ||
'modLoader' : 'neoforge', | ||
'curseforgeId': '247695', | ||
'modrinthId' : 'WIxTuRkQ', | ||
'dependencies': [ | ||
[ | ||
'modId' : 'codechickenlib', | ||
'type' : 'required', | ||
'modrinthId' : '242818', | ||
'curseforgeId': '2gq0ALnz' | ||
], | ||
[ | ||
'modId' : 'cbmultipart', | ||
'type' : 'required', | ||
'modrinthId' : '258426', | ||
'curseforgeId': 'LmvnWWSV' | ||
] | ||
] | ||
] | ||
])) | ||
} | ||
} | ||
|
||
processResources { task -> | ||
inputs.property 'mod_version', config.mod_version | ||
inputs.property 'mc_version', config.mc_version | ||
inputs.property 'ccl_version', config.ccl_version | ||
inputs.property 'ccl_version_max', config.ccl_version_max | ||
inputs.property 'cbmp_version', config.cbmp_version | ||
inputs.property 'cbmp_version_max', config.cbmp_version_max | ||
|
||
from(sourceSets.main.resources.srcDirs) { spec -> | ||
spec.include 'META-INF/mods.toml' | ||
task.doFirst { | ||
spec.expand 'version': config.mod_version, | ||
'mc_version': config.mc_version, | ||
'forge_version': config.forge_version, | ||
'ccl_version_range': "[${resolve("CodeChickenLib")},${config.ccl_version_max})", | ||
'cbmp_version_range': "[${resolve("CBMultipart")},${config.cbmp_version_max})" | ||
} | ||
inputs.property 'mod_version', mod_version | ||
inputs.property 'mc_version', mc_version | ||
inputs.property 'ccl_version', ccl_version | ||
inputs.property 'ccl_version_max', ccl_version_max | ||
inputs.property 'cbmp_version', cbmp_version | ||
inputs.property 'cbmp_version_max', cbmp_version_max | ||
|
||
filesMatching('META-INF/mods.toml') { | ||
expand 'file': ['jarVersion': mod_version], | ||
'mc_version': mc_version, | ||
'forge_version': forge_version, | ||
'lang_version': forge_version.split('\\.')[0], | ||
'ccl_version_range': "[${ccl_version.replace(".+", "")},${ccl_version_max})", | ||
'cbmp_version_range': "[${cbmp_version.replace(".+", "")},${cbmp_version_max})" | ||
} | ||
} | ||
|
||
jar { | ||
finalizedBy 'reobfJar' | ||
classifier = 'universal' | ||
archiveClassifier = 'universal' | ||
manifest { | ||
attributes 'Specification-Title': archivesBaseName | ||
attributes 'Specification-Vendor': 'covers1624' | ||
|
@@ -137,11 +122,37 @@ jar { | |
from file("LICENSE.txt") | ||
} | ||
|
||
task srcJar(type: Jar) { | ||
build.dependsOn it | ||
from sourceSets.main.allSource | ||
classifier = 'sources' | ||
from file("LICENSE.txt") | ||
tasks.register("signJar") { | ||
dependsOn("jar") | ||
dependsOn("reobfJar") | ||
|
||
doFirst { | ||
def args = [:] | ||
args['jar'] = jar.archiveFile.get().asFile | ||
if (System.getenv("KEY_STORE")) { | ||
args['keyStore'] = System.getenv("KEY_STORE") | ||
file(System.getenv("KEY_STORE_PROPS")).withReader { | ||
def props = new Properties() | ||
props.load(it) | ||
args.putAll(props) | ||
} | ||
} else if (project.hasProperty('keyStore')) { | ||
args['keyStore'] = project.getProperty('keyStore') | ||
args['alias'] = project.getProperty('keyStoreAlias') | ||
args['storePass'] = project.getProperty('keyStorePass') | ||
args['keyPass'] = project.getProperty('keyStoreKeyPass') | ||
} else { | ||
println "No signing properties." | ||
state.setOutcome(org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE) | ||
didWork = false | ||
return | ||
} | ||
project.ant.invokeMethod('signjar', args) | ||
} | ||
} | ||
|
||
javadoc { | ||
options.addBooleanOption("Xdoclint:none", true) | ||
} | ||
|
||
publishing { | ||
|
@@ -162,27 +173,31 @@ publishing { | |
artifactId project.archivesBaseName | ||
version project.version | ||
artifact jar | ||
artifact srcJar | ||
artifact sourcesJar | ||
artifact javadocJar | ||
artifact(publishingMetadata) { | ||
builtBy publishingMetadataTask | ||
classifier 'publishing' | ||
} | ||
|
||
pom { | ||
name = archivesBaseName | ||
description = archivesBaseName | ||
//The publish plugin doesnt like GString's here apparently.. | ||
url = "https://github.com/TheCBProject/${archivesBaseName}".toString() | ||
url = "https://github.com/TheCBProject/${archivesBaseName}" | ||
scm { | ||
url = "https://github.com/TheCBProject/${archivesBaseName}".toString() | ||
connection = "scm:git:git://github.com/TheCBProject/${archivesBaseName}.git".toString() | ||
connection = "scm:git:[email protected]:TheCBProject/${archivesBaseName}.git".toString() | ||
url = "https://github.com/TheCBProject/${archivesBaseName}" | ||
connection = "scm:git:git://github.com/TheCBProject/${archivesBaseName}.git" | ||
connection = "scm:git:[email protected]:TheCBProject/${archivesBaseName}.git" | ||
} | ||
|
||
issueManagement { | ||
system = 'github' | ||
url = "https://github.com/TheCBProject/${archivesBaseName}/issues".toString() | ||
url = "https://github.com/TheCBProject/${archivesBaseName}/issues" | ||
} | ||
licenses { | ||
license { | ||
name = "MIT" | ||
url = "https://raw.githubusercontent.com/TheCBProject/${archivesBaseName}/master/LICENSE.txt".toString() | ||
url = "https://raw.githubusercontent.com/TheCBProject/${archivesBaseName}/master/LICENSE.txt" | ||
distribution = 'repo' | ||
} | ||
} | ||
|
@@ -203,32 +218,19 @@ publishing { | |
} | ||
} | ||
|
||
/** | ||
* Polls the 'compile' configuration for a dependency with the given module name | ||
* and resolves, and returns its version. E.g: '1.2.+' will resolve to '1.2.3.4' | ||
* | ||
* @param module The module to search for. | ||
* @param chop If the string should be chopped on the last '-' in its string. | ||
* @param configuration The name of the configuration to search. | ||
* @param errorMissing If an error should be thrown if it can't be found. | ||
* @return The version string, '0' if 'errorMissing' is false and nothing was found. | ||
*/ | ||
def resolve(module, chop = true, configuration = 'compile', errorMissing = true) { | ||
//Copy and lenient resolve the configuration, Forge cant be resolved at this time so lenient is required. | ||
def filtered = configurations.getByName(configuration).copy().incoming.artifactView({ it.lenient = true }).artifacts | ||
.findAll { it.id.componentIdentifier.module == module } | ||
.collect { it.id.componentIdentifier.version } | ||
if (filtered.size() > 1) { | ||
println "WARNING: Found ${filtered.size()} Dependencies with ModuleName '${module}' in configuration '${configuration.name}'" | ||
} | ||
if (errorMissing && filtered.isEmpty()) { | ||
throw new RuntimeException("Failed resolve dependency version for '${module}'") | ||
} | ||
if (filtered.isEmpty()) return "0" | ||
def version = filtered.first() as String | ||
if (chop) { | ||
def idx = version.lastIndexOf('-') | ||
return version.substring(idx + 1) | ||
signing { | ||
if (System.getenv('GPG_PRIVATE_KEY')) { | ||
useInMemoryPgpKeys( | ||
new File(System.getenv('GPG_PRIVATE_KEY')).text, | ||
System.getenv('GPG_PRIVATE_KEY_PASS') | ||
) | ||
} else if (project.hasProperty('gpgPrivateKey')) { | ||
useInMemoryPgpKeys( | ||
new File(project.getProperty('gpgPrivateKey')).text, | ||
project.getProperty('gpgPrivateKeyPass') | ||
) | ||
} else { | ||
return | ||
} | ||
return version | ||
sign publishing.publications.Translocators | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mc_version=1.20.1 | ||
forge_version=47.1.65 | ||
ccl_version=4.4.0.+ | ||
ccl_version_max=5.0.0 | ||
mod_version=2.6.0 | ||
cbmp_version=3.3.0.+ | ||
cbmp_version_max=4.0.0 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.