Files
ForestryMC/build.gradle
T
2015-11-20 18:28:25 -08:00

258 lines
5.6 KiB
Groovy
Executable File

buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
// https://github.com/ajoberstar/gradle-git
classpath 'org.ajoberstar:gradle-git:0.8.0'
}
}
apply plugin: 'forge'
apply plugin: 'maven'
apply plugin: 'java'
version = version_major + '.' + version_minor + '.' + version_patch + '.' + getBuildNumber()
if (project.hasProperty('buildQualifier')) {
version = project.version + '-' + project.buildQualifier
}
group= "net.sengir.forestry" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "forestry_" + mcversion
ext.dirDest = './build/dist'
ext.dirLang = "./lang"
ext.apiForestry = "./api/forestry"
ext.apiRedstoneFlux = "./api/redstoneflux"
// java version
sourceCompatibility = 1.7
targetCompatibility = 1.7
minecraft {
version = mcversion + "-" + forgeversion
runDir = "run"
replace '@VERSION@', project.version
replace '@BUILD_NUMBER@', getBuildNumber()
srgExtra "PK: chylex/javacheck forestry/shade/javacheck"
}
sourceSets {
main {
java {
srcDir project.apiForestry
srcDir project.apiRedstoneFlux + "/src/main/java"
}
resources {
srcDir project.dirLang
}
}
}
repositories {
maven {
name = "ic2"
url = "http://maven.ic2.player.to/"
}
ivy {
name "BuildCraft"
artifactPattern "http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision]-[classifier].[ext]"
}
maven {
name = "chickenbones"
url = "http://chickenbones.net/maven/"
}
maven{
name "tterrag Repo"
url "http://maven.tterrag.com/"
}
}
configurations {
api
compile.extendsFrom api
shade
compile.extendsFrom shade
}
dependencies {
api 'net.industrial-craft:industrialcraft-2:2.2.790-experimental:api'
api name: "buildcraft", version: "7.1.12", classifier: "api"
// http://files.minecraftforge.net/CodeChickenLib/
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev"
// http://chickenbones.net/maven
compile "codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev"
compile "codechicken:NotEnoughItems:1.7.10-1.0.5.111:dev"
compile "codechicken:NotEnoughItems:1.7.10-1.0.5.111:src"
// http://maven.tterrag.com/
shade "chylex.javacheck:JavaChecker:v1.2-b1"
testCompile 'junit:junit:4.12'
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude '**/*.md'
}
}
runClient {
if (project.hasProperty('mcUsername')) {
args "--username=" + project.mcUsername
}
if (project.hasProperty('mcPassword')) {
args "--password=" + project.mcPassword
}
}
debugClient {
if (project.hasProperty('mcUsername')) {
args "--username=" + project.mcUsername
}
if (project.hasProperty('mcPassword')) {
args "--password=" + project.mcPassword
}
}
jar {
destinationDir = file("build/tmp")
archiveName = "main.jar"
// Copy various READMEs and Licensing files into the jar
into ('forestry/api') {
from project.apiForestry + "/LICENSE.txt"
}
into ('cofh/api') {
from project.apiRedstoneFlux + "/LICENSE - LGPLv3.txt"
}
into ('invtweaks/api') {
from "./src/main/java/invtweaks/LICENSE.txt"
}
configurations.shade.each{ dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**', 'mcmod.info'
}
}
}
task mainJar(type: Jar, dependsOn: 'reobf') {
from (zipTree(jar.getArchivePath())) {
include '**'
exclude '**/codechicken/**'
exclude '**/uristqwerty/**'
}
destinationDir = file(dirDest)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
includeEmptyDirs = false
manifest{
attributes 'TweakClass': 'forestry.shade.javacheck.Java7Checker'
}
}
task devJar(type: Jar, dependsOn: 'classes') {
from (sourceSets.main.output) {
exclude '**/codechicken/**'
exclude '**/uristqwerty/**'
}
destinationDir = file(dirDest)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
includeEmptyDirs = false
classifier = 'dev'
}
task apiJar(type: Jar, dependsOn: 'classes') {
from project.apiForestry
from(sourceSets.main.output) {
include 'forestry/api/**'
}
destinationDir = file(dirDest)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
includeEmptyDirs = false
classifier = 'api'
}
task sourceJar(type: Jar, dependsOn: 'classes') {
from (sourceSets.main.allSource) {
exclude '**/codechicken/**'
exclude '**/uristqwerty/**'
}
destinationDir = file(dirDest)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
includeEmptyDirs = false
classifier = 'sources'
}
task release (dependsOn: [mainJar, apiJar, devJar, sourceJar]) {
}
artifacts {
archives apiJar
archives devJar
archives sourceJar
}
uploadArchives {
repositories {
if (project.hasProperty('mavenDir')) {
mavenDeployer {
repository(url: "file://"+mavenDir)
addFilter('api') { artifact, file ->
file == apiJar.archivePath
}
addFilter('dev') { artifact, file ->
file == devJar.archivePath
}
addFilter('source') { artifact, file ->
file == sourceJar.archivePath
}
}
} else {
println 'Archives upload disabled, gradle.properties is missing.'
}
}
}
def getBuildNumber() {
return "$System.env.BUILD_NUMBER" != "null" ? "$System.env.BUILD_NUMBER" : "0"
}