mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
307 lines
8.5 KiB
Groovy
307 lines
8.5 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
maven {
|
|
name "forge"
|
|
url "https://files.minecraftforge.net/maven"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.0.+'
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id 'org.hidetake.ssh' version '2.10.1'
|
|
id "com.diffplug.gradle.spotless" version "3.27.2"
|
|
}
|
|
|
|
apply plugin: 'net.minecraftforge.gradle'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'maven'
|
|
apply plugin: 'pmd'
|
|
// apply plugin: 'com.matthewprenger.cursegradle'
|
|
|
|
ext.configFile = file('build.properties')
|
|
ext.config = parseConfig(configFile)
|
|
ext.priv = parseConfig(file('private.properties'))
|
|
|
|
def mc_version = "1.16.1"
|
|
version = "${config.version}-${config.build_number}"
|
|
group = "vazkii.botania" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
|
archivesBaseName = config.mod_name
|
|
|
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
|
|
|
minecraft {
|
|
mappings channel: 'snapshot', version: "20200514-1.16"
|
|
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
|
runs {
|
|
client {
|
|
properties 'forge.logging.console.level': 'debug'
|
|
properties 'fml.earlyprogresswindow': 'false'
|
|
workingDirectory project.file('run')
|
|
mods {
|
|
botania {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
}
|
|
server {
|
|
properties 'forge.logging.console.level': 'debug'
|
|
workingDirectory project.file('run')
|
|
mods {
|
|
botania {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
}
|
|
data {
|
|
properties 'fml.earlyprogresswindow': 'false'
|
|
workingDirectory project.file('run')
|
|
mods {
|
|
botania {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
args '--mod', 'botania', '--all',
|
|
'--existing', '"' + file('src/main/resources/') + '"',
|
|
'--existing', '"' + file('src/generated/resources/') + '"',
|
|
'--output', '"' + file('src/generated/resources/') + '"'
|
|
}
|
|
}
|
|
}
|
|
|
|
sourceSets.main.resources {
|
|
srcDir 'src/generated/resources'
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven {
|
|
url "https://maven.blamejared.com"
|
|
}
|
|
maven {
|
|
url "https://dvs1.progwml6.com/files/maven"
|
|
}
|
|
maven {
|
|
url "https://minecraft.curseforge.com/api/maven/"
|
|
}
|
|
maven {
|
|
name "curios"
|
|
url "https://maven.theillusivec4.top/"
|
|
}
|
|
}
|
|
|
|
test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
dependencies {
|
|
minecraft "net.minecraftforge:forge:${mc_version}-32.0.24"
|
|
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.16-36.188:api")
|
|
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16-36.188")
|
|
|
|
compileOnly fg.deobf("mezz.jei:jei-1.16.1:7.0.0.2:api")
|
|
runtimeOnly fg.deobf("mezz.jei:jei-1.16.1:7.0.0.2")
|
|
|
|
/*
|
|
compileOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0:api")
|
|
runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0")
|
|
*/
|
|
|
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.1'
|
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.1'
|
|
}
|
|
|
|
spotless {
|
|
enforceCheck = false // workaround around jenkins having wrong line endings in some files
|
|
// we explicitly check in github actions builds
|
|
java {
|
|
target '**/vazkii/botania/**/*.java'
|
|
targetExclude '**/buildcraft/*.java', '**/thaumcraft/*.java'
|
|
|
|
indentWithTabs()
|
|
licenseHeaderFile( 'spotless/license_template.txt')
|
|
eclipse().configFile 'spotless/eclipseformat.xml'
|
|
importOrderFile 'spotless/eclipse.importorder'
|
|
}
|
|
}
|
|
pmd {
|
|
ruleSets = ["java-braces"]
|
|
}
|
|
|
|
task checkSyntax {
|
|
dependsOn spotlessJavaCheck, pmdMain
|
|
}
|
|
|
|
if (System.getenv().BUILD_NUMBER != null) {
|
|
//adds the build number to the end of the version string if on a build server
|
|
version += ".${System.getenv().BUILD_NUMBER}"
|
|
}
|
|
|
|
jar {
|
|
manifest {
|
|
attributes(["Specification-Title": "botania",
|
|
"Specification-Vendor": "botania",
|
|
"Specification-Version": "1",
|
|
"Implementation-Title": project.name,
|
|
"Implementation-Version": "${version}",
|
|
"Implementation-Vendor": "botania",
|
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],)
|
|
}
|
|
|
|
exclude "**/*.bat"
|
|
exclude "**/*.psd"
|
|
exclude "**/*.exe"
|
|
}
|
|
|
|
processResources {
|
|
// Exclude datagenerator .cache directory
|
|
exclude '.cache'
|
|
|
|
filesMatching('data/botania/patchouli_books/lexicon/book.json') {
|
|
filter {
|
|
it.replaceAll("buildNumber", config.build_number)
|
|
}
|
|
}
|
|
}
|
|
|
|
task srcJar(type: Jar) {
|
|
from(sourceSets.main.java)
|
|
classifier = 'sources'
|
|
}
|
|
|
|
task apiJar(type: Jar) {
|
|
// Remove sources from the api jar when MinecraftForge/ForgeGradle#369 is fixed
|
|
from(sourceSets.main.allJava)
|
|
from(sourceSets.main.output)
|
|
include 'vazkii/botania/api/**'
|
|
|
|
classifier = 'api'
|
|
}
|
|
|
|
artifacts {
|
|
archives srcJar, apiJar
|
|
}
|
|
|
|
/**
|
|
* Increments the buildnumber in your config file, and saves it
|
|
* Note: The doFirst is important, without it the build number
|
|
* will be incremented every time tasks are configured, i.e every
|
|
* time gradle is run on this project.
|
|
*/
|
|
task incrementBuildNumber {
|
|
doFirst {
|
|
config.build_number = (config.build_number.toString().toInteger()) + 1
|
|
configFile.withWriter {
|
|
config.toProperties().store(it, "")
|
|
}
|
|
|
|
file('web/versions.ini').append("\n${project.version}=${mc_version}")
|
|
file("${config.dir_repo}/version/${mc_version}.txt").write("${project.version}")
|
|
}
|
|
}
|
|
|
|
|
|
import java.util.regex.Pattern
|
|
|
|
task sortArtifacts(type: Copy) {
|
|
from jar.destinationDir
|
|
into config.dir_output
|
|
//Put each jar with a classifier in a subfolder with the classifier as its name
|
|
eachFile {
|
|
//This matcher is used to get the classifier of the jar
|
|
def matcher = Pattern.compile("$config.mod_name $version-(?<classifier>\\w+).jar").matcher(it.name)
|
|
//Only change the destination for full matches, i.e jars with classifiers
|
|
if (matcher.matches()) {
|
|
def classifier = matcher.group('classifier')
|
|
/* Set the relative path to change the destination, since
|
|
* Gradle doesn't seem to like the absolute path being set*/
|
|
it.relativePath = it.relativePath.parent.append(false, classifier, it.name)
|
|
}
|
|
}
|
|
}
|
|
|
|
// SCP servers
|
|
remotes {
|
|
if (priv != null)
|
|
web {
|
|
host = 'botaniamod.net'
|
|
user = priv.scp_user
|
|
password = priv.scp_pass
|
|
knownHosts = allowAnyHosts
|
|
}
|
|
}
|
|
|
|
task upload {
|
|
doLast {
|
|
ssh.run {
|
|
session(remotes.web) {
|
|
put from: 'web/changelog.txt', into: priv.scp_dir + "/changelog.txt"
|
|
put from: 'web/versions.ini', into: priv.scp_dir + "/versions.ini"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task deployWeb {
|
|
doLast {
|
|
ssh.run {
|
|
session(remotes.web) {
|
|
def parent = file('web').toPath()
|
|
for (f in fileTree(dir: 'web')) {
|
|
def rel = parent.relativize(f.toPath()).toString().replace(File.separator, '/')
|
|
def dest = priv.scp_dir + rel
|
|
put from: f, into: dest
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def parseConfig(File config) {
|
|
if(config.exists()){
|
|
config.withReader {
|
|
def prop = new Properties()
|
|
prop.load(it)
|
|
return (new ConfigSlurper().parse(prop))
|
|
}
|
|
} else {
|
|
return null
|
|
}
|
|
}
|
|
|
|
/*
|
|
curseforge {
|
|
if(priv == null){
|
|
return
|
|
}
|
|
apiKey = priv.cfkey
|
|
project {
|
|
id = "225643"
|
|
changelog = """
|
|
See http://botaniamod.net/changelog.php#${version}
|
|
"""
|
|
releaseType = "release"
|
|
addGameVersion "${mc_version}"
|
|
relations {
|
|
requiredLibrary 'curios'
|
|
optionalLibrary 'quark'
|
|
optionalLibrary 'albedo'
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
uploadArchives {
|
|
repositories {
|
|
mavenDeployer {
|
|
repository(url: "file://" + (System.getenv("local_maven") != null ? System.getenv("local_maven") : System.getenv("bamboo_local_maven")))
|
|
}
|
|
}
|
|
}
|
|
// tasks.uploadArchives.dependsOn reobfJar
|
|
|
|
defaultTasks 'clean', 'runData', 'checkSyntax', 'build', 'sortArtifacts', 'incrementBuildNumber', 'upload'
|