mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-21 20:42:26 +00:00
252 lines
6.4 KiB
Groovy
252 lines
6.4 KiB
Groovy
/*
|
|
* Mantle
|
|
* Master build file
|
|
* Based on TConstruct's master build file
|
|
* Authors: Sunstrike, ProgWML6
|
|
* Help from AbrarSyed
|
|
*/
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenLocal()
|
|
maven { url = 'https://maven.minecraftforge.net/' }
|
|
maven { url = 'https://libraries.minecraft.net/' }
|
|
jcenter()
|
|
mavenCentral()
|
|
maven {
|
|
name = "sonatype"
|
|
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
}
|
|
maven {
|
|
url "https://plugins.gradle.org/m2/"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
|
classpath 'io.freefair.gradle:lombok-plugin:4.1.6'
|
|
}
|
|
}
|
|
|
|
apply plugin: 'net.minecraftforge.gradle'
|
|
apply plugin: 'maven'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'io.freefair.lombok'
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
maven { // Vanilla
|
|
name 'Vanilla'
|
|
url 'https://libraries.minecraft.net/'
|
|
}
|
|
maven { // Forge
|
|
name 'ForgeFS'
|
|
url 'https://maven.minecraftforge.net/'
|
|
}
|
|
maven {
|
|
name 'DVS1 Maven FS'
|
|
url 'https://dvs1.progwml6.com/files/maven'
|
|
}
|
|
maven {
|
|
// for Yarn2MCP
|
|
name "yarn2mcp"
|
|
url "https://maven.tterrag.com/"
|
|
}
|
|
}
|
|
|
|
group = 'slimeknights.mantle'
|
|
|
|
// sets version to the slimeKnights version format
|
|
task buildInfo {
|
|
try {
|
|
def cmd = "git rev-parse --short HEAD"
|
|
def proc = cmd.execute()
|
|
proc.waitFor()
|
|
if (proc.exitValue() == 0) {
|
|
ext.revision = proc.text.trim()
|
|
} else {
|
|
ext.revision = "GITBORK"
|
|
}
|
|
} catch (all) {
|
|
ext.revision = "gitgud"
|
|
}
|
|
|
|
if (System.getenv().BUILD_NUMBER != null) {
|
|
ext.buildNum = "${System.getenv().BUILD_NUMBER}"
|
|
} else {
|
|
ext.buildNum = "DEV.${project.buildInfo.revision}"
|
|
}
|
|
}
|
|
ext.artifact_version = 'NFG'
|
|
if (System.getenv().ARTIFACT_VERSION == null) {
|
|
artifact_version = "${mod_version}.${project.buildInfo.buildNum}"
|
|
}
|
|
if (System.getenv().ARTIFACT_VERSION != null) {
|
|
artifact_version = "${system.getenv().ARTIFACT_VERSION}"
|
|
}
|
|
|
|
version = "${minecraft_version}-${artifact_version}"
|
|
|
|
sourceSets {
|
|
main {
|
|
resources {
|
|
srcDirs "src/generated/resources"
|
|
//But exclude the cache of the generated data from what gets built
|
|
exclude '.cache'
|
|
}
|
|
}
|
|
}
|
|
|
|
minecraft {
|
|
mappings channel: 'snapshot', version: mappings_version
|
|
|
|
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
|
|
|
runs {
|
|
client {
|
|
workingDirectory project.file('run')
|
|
|
|
// Recommended logging data for a userdev environment
|
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP,CORE'
|
|
|
|
// Recommended logging level for the console
|
|
property 'forge.logging.console.level', 'debug'
|
|
|
|
mods {
|
|
mantle {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
}
|
|
|
|
server {
|
|
workingDirectory project.file('run')
|
|
|
|
// Recommended logging data for a userdev environment
|
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP,CORE'
|
|
|
|
// Recommended logging level for the console
|
|
property 'forge.logging.console.level', 'debug'
|
|
|
|
mods {
|
|
mantle {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
}
|
|
|
|
data {
|
|
workingDirectory project.file('run')
|
|
|
|
// Recommended logging data for a userdev environment
|
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP,CORE'
|
|
|
|
// Recommended logging level for the console
|
|
property 'forge.logging.console.level', 'debug'
|
|
|
|
args '--mod', 'mantle', '--all', '--output', file('src/generated/resources/')
|
|
|
|
mods {
|
|
mantle {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
deployerJars
|
|
}
|
|
|
|
dependencies {
|
|
minecraft 'net.minecraftforge:forge:' + minecraft_version + '-' + forge_version
|
|
|
|
// compile against the JEI API but do not include it at runtime
|
|
compileOnly fg.deobf("mezz.jei:jei-${jei_version}:api")
|
|
// at runtime, use the full JEI jar
|
|
runtimeOnly fg.deobf("mezz.jei:jei-${jei_version}")
|
|
}
|
|
|
|
def modsTomlSpec = copySpec{
|
|
from(sourceSets.main.resources) {
|
|
include 'META-INF/mods.toml'
|
|
expand 'version': artifact_version,
|
|
'loader_range': loader_range,
|
|
'minecraft_range': minecraft_range,
|
|
'forge_range': forge_range
|
|
}
|
|
}
|
|
|
|
// need to copy into each build directory, unfortunately does not seem easy to do this automatically
|
|
def buildPaths = [
|
|
"$rootDir/out/production/resources", // IDEA
|
|
"$rootDir/bin", // Eclipse
|
|
]
|
|
|
|
// task to add mods.toml to all relevant folders
|
|
task replaceResources {
|
|
// copy for gradle
|
|
copy {
|
|
outputs.upToDateWhen { false }
|
|
with modsTomlSpec
|
|
into processResources.destinationDir
|
|
}
|
|
// copy for IDEs
|
|
buildPaths.each { path ->
|
|
if (new File(path).exists()) {
|
|
copy {
|
|
outputs.upToDateWhen { false }
|
|
with modsTomlSpec
|
|
into path
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
processResources {
|
|
exclude 'META-INF/mods.toml'
|
|
finalizedBy replaceResources
|
|
}
|
|
|
|
|
|
jar {
|
|
manifest {
|
|
attributes([
|
|
"Specification-Title" : "Mantle",
|
|
"Specification-Vendor" : "Slime Knights",
|
|
"Specification-Version" : "1", // We are version 1 of ourselves
|
|
"Implementation-Title" : project.name,
|
|
"Implementation-Version" : "${version}",
|
|
"Implementation-Vendor" : "Slime Knights",
|
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
|
])
|
|
}
|
|
}
|
|
|
|
jar.finalizedBy('reobfJar')
|
|
|
|
task sourcesJar(type: Jar) {
|
|
from sourceSets.main.allJava
|
|
classifier = 'sources'
|
|
}
|
|
|
|
artifacts {
|
|
archives sourcesJar
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
artifact jar
|
|
artifact sourcesJar
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
if (project.hasProperty('DEPLOY_DIR')) {
|
|
maven { url DEPLOY_DIR }
|
|
}
|
|
}
|
|
}
|