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' } } apply plugin: 'scala' apply plugin: 'forge' apply plugin: 'maven-publish' ext.buildProps = file "build.properties" buildProps.withReader { def prop = new Properties() prop.load(it) ext.config = new ConfigSlurper().parse prop } version = "${config.version.mod.major}.${config.version.mod.minor}.${config.version.mod.revis}" if (System.getenv("TEAMCITY_BUILDCONF_NAME").equalsIgnoreCase("Production")) { group = "com.calclavia.resonantinduction" archivesBaseName = System.getenv("TEAMCITY_PROJECT_NAME").replaceAll(" ", "-") } else { group = "dev.calclavia.resonantinduction" archivesBaseName = System.getenv("TEAMCITY_PROJECT_NAME").replaceAll(" ", "-") + "-" + System.getenv("TEAMCITY_BUILDCONF_NAME") } minecraft { version = "${config.version.minecraft}-${config.version.forge}" replaceIn "References.java" replace "@MAJOR@", config.version.mod.major replace "@MINOR@", config.version.mod.minor replace "@REVIS@", config.version.mod.revis replace "@BUILD@", System.getenv("BUILD_NUMBER") } if (System.getenv("BUILD_NUMBER") != null) version += ".${System.getenv("BUILD_NUMBER")}" processResources { inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in text files, not binary ones. from(sourceSets.main.resources.srcDirs) { include '**/*.info' // replace version and MCVersion // forge version is also accessible via project.minecraftforgeVersion // it contains the full minecraft version, including buildNumber expand 'version': project.version, 'mcversion': project.minecraft.version } // copy everything else, thats not text from 'build.properties' } task copyBuildXml(type: Copy) { from 'build.properties' into 'output' } /** * Generates a TeamCity XML changelog via the REST API. */ task("createChangelog").doLast { def teamCityURL = "http://ci.calclavia.com/" /** * Create a new file */ def file = new FileOutputStream("output/changelog.xml") def out = new BufferedOutputStream(file) /** * Grab the build first, parse the XML to find the changelog XML URL */ def changesXML = new XmlSlurper().parse(teamCityURL + "guestAuth/app/rest/changes?locator=build:(id:" + teamcity["teamcity.build.id"] + ")") def changes = changesXML.change /** * Add the XML definition header in the front of the file and remove all other occurrences of the XML header */ out << ("") println("createChangelog: Identified " + changes.size() + " changes to be written into the changelog.") for (int i = 0; i < changes.size(); i++) { /** * Write each changelog XML into the URL */ def changelogURL = teamCityURL + "guestAuth/app/rest/changes/id:" + changes[i].@id.text() out << new URL(changelogURL).getText().replaceAll("<\\?xml version=\"1\\.0\" encoding=\"UTF-8\" standalone=\"yes\"\\?>", "") } out << "" out.close() } jar { dependsOn copyBuildXml, createChangelog classifier = 'core' destinationDir = file 'output' } publishing { publications { mavenJava(MavenPublication) { artifact jar artifact("output/changelog.xml") { classifier "changelog" extension "xml" } artifact("output/build.properties") { classifier "build" extension "properties" } } } repositories { maven { url "file://var/www/maven" } } } repositories { maven { name 'Calclavia Maven' url 'http://calclavia.com/maven' } maven { name = "forge" url = "http://files.minecraftforge.net/maven" } maven { name "Mobius Repo" url "http://mobiusstrip.eu/maven" } maven { name "CB Repo" url "https://chickenbones.net/maven" } mavenCentral() } dependencies { if (System.getenv("TEAMCITY_BUILDCONF_NAME") == "Development") { compile group: 'dev.calclavia.universalelectricity', name: 'universal-electricity', version: "${rootProject.config.version.universalelectricity}", classifier: "dev" compile group: 'dev.calclavia.resonantengine', name: 'resonant-engine', version: "${config.version.resonantengine}", classifier: "dev" } else { compile group: 'com.calclavia.universalelectricity', name: 'universal-electricity', version: "${rootProject.config.version.universalelectricity}", classifier: "dev" compile group: 'com.calclavia.resonantengine', name: 'resonant-engine', version: "${config.version.resonantengine}", classifier: "dev" } compile group: 'codechicken', name: 'CodeChickenLib', version: "${config.version.minecraft}-${config.version.cclib}", ext: 'jar' compile group: 'codechicken', name: 'ForgeMultipart', version: "${config.version.minecraft}-${config.version.fmp}", ext: 'jar' compile group: 'codechicken', name: 'NotEnoughItems', version: "${config.version.nei}", ext: 'jar' compile group: 'codechicken', name: 'CodeChickenCore', version: "${config.version.cccore}", ext: 'jar' }