Update loom + cleanup build.gradle
This commit is contained in:
parent
6a4116ed26
commit
e8bad0f009
1 changed files with 68 additions and 77 deletions
69
build.gradle
69
build.gradle
|
@ -11,10 +11,9 @@ plugins {
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'com.diffplug.spotless' version '6.12.0'
|
id 'com.diffplug.spotless' version '6.19.0'
|
||||||
id 'fabric-loom' version '1.2-SNAPSHOT'
|
id 'fabric-loom' version '1.3-SNAPSHOT'
|
||||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
||||||
id 'de.undercouch.download' version '4.1.1'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -82,7 +81,7 @@ allprojects {
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
register("maven", MavenPublication) {
|
||||||
groupId project.name
|
groupId project.name
|
||||||
artifactId project.archivesBaseName + "-" + getBranch()
|
artifactId project.archivesBaseName + "-" + getBranch()
|
||||||
version project.version
|
version project.version
|
||||||
|
@ -269,12 +268,12 @@ jar {
|
||||||
dependsOn 'runDatagen'
|
dependsOn 'runDatagen'
|
||||||
}
|
}
|
||||||
|
|
||||||
task crowdinExport() {
|
tasks.register('crowdinExport') {
|
||||||
description "Triggers crowdin to export the latest translations"
|
description "Triggers crowdin to export the latest translations"
|
||||||
onlyIf {
|
onlyIf {
|
||||||
ENV.CROWDIN_KEY
|
ENV.CROWDIN_KEY
|
||||||
}
|
}
|
||||||
doLast{
|
doLast {
|
||||||
def apiKey = ENV.CROWDIN_KEY
|
def apiKey = ENV.CROWDIN_KEY
|
||||||
def projectId = 'techreborn'
|
def projectId = 'techreborn'
|
||||||
def response = new URL(sprintf('https://api.crowdin.com/api/project/%1$s/export?key=%2$s', [projectId, apiKey])).text
|
def response = new URL(sprintf('https://api.crowdin.com/api/project/%1$s/export?key=%2$s', [projectId, apiKey])).text
|
||||||
|
@ -283,22 +282,29 @@ task crowdinExport() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task crowdin(type: Download, dependsOn: 'crowdinExport'){
|
def translationsUrl = "https://crowdin.com/backend/download/project/techreborn.zip"
|
||||||
|
def translationsZip = file("build/translations.zip")
|
||||||
|
|
||||||
|
tasks.register('crowdin') {
|
||||||
|
dependsOn crowdinExport
|
||||||
description "Downloads translations from CrowdIn"
|
description "Downloads translations from CrowdIn"
|
||||||
src 'https://crowdin.com/backend/download/project/techreborn.zip'
|
outputs.file translationsZip
|
||||||
dest file("build/translations.zip")
|
|
||||||
overwrite true
|
doLast {
|
||||||
|
translationsZip.bytes = new URL(translationsUrl).bytes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task cleanCrowdin(type: Delete){
|
tasks.register('cleanCrowdin', Delete) {
|
||||||
description "Delete old translations"
|
description "Delete old translations"
|
||||||
delete 'build/translations'
|
delete 'build/translations'
|
||||||
}
|
}
|
||||||
|
clean.dependsOn cleanCrowdin
|
||||||
|
|
||||||
task renameCrowdin(type: Copy, dependsOn: ['crowdin', 'cleanCrowdin']){
|
tasks.register('renameCrowdin', Copy) {
|
||||||
|
dependsOn crowdin
|
||||||
description "Renames the translation files to be all lower case"
|
description "Renames the translation files to be all lower case"
|
||||||
mustRunAfter 'crowdin'
|
from zipTree(translationsZip)
|
||||||
from zipTree(file("build/translations.zip"))
|
|
||||||
into file('build/translations')
|
into file('build/translations')
|
||||||
rename {
|
rename {
|
||||||
String filename -> return filename.toLowerCase()
|
String filename -> return filename.toLowerCase()
|
||||||
|
@ -311,14 +317,15 @@ task renameCrowdin(type: Copy, dependsOn: ['crowdin', 'cleanCrowdin']){
|
||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
task fixTranslations(dependsOn: ['renameCrowdin']) {
|
tasks.register('fixTranslations') {
|
||||||
|
dependsOn renameCrowdin
|
||||||
description "Remove all translations that do not have an entry, ensures that minecraft falls back to EN_US over writing out an empty string"
|
description "Remove all translations that do not have an entry, ensures that minecraft falls back to EN_US over writing out an empty string"
|
||||||
def jsonSlurper = new JsonSlurper()
|
def jsonSlurper = new JsonSlurper()
|
||||||
doLast {
|
doLast {
|
||||||
file('build/translations').eachFileRecurse(groovy.io.FileType.FILES) {
|
file('build/translations').eachFileRecurse(groovy.io.FileType.FILES) {
|
||||||
if(it.name.endsWith(".json")) {
|
if (it.name.endsWith(".json")) {
|
||||||
def lang = jsonSlurper.parseText(it.text)
|
def lang = jsonSlurper.parseText(it.text)
|
||||||
lang.values().removeIf { val -> val.empty}
|
lang.values().removeIf { val -> val.empty }
|
||||||
it.text = JsonOutput.prettyPrint(JsonOutput.toJson(lang))
|
it.text = JsonOutput.prettyPrint(JsonOutput.toJson(lang))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,13 +333,12 @@ task fixTranslations(dependsOn: ['renameCrowdin']) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use to test the crowdin translations in a dev env
|
// Use to test the crowdin translations in a dev env
|
||||||
task copyTranslationsToGenerated(dependsOn: ['fixTranslations'], type: Copy) {
|
tasks.register('copyTranslationsToGenerated', Copy) {
|
||||||
|
dependsOn fixTranslations
|
||||||
from file('build/translations')
|
from file('build/translations')
|
||||||
into file('src/main/generated')
|
into file('src/main/generated')
|
||||||
}
|
}
|
||||||
|
|
||||||
import groovy.util.XmlSlurper
|
|
||||||
|
|
||||||
curseforge {
|
curseforge {
|
||||||
if (ENV.CURSEFORGE_API_KEY) {
|
if (ENV.CURSEFORGE_API_KEY) {
|
||||||
apiKey = ENV.CURSEFORGE_API_KEY
|
apiKey = ENV.CURSEFORGE_API_KEY
|
||||||
|
@ -360,7 +366,7 @@ curseforge {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getBranch() {
|
static def getBranch() {
|
||||||
def ENV = System.getenv()
|
def ENV = System.getenv()
|
||||||
if (ENV.GITHUB_REF) {
|
if (ENV.GITHUB_REF) {
|
||||||
def branch = ENV.GITHUB_REF
|
def branch = ENV.GITHUB_REF
|
||||||
|
@ -373,7 +379,8 @@ def getBranch() {
|
||||||
import org.kohsuke.github.GHReleaseBuilder
|
import org.kohsuke.github.GHReleaseBuilder
|
||||||
import org.kohsuke.github.GitHub
|
import org.kohsuke.github.GitHub
|
||||||
|
|
||||||
task github(dependsOn: remapJar) {
|
tasks.register('github') {
|
||||||
|
dependsOn remapJar
|
||||||
onlyIf {
|
onlyIf {
|
||||||
ENV.GITHUB_TOKEN
|
ENV.GITHUB_TOKEN
|
||||||
}
|
}
|
||||||
|
@ -392,20 +399,4 @@ task github(dependsOn: remapJar) {
|
||||||
ghRelease.uploadAsset(file("RebornCore/build/libs/RebornCore-${version}.jar"), "application/java-archive")
|
ghRelease.uploadAsset(file("RebornCore/build/libs/RebornCore-${version}.jar"), "application/java-archive")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
github.dependsOn(project(":RebornCore").getTasks().getByName("remapJar"))
|
github.dependsOn(project(":RebornCore").getTasks().named("remapJar"))
|
||||||
|
|
||||||
// A task to ensure that the version being released has not already been released.
|
|
||||||
task checkVersion {
|
|
||||||
doFirst {
|
|
||||||
def xml = new URL("https://maven.modmuss50.me/TechReborn/TechReborn-1.17/maven-metadata.xml").text
|
|
||||||
def metadata = new XmlSlurper().parseText(xml)
|
|
||||||
def versions = metadata.versioning.versions.version*.text();
|
|
||||||
if (versions.contains(version)) {
|
|
||||||
throw new RuntimeException("${version} has already been released!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
github.mustRunAfter checkVersion
|
|
||||||
publish.mustRunAfter checkVersion
|
|
||||||
project.tasks.curseforge.mustRunAfter checkVersion
|
|
||||||
|
|
Loading…
Reference in a new issue