-
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
45e61f7
commit 4aa48b8
Showing
3 changed files
with
113 additions
and
76 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,49 +1,32 @@ | ||
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)' | ||
} | ||
|
||
java.toolchain.languageVersion = JavaLanguageVersion.of(17) | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
} | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
|
||
group = "codechicken" | ||
group = "io.codechicken" | ||
archivesBaseName = "ChickenChunks" | ||
|
||
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) | ||
} | ||
} 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.' | ||
} | ||
|
||
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}, with Mappings: ${config.mappings}" | ||
mod_version = "${mod_version}." + (System.getenv("BUILD_NUMBER") ?: "1") | ||
version = "${mc_version}-${mod_version}" | ||
println "Starting build of ${archivesBaseName}, Version: ${mod_version}" | ||
println "Using NeoForge: ${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 { | ||
|
@@ -68,35 +51,47 @@ repositories { | |
} | ||
|
||
dependencies { | ||
minecraft "net.neoforged:forge:${config.mc_version}-${config.forge_version}" | ||
implementation fg.deobf("codechicken:CodeChickenLib:${config.mc_version}-${config.ccl_version}:universal") | ||
} | ||
|
||
signing { | ||
if (!signProps.isEmpty()) { | ||
jars { | ||
sign jar | ||
after 'reobfJar' | ||
|
||
keyStore = signProps.keyStore | ||
alias = signProps.alias | ||
storePass = signProps.storePass | ||
keyPass = signProps.keyPass | ||
} | ||
} | ||
minecraft "net.neoforged:forge:${mc_version}-${forge_version}" | ||
implementation fg.deobf("io.codechicken:CodeChickenLib:${mc_version}-${ccl_version}:universal") | ||
} | ||
|
||
processResources { | ||
inputs.property 'mod_version', config.mod_version | ||
inputs.property 'mc_version', config.mc_version | ||
inputs.property 'ccl_version', config.ccl_version | ||
inputs.property 'mod_version', mod_version | ||
inputs.property 'mc_version', mc_version | ||
inputs.property 'ccl_version', ccl_version | ||
|
||
filesMatching('META-INF/mods.toml') { | ||
expand 'file': ['jarVersion': config.mod_version], | ||
'mc_version': config.mc_version, | ||
'forge_version': config.forge_version, | ||
'lang_version': config.forge_version.split('\\.')[0], | ||
'ccl_version_range': "[${config.ccl_version.replace(".+", "")},${config.ccl_version_max})" | ||
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})" | ||
} | ||
} | ||
|
||
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' : "Chicken Chunks ${version}", | ||
'mcVersion' : "${mc_version}", | ||
'version' : "${mod_version}", | ||
'classifier' : 'universal', | ||
'modLoader' : 'neoforge', | ||
'curseforgeId': '243883', | ||
'modrinthId' : '2JkvF271', | ||
'dependencies': [ | ||
[ | ||
'modId' : 'codechickenlib', | ||
'type' : 'required', | ||
'modrinthId' : '242818', | ||
'curseforgeId': '2gq0ALnz' | ||
] | ||
] | ||
] | ||
])) | ||
} | ||
} | ||
|
||
|
@@ -115,11 +110,37 @@ jar { | |
from file("LICENSE.txt") | ||
} | ||
|
||
task srcJar(type: Jar) { | ||
build.dependsOn it | ||
from sourceSets.main.allSource | ||
archiveClassifier = '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 { | ||
|
@@ -135,27 +156,31 @@ publishing { | |
} | ||
} | ||
publications { | ||
EnderStorage(MavenPublication) { | ||
ChickenChunks(MavenPublication) { | ||
groupId project.group | ||
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 { | ||
|
@@ -180,3 +205,20 @@ publishing { | |
} | ||
} | ||
} | ||
|
||
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 | ||
} | ||
sign publishing.publications.ChickenChunks | ||
} |
File renamed without changes.