buildcraft/build.gradle

409 lines
12 KiB
Groovy
Raw Normal View History

// DON'T TOUCH THE BUILDSCRIPT[] BLOCK
// its special, and it is only there to make ForgeGradle work correctly.
2014-02-17 08:24:19 +01:00
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
2014-04-26 13:12:28 +02:00
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
2014-02-17 08:24:19 +01:00
}
}
apply plugin: 'forge' // adds the forge dependency
apply plugin: 'maven' // for uploading to a maven repo
2014-05-04 06:06:32 +02:00
apply plugin: 'checkstyle'
2014-02-17 08:24:19 +01:00
2016-03-18 14:16:05 +01:00
version = "7.1.16"
2014-02-17 08:24:19 +01:00
group= "com.mod-buildcraft"
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
ext.mcModInfo = new groovy.json.JsonSlurper().parse(file("buildcraft_resources/mcmod.info"))
ext.priv = parseConfig(file('private.properties'))
2014-02-17 08:24:19 +01:00
minecraft {
2015-07-15 12:15:38 +02:00
version = "1.7.10-10.13.4.1490-1.7.10" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
2014-02-17 08:24:19 +01:00
runDir = "run" // the directory for ForgeGradle to run Minecraft in
2014-02-17 08:24:19 +01:00
// replacing stuff in the source
replace '@VERSION@', project.version
replace '@MC_VERSION@', version
}
// configure the source folders
sourceSets {
main {
java {
srcDir 'common'
2014-02-17 08:24:19 +01:00
// exclude 'some exclusion'
// include 'some inclusion'
}
resources {
srcDir 'buildcraft_resources'
def l10n = file('../BuildCraft-Localization')
if(l10n.exists())
srcDir l10n
exclude '**/.md' // exclude readme from localization repo
2014-02-17 08:24:19 +01:00
// exclude 'some exclusion'
// include 'some inclusion'
}
}
api {
java {
srcDir 'api'
}
}
2014-02-17 08:24:19 +01:00
}
// Obfuscated Jar location
ext.jarFile = zipTree(jar.archivePath)
// Add API dir to the IDEA module
idea.module.sourceDirs += sourceSets.api.java.srcDirs
2014-02-17 08:24:19 +01:00
processResources
{
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
// ${version} and ${mcversion} are the exact strings being replaced
expand 'version':project.version, 'mcversion':project.minecraft.version
2014-02-17 08:24:19 +01:00
}
// copy everything else, that's not the mcmod.info
2014-02-17 08:24:19 +01:00
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// --------------------
// extra jar section
// -------------------
def createMCModInfo(def id, def taskName)
{
File temp = new File("build/processing/" + taskName + "/mcmod.info")
temp.parentFile.mkdirs()
if (temp.exists())
temp.delete()
temp.createNewFile()
temp.write(groovy.json.JsonOutput.toJson([ext.mcModInfo[id]]))
temp.deleteOnExit()
return temp
}
def parseConfig(File config) {
if (!config.exists())
return null;
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}
2014-02-17 08:24:19 +01:00
// add a source jar
task sourceJar(type: Jar) {
from sourceSets.main.allSource
from sourceSets.api.allSource
2014-02-17 08:24:19 +01:00
classifier = 'sources'
}
// add api classes to javadoc
javadoc {
source += sourceSets.api.allSource
}
2014-02-17 08:24:19 +01:00
// add a javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
// because the normal output has been made to be obfuscated
task deobfJar(type: Jar) {
from sourceSets.main.output
from sourceSets.api.output
2014-02-17 08:24:19 +01:00
classifier = 'dev'
}
task apiJar(type: Jar) {
from sourceSets.api.output
classifier = 'api'
}
task coreJar(type: Jar, dependsOn: reobf) {
destinationDir = file("modules")
classifier = 'core'
doFirst {
from(createMCModInfo(0, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraft/**", "assets/buildcraftcore/**", "buildcraft/BuildCraftCore**", "buildcraft/BuildCraftMod**", "buildcraft/core/**", "buildcraft/api/**", "cofh/**", "changelog/**", "LICENSE**", "versions.txt"])
}
}
}
task buildersJar(type: Jar, dependsOn: reobf) {
destinationDir = file("modules")
classifier = 'builders'
doFirst {
from(createMCModInfo(1, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftbuilders/**", "buildcraft/builders/**", "buildcraft/BuildCraftBuilders**", "LICENSE"])
}
}
}
task energyJar(type: Jar, dependsOn: reobf) {
destinationDir = file("modules")
classifier = 'energy'
doFirst {
from(createMCModInfo(2, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftenergy/**", "buildcraft/energy/**", "buildcraft/BuildCraftEnergy**", "LICENSE"])
}
}
}
task factoryJar(type: Jar, dependsOn: reobf) {
destinationDir = file("modules")
classifier = 'factory'
doFirst {
from(createMCModInfo(3, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftfactory/**", "buildcraft/factory/**", "buildcraft/BuildCraftFactory**", "LICENSE"])
}
}
}
task siliconJar(type: Jar, dependsOn: reobf) {
destinationDir = file("modules")
classifier = 'silicon'
doFirst {
from(createMCModInfo(4, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftsilicon/**", "buildcraft/silicon/**", "buildcraft/BuildCraftSilicon**", "LICENSE"])
}
}
}
task transportJar(type: Jar, dependsOn: reobf) {
destinationDir = file("modules")
classifier = 'transport'
doFirst {
from(createMCModInfo(5, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcrafttransport/**", "buildcraft/transport/**", "buildcraft/BuildCraftTransport**", "LICENSE"])
}
}
}
task roboticsJar(type: Jar, dependsOn: reobf) {
destinationDir = file("modules")
classifier = 'robotics'
doFirst {
from(createMCModInfo(6, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftrobotics/**", "buildcraft/robotics/**", "buildcraft/BuildCraftRobotics**", "LICENSE"])
}
}
}
// add api classes to main package
jar {
from sourceSets.api.output
}
2014-05-04 18:16:45 +02:00
checkstyle {
2014-05-04 06:06:32 +02:00
configFile = file('guidelines/buildcraft.checkstyle')
}
2014-09-04 21:24:24 +02:00
checkstyleApi.exclude 'cofh/**'
2014-02-17 08:24:19 +01:00
// make sure all of these happen when we run build
build.dependsOn sourceJar, javadocJar, deobfJar, apiJar
2014-02-17 08:24:19 +01:00
// --------------------
// maven section
// -------------------
// create the deployerJars dependency configuration
configurations {
deployerJars
sshAntTask
2014-02-17 08:24:19 +01:00
}
dependencies {
// dependency in deployerJars, for maven deployment. see definition in mavenDeployer{} below
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
sshAntTask 'org.apache.ant:ant-jsch:1.9.6', 'com.jcraft:jsch:0.1.53'
}
clean{
delete "modules"
2014-02-17 08:24:19 +01:00
}
// specify artifacts to be uploaded
artifacts {
// the default jar is already here by default
2014-02-17 08:24:19 +01:00
archives sourceJar
archives javadocJar
archives deobfJar
archives apiJar
// Modules
archives coreJar
archives buildersJar
archives energyJar
archives factoryJar
archives siliconJar
archives transportJar
archives roboticsJar
2014-02-17 08:24:19 +01:00
}
def sftp(String subPath, Closure antFileset = {}) {
ant {
taskdef(name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath: configurations.sshAntTask.asPath)
Map sftpArgs = [
verbose : 'yes',
todir : priv.username + "@" + priv.host + ":" + priv.remotedir + version + "/" + subPath,
port: priv.port,
password: priv.password,
sftp: true,
trust: 'yes'
]
delegate.scp(sftpArgs) {
antFileset.delegate = delegate
antFileset()
}
}
}
task upload(dependsOn: build) {
description = 'Update files on remote server.'
doFirst {
sftp("") {
fileset(dir: libsDir)
}
sftp("modules") {
fileset(dir: 'modules')
}
}
}
if (ext.priv == null)
upload.enabled = false;
2014-02-17 08:24:19 +01:00
uploadArchives {
// make sure this happens after reobfuscation
dependsOn 'reobf'
repositories {
if (project.hasProperty("filesmaven")) { // if this is the Forge server, and this stuff is defined...
logger.info('Publishing to files server')
mavenDeployer {
// specify the jars that maven needs to deploy here
configuration = configurations.deployerJars
// authentication, again, specially set in the forge server environment
repository(url: project.filesmaven.url) {
authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key)
}
// here you specify all your metadata
// this is the definition of the maven pom.xml. This is simply a DSL to define the XML. Not actual fields or things to set.
pom {
groupId = project.group
2014-03-18 22:08:36 +01:00
version = project.version
2014-02-17 08:24:19 +01:00
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'A Minecraft mod adding all sorts of machinery'
2014-02-17 08:24:19 +01:00
url 'http://www.mod-buildcraft.com/'
scm {
url 'https://github.com/BuildCraft/BuildCraft'
connection 'scm:git:git://github.com/BuildCraft/BuildCraft.git'
developerConnection 'scm:git:git@github.com:BuildCraft/BuildCraft.git'
}
issueManagement {
system 'github'
url 'https://github.com/BuildCraft/BuildCraft/issues'
}
licenses {
license {
name 'Minecraft Mod Public License'
url 'http://www.mod-buildcraft.com/MMPL-1.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'SpaceToad'
name 'SpaceToad'
roles { role 'developer' }
}
developer {
id 'CovertJaguar'
name 'CovertJaguar'
roles { role 'developer' }
}
developer {
id 'SirSngir'
name 'SirSengir'
roles { role 'developer' }
}
developer {
id 'Krapht'
name 'Krapht'
roles { role 'developer' }
}
}
}
}
}
}
else
{
// otherwise publishing to the local repo in ~/.m2 is fine...
add project.repositories.mavenLocal()
}
}
}