Update loom + cleanup build.gradle
This commit is contained in:
parent
6a4116ed26
commit
e8bad0f009
1 changed files with 68 additions and 77 deletions
63
build.gradle
63
build.gradle
|
@ -11,10 +11,9 @@ plugins {
|
|||
id 'idea'
|
||||
id 'eclipse'
|
||||
id 'maven-publish'
|
||||
id 'com.diffplug.spotless' version '6.12.0'
|
||||
id 'fabric-loom' version '1.2-SNAPSHOT'
|
||||
id 'com.diffplug.spotless' version '6.19.0'
|
||||
id 'fabric-loom' version '1.3-SNAPSHOT'
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
||||
id 'de.undercouch.download' version '4.1.1'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -82,7 +81,7 @@ allprojects {
|
|||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
register("maven", MavenPublication) {
|
||||
groupId project.name
|
||||
artifactId project.archivesBaseName + "-" + getBranch()
|
||||
version project.version
|
||||
|
@ -269,7 +268,7 @@ jar {
|
|||
dependsOn 'runDatagen'
|
||||
}
|
||||
|
||||
task crowdinExport() {
|
||||
tasks.register('crowdinExport') {
|
||||
description "Triggers crowdin to export the latest translations"
|
||||
onlyIf {
|
||||
ENV.CROWDIN_KEY
|
||||
|
@ -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"
|
||||
src 'https://crowdin.com/backend/download/project/techreborn.zip'
|
||||
dest file("build/translations.zip")
|
||||
overwrite true
|
||||
outputs.file translationsZip
|
||||
|
||||
doLast {
|
||||
translationsZip.bytes = new URL(translationsUrl).bytes
|
||||
}
|
||||
}
|
||||
|
||||
task cleanCrowdin(type: Delete){
|
||||
tasks.register('cleanCrowdin', Delete) {
|
||||
description "Delete old 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"
|
||||
mustRunAfter 'crowdin'
|
||||
from zipTree(file("build/translations.zip"))
|
||||
from zipTree(translationsZip)
|
||||
into file('build/translations')
|
||||
rename {
|
||||
String filename -> return filename.toLowerCase()
|
||||
|
@ -311,7 +317,8 @@ task renameCrowdin(type: Copy, dependsOn: ['crowdin', 'cleanCrowdin']){
|
|||
import groovy.json.JsonSlurper
|
||||
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"
|
||||
def jsonSlurper = new JsonSlurper()
|
||||
doLast {
|
||||
|
@ -326,13 +333,12 @@ task fixTranslations(dependsOn: ['renameCrowdin']) {
|
|||
}
|
||||
|
||||
// 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')
|
||||
into file('src/main/generated')
|
||||
}
|
||||
|
||||
import groovy.util.XmlSlurper
|
||||
|
||||
curseforge {
|
||||
if (ENV.CURSEFORGE_API_KEY) {
|
||||
apiKey = ENV.CURSEFORGE_API_KEY
|
||||
|
@ -360,7 +366,7 @@ curseforge {
|
|||
}
|
||||
}
|
||||
|
||||
def getBranch() {
|
||||
static def getBranch() {
|
||||
def ENV = System.getenv()
|
||||
if (ENV.GITHUB_REF) {
|
||||
def branch = ENV.GITHUB_REF
|
||||
|
@ -373,7 +379,8 @@ def getBranch() {
|
|||
import org.kohsuke.github.GHReleaseBuilder
|
||||
import org.kohsuke.github.GitHub
|
||||
|
||||
task github(dependsOn: remapJar) {
|
||||
tasks.register('github') {
|
||||
dependsOn remapJar
|
||||
onlyIf {
|
||||
ENV.GITHUB_TOKEN
|
||||
}
|
||||
|
@ -392,20 +399,4 @@ task github(dependsOn: remapJar) {
|
|||
ghRelease.uploadAsset(file("RebornCore/build/libs/RebornCore-${version}.jar"), "application/java-archive")
|
||||
}
|
||||
}
|
||||
github.dependsOn(project(":RebornCore").getTasks().getByName("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
|
||||
github.dependsOn(project(":RebornCore").getTasks().named("remapJar"))
|
||||
|
|
Loading…
Reference in a new issue