354 lines
No EOL
8.3 KiB
Groovy
354 lines
No EOL
8.3 KiB
Groovy
buildscript {
|
|
dependencies {
|
|
classpath 'org.kohsuke:github-api:1.114'
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id 'java'
|
|
id 'idea'
|
|
id 'eclipse'
|
|
id 'maven-publish'
|
|
id 'signing'
|
|
id "org.cadixdev.licenser" version "0.5.0"
|
|
id "fabric-loom" version "0.6-SNAPSHOT"
|
|
id "com.matthewprenger.cursegradle" version "1.4.0"
|
|
id "de.undercouch.download" version "4.1.1"
|
|
}
|
|
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
|
|
repositories {
|
|
maven {
|
|
name = "Modmuss50"
|
|
url = "https://maven.modmuss50.me/"
|
|
}
|
|
maven {
|
|
name = "BuildCraft"
|
|
url = "https://mod-buildcraft.com/maven"
|
|
content {
|
|
includeGroup "alexiil.mc.lib"
|
|
}
|
|
}
|
|
maven {
|
|
url = "https://www.cursemaven.com"
|
|
content {
|
|
includeGroup "curse.maven"
|
|
}
|
|
}
|
|
maven {
|
|
url "https://maven.shedaniel.me/"
|
|
}
|
|
maven {
|
|
url = "https://jitpack.io"
|
|
content {
|
|
includeGroup "com.github.dexman545"
|
|
includeGroup "com.github.emilyploszaj"
|
|
includeGroup "io.github.onyxstudios.Cardinal-Components-API"
|
|
}
|
|
}
|
|
}
|
|
|
|
version = "3.8.2"
|
|
|
|
configurations {
|
|
shade
|
|
compile.extendsFrom shade
|
|
}
|
|
|
|
def ENV = System.getenv()
|
|
def build_number = ENV.BUILD_NUMBER ?: "local"
|
|
version = "${version}+build.$build_number"
|
|
|
|
license {
|
|
header file('HEADER')
|
|
include '**/*.java'
|
|
ignoreFailures = true //Stops the build from failing if a file does not have a license header
|
|
}
|
|
|
|
group = 'TechReborn'
|
|
|
|
configurations.all {
|
|
resolutionStrategy.cacheDynamicVersionsFor 2, 'minutes'
|
|
}
|
|
|
|
dependencies {
|
|
minecraft "com.mojang:minecraft:1.16.5"
|
|
mappings "net.fabricmc:yarn:1.16.5+build.4:v2"
|
|
modImplementation "net.fabricmc:fabric-loader:0.11.1"
|
|
|
|
//Fabric api
|
|
modImplementation "net.fabricmc.fabric-api:fabric-api:0.30.0+1.16"
|
|
|
|
optionalDependency "me.shedaniel:RoughlyEnoughItems:5.8.9"
|
|
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.6.7')
|
|
|
|
def rcVersion = 'RebornCore:RebornCore-1.16:+'
|
|
modApi (rcVersion) {
|
|
exclude group: "net.fabricmc.fabric-api"
|
|
}
|
|
include rcVersion
|
|
|
|
modApi 'teamreborn:energy:0.1.1'
|
|
|
|
optionalDependency "com.github.dexman545:autoswitch-api:-SNAPSHOT"
|
|
}
|
|
|
|
def optionalDependency(String dep) {
|
|
dependencies.modRuntime (dep) {
|
|
exclude group: "net.fabricmc.fabric-api"
|
|
exclude module: "nbt-crafting"
|
|
}
|
|
dependencies.modCompileOnly (dep) {
|
|
exclude group: "net.fabricmc.fabric-api"
|
|
exclude module: "nbt-crafting"
|
|
}
|
|
}
|
|
|
|
def disabledOptionalDependency(String dep) {
|
|
dependencies.modCompileOnly (dep) {
|
|
exclude group: "net.fabricmc.fabric-api"
|
|
exclude module: "nbt-crafting"
|
|
}
|
|
}
|
|
|
|
processResources {
|
|
inputs.property "version", project.version
|
|
|
|
filesMatching("fabric.mod.json") {
|
|
expand "version": project.version
|
|
}
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
it.options.encoding = "UTF-8"
|
|
|
|
if (JavaVersion.current().isJava9Compatible()) {
|
|
it.options.release = 8
|
|
}
|
|
}
|
|
|
|
jar {
|
|
exclude "**/*.psd"
|
|
classifier = 'universal'
|
|
|
|
from { crowdin.getDidWork() ? fileTree('build/translations').matching{exclude "**/en_US.json"} : null}
|
|
dependsOn 'fixTranslations'
|
|
dependsOn 'compileRecipes'
|
|
}
|
|
|
|
|
|
//Triggers crowdin to export the latest translations
|
|
task crowdinExport() {
|
|
onlyIf {
|
|
ENV.CROWDIN_KEY
|
|
}
|
|
doLast{
|
|
def apiKey = ENV.CROWDIN_KEY
|
|
def projectId = 'techreborn'
|
|
def response = new URL(sprintf('https://api.crowdin.com/api/project/%1$s/export?key=%2$s', [projectId, apiKey])).text
|
|
def metadata = new XmlParser().parseText(response)
|
|
project.logger.lifecycle("crowdin export status: " + metadata.@status)
|
|
}
|
|
}
|
|
|
|
|
|
task crowdin(type: Download, dependsOn: 'crowdinExport'){
|
|
src 'https://crowdin.com/backend/download/project/techreborn.zip'
|
|
dest file("build/translations.zip")
|
|
overwrite true
|
|
}
|
|
|
|
task cleanCrowdin(type: Delete){
|
|
delete 'build/translations'
|
|
}
|
|
|
|
//Renames the translation files to be all lower case
|
|
task renameCrowdin(type: Copy, dependsOn: ['crowdin', 'cleanCrowdin']){
|
|
mustRunAfter 'crowdin'
|
|
from zipTree(file("build/translations.zip"))
|
|
into file('build/translations')
|
|
rename {
|
|
String filename -> return filename.toLowerCase()
|
|
}
|
|
doFirst {
|
|
file('build/translations').deleteDir()
|
|
}
|
|
}
|
|
|
|
import groovy.json.JsonSlurper
|
|
import groovy.json.JsonOutput
|
|
|
|
//Remove all translations that do not have an entry, ensures that minecraft falls back to EN_US over writing out an empty string.
|
|
task fixTranslations(dependsOn: ['renameCrowdin']) {
|
|
def jsonSlurper = new JsonSlurper()
|
|
doLast {
|
|
file('build/translations').eachFileRecurse(groovy.io.FileType.FILES) {
|
|
if(it.name.endsWith(".json")) {
|
|
def lang = jsonSlurper.parseText(it.text)
|
|
lang.values().removeIf { val -> val.empty}
|
|
it.text = JsonOutput.prettyPrint(JsonOutput.toJson(lang))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
classifier = "sources"
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
maven(MavenPublication) {
|
|
groupId 'TechReborn'
|
|
artifactId project.archivesBaseName
|
|
version project.version
|
|
|
|
artifact(remapJar) {
|
|
builtBy remapJar
|
|
}
|
|
artifact(sourcesJar) {
|
|
builtBy remapSourcesJar
|
|
}
|
|
}
|
|
}
|
|
repositories {
|
|
if (ENV.MAVEN_URL) {
|
|
maven {
|
|
url ENV.MAVEN_URL
|
|
credentials {
|
|
username ENV.MAVEN_USERNAME
|
|
password ENV.MAVEN_PASSWORD
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ENV.SIGNING_KEY) {
|
|
signing {
|
|
useInMemoryPgpKeys(ENV.SIGNING_KEY, ENV.SIGNING_PASSWORD)
|
|
|
|
sign publishing.publications.maven
|
|
sign remapJar
|
|
}
|
|
|
|
task signAll(dependsOn: [signMavenPublication, signRemapJar, remapJar])
|
|
}
|
|
|
|
import com.google.gson.JsonArray
|
|
import groovy.util.XmlSlurper
|
|
import org.apache.commons.io.FileUtils
|
|
|
|
import java.util.function.Consumer
|
|
|
|
curseforge {
|
|
if (ENV.CURSEFORGE_API_KEY) {
|
|
apiKey = ENV.CURSEFORGE_API_KEY
|
|
}
|
|
|
|
project {
|
|
id = "233564"
|
|
changelog = "A changelog can be found at https://github.com/TechReborn/TechReborn"
|
|
releaseType = ENV.RELEASE_CHANNEL ?: "release"
|
|
addGameVersion "1.16.5"
|
|
addGameVersion "Fabric"
|
|
|
|
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
|
|
relations {
|
|
requiredDependency 'reborncore'
|
|
}
|
|
|
|
afterEvaluate {
|
|
uploadTask.dependsOn("remapJar")
|
|
}
|
|
}
|
|
|
|
options {
|
|
forgeGradleIntegration = false
|
|
}
|
|
}
|
|
|
|
def getBranch() {
|
|
def ENV = System.getenv()
|
|
if (ENV.GITHUB_REF) {
|
|
def branch = ENV.GITHUB_REF
|
|
return branch.substring(branch.lastIndexOf("/") + 1)
|
|
}
|
|
|
|
return "unknown"
|
|
}
|
|
|
|
import org.kohsuke.github.GHReleaseBuilder
|
|
import org.kohsuke.github.GitHub
|
|
|
|
task github(dependsOn: remapJar) {
|
|
onlyIf {
|
|
ENV.GITHUB_TOKEN
|
|
}
|
|
|
|
doLast {
|
|
def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String)
|
|
def repository = github.getRepository(ENV.GITHUB_REPOSITORY)
|
|
|
|
def releaseBuilder = new GHReleaseBuilder(repository, version as String)
|
|
releaseBuilder.name("${archivesBaseName}-${version}")
|
|
releaseBuilder.body("A changelog can be found at https://github.com/TechReborn/TechReborn")
|
|
releaseBuilder.commitish(getBranch())
|
|
|
|
def ghRelease = releaseBuilder.create()
|
|
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
|
|
}
|
|
}
|
|
|
|
// Generate recipe JSON for similar recipes
|
|
task compileRecipes {
|
|
def jsonSlurper = new JsonSlurper()
|
|
def recipePath = "build/resources/main/data/techreborn/recipes"
|
|
|
|
def smeltingPath = recipePath + "/smelting"
|
|
def blastingPath = recipePath + "/blasting"
|
|
|
|
doLast {
|
|
// Add any recipe filenames that don't match the regex here
|
|
String[] whitelist = []
|
|
def pattern = ~'^\\w+_(ingot(_from_dust)?)\\.json$'
|
|
|
|
file(smeltingPath).eachFileRecurse(groovy.io.FileType.FILES) {
|
|
if (whitelist.contains(it.name) || it.name ==~ pattern) {
|
|
def recipe = jsonSlurper.parseText(it.text)
|
|
|
|
// Final failsafe
|
|
if (["smelting", "minecraft:smelting"].contains(recipe.type)) {
|
|
recipe.type = "minecraft:blasting"
|
|
recipe.cookingtime = recipe.cookingtime / 2
|
|
|
|
File output = new File(blastingPath, it.name)
|
|
output.write(JsonOutput.prettyPrint(JsonOutput.toJson(recipe)))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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.16/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!")
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ENV.SIGNING_KEY) {
|
|
publish.dependsOn signAll
|
|
}
|
|
|
|
github.mustRunAfter checkVersion
|
|
publish.mustRunAfter checkVersion
|
|
project.tasks.curseforge.mustRunAfter checkVersion |