Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buildscript {
- repositories {
- jcenter()
- maven {
- name = "forge"
- url = "http://files.minecraftforge.net/maven"
- }
- }
- dependencies {
- classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
- }
- }
- plugins {
- id "org.sonarqube" version "2.3"
- id "com.matthewprenger.cursegradle" version "1.0.7"
- }
- repositories {
- maven {
- name 'DVS1 Maven FS'
- url 'http://dvs1.progwml6.com/files/maven'
- }
- maven {
- url 'http://dogforce-games.com/maven'
- }
- }
- sonarqube {
- properties{
- property "sonar.host.url", "http://home.kk-sc.de:9000"
- property "sonar.sourceEncoding", "UTF-8"
- property "sonar.projectName", "Minecolonies"
- property "sonar.branch", System.getenv()['TEAMCITY_BRANCH'] != null ? System.getenv()['TEAMCITY_BRANCH'] : System.getenv()['TRAVIS_BRANCH']
- }
- }
- apply plugin: 'idea'
- apply plugin: 'net.minecraftforge.gradle.forge'
- apply plugin: 'jacoco'
- jacocoTestReport {
- reports {
- xml.enabled true
- }
- }
- sourceSets {
- api {
- java {
- srcDir 'src/api/java'
- }
- resources {
- srcDir 'src/api/resources'
- }
- }
- blockOut {
- java {
- srcDir 'src/blockout/java'
- }
- resources {
- srcDir 'src/blockout/resources'
- }
- compileClasspath += sourceSets.api.compileClasspath
- }
- structures {
- java {
- srcDir 'src/structures/java'
- }
- resources {
- srcDir 'src/structures/resources'
- }
- compileClasspath += sourceSets.api.compileClasspath
- }
- main {
- java {
- srcDir 'src/main/java'
- }
- resources {
- srcDir 'src/main/resources'
- }
- compileClasspath += sourceSets.structures.output
- compileClasspath += sourceSets.blockOut.output
- compileClasspath += sourceSets.api.output
- }
- test {
- java {
- srcDir 'src/test/java'
- }
- resources {
- srcDir 'src/test/resources'
- }
- }
- }
- ext.configFile = file "build.properties"
- configFile.withReader {
- def prop = new Properties()
- prop.load(it)
- ext.config = new ConfigSlurper().parse prop
- }
- dependencies {
- deobfCompile "slimeknights.mantle:Mantle:${config.minecraft_version}-${config.mantle_version}"
- deobfCompile "slimeknights:TConstruct:${config.minecraft_version}-${config.tconstruct_version}"
- structuresCompile sourceSets.api.output
- //blockOutCompile sourceSets.api.output
- deobfCompile "gigaherz.guidebook:Guidebook-${config.minecraft_version}:${config.guidebook_version}"
- testCompile sourceSets.structures.output
- testCompile sourceSets.blockOut.output
- testCompile 'junit:junit:4.11'
- testCompile "org.mockito:mockito-core:1.+"
- testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.6.5'
- testCompile group: 'org.powermock', name: 'powermock-api-mockito', version: '1.6.5'
- testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
- compile 'com.intellij:annotations:+@jar'
- }
- group = "com.minecolonies"
- config.buildnumber = System.getenv()['BUILD_NUMBER'] != null ? System.getenv()['BUILD_NUMBER'] : System.getenv()['TRAVIS_BUILD_NUMBER']
- if (project.hasProperty("teamcity")) {
- config.buildnumber = project.teamcity["teamcity.build.id"]
- }
- version = "${config.minecraft_version}-${config.minecolonies_major}.${config.minecolonies_minor}.${config.buildnumber}"
- sourceCompatibility = '1.8'
- targetCompatibility = '1.8'
- minecraft {
- version = config.minecraft_version + "-" + config.forge_version
- runDir = "run"
- mappings = "${config.minecolonies_mappings}"
- replaceIn "lib/Constants.java"
- replace "@VERSION@", project.version
- // Set the jar signature in code prior to compilation, if it exists as a build property
- if (project.hasProperty("signature")) {
- replace "@FINGERPRINT@", project.signature
- }
- }
- processResources {
- inputs.property "version", project.version
- inputs.property "mcversion", project.minecraft.version
- from(sourceSets.main.resources.srcDirs) {
- include 'mcmod.info'
- expand 'version': project.version, 'mcversion': project.minecraft.version
- }
- from(sourceSets.main.resources.srcDirs) {
- exclude 'mcmod.info'
- }
- }
- compileJava {
- options.encoding = 'UTF-8'
- options.compilerArgs << "-Xlint"
- }
- task apiJar(type: Jar) {
- from sourceSets.api.output
- classifier 'api'
- }
- task blockOutJar(type: Jar) {
- from sourceSets.blockOut.output
- classifier 'blockOut'
- }
- task structuresJar(type: Jar){
- from sourceSets.structures.output
- classifier 'structures'
- }
- task deobfJar(type: Jar) {
- from sourceSets.main.output
- appendix = 'deobf'
- }
- task incrementBuildNumber() {
- dependsOn "reobf"
- doLast {
- config.minecolonies_build = (config.minecolonies_build.toString().toInteger()) + 1
- configFile.withWriter {
- config.toProperties().store(it, "")
- }
- }
- }
- jar {
- from sourceSets.api.output
- from sourceSets.blockOut.output
- from sourceSets.structures.output
- from sourceSets.main.output
- dependsOn apiJar
- dependsOn blockOutJar
- dependsOn structuresJar
- dependsOn deobfJar
- appendix = 'universal'
- archiveName = "minecolonies-universal-" + project.version + ".jar"
- manifest {
- attributes 'FMLAT': "minecolonies_at.cfg"
- }
- }
- javadoc {
- source += sourceSets.api.allSource
- source += sourceSets.blockOut.allSource
- source += sourceSets.structures.allSource
- }
- idea {
- module {
- inheritOutputDirs = true
- }
- }
- task copyToLib(type: Copy) {
- // into "build/lib"
- into "lib"
- from configurations.runtime
- }
- task runCheckStyle(type: Checkstyle) {
- description 'Runs Checkstyle inspection against Minecolonies sourcesets.'
- group = 'Code Quality'
- ignoreFailures = true
- showViolations = false
- source 'src/main/java'
- include '**/*.java'
- exclude '**/com/minecolonies/blockout/**'
- classpath = files()
- }
- task runPMD(type: Pmd) {
- description 'Runs PMD inspection against Minecolonies sourcesets.'
- group = 'Code Quality'
- ignoreFailures = true
- source 'src/main/java'
- include '**/*.java'
- exclude '**/com/minecolonies/blockout/**'
- classpath = files()
- }
- task runSonar() {
- dependsOn runCheckStyle, runPMD
- description 'Runs the equivalent of a SonarQube analysis directly in the build process. Calls runCheckStyle and runPMD'
- group = 'Code Quality'
- }
- task signJar(type: SignJar, dependsOn: reobfJar) {
- onlyIf { // Skip the task if our secret data isn't available
- project.hasProperty('keyStore')
- }
- if (project.hasProperty('keyStore')) {
- keyStore = project.keyStore // This needs to be a path to the keystore file
- alias = project.keyStoreAlias
- storePass = project.keyStorePass
- keyPass = project.keyStoreKeyPass
- inputFile = jar.archivePath
- outputFile = jar.archivePath
- }
- }
- build.dependsOn signJar
- curseforge {
- if (System.getenv().CURSEAPIKEY != null && System.getenv().CURSERELEASETYPE != null)
- {
- apiKey = System.getenv().CURSEAPIKEY
- project {
- id = '245506'
- changelog = file('build/changelog.md')
- changelogType = 'markdown'
- releaseType = System.getenv().CURSERELEASETYPE
- addArtifact deobfJar
- }
- }
- else
- {
- logger.lifecycle("Cannot run the CurseUpload sequence. No API-Key or release type has been provided.")
- }
- }
- task("createChangelog") {
- group = 'upload'
- doLast {
- def teamCityURL = "http://teamcity.minecolonies.com/"
- def file = new FileOutputStream("build/changelog.md")
- def out = new BufferedOutputStream(file)
- def changesXML = new XmlSlurper().parse(teamCityURL + "guestAuth/app/rest/changes?locator=build:(id:" + teamcity["teamcity.build.id"] + ")")
- def changes = changesXML.change
- println("createChangelog: Identified " + changes.size() + " changes to be written into the changelog.")
- out << "# Minecolonies Changelog \n"
- out << "## Version: _" + version + "_ \n"
- if (changes.size() > 0) {
- for (int i = 0; i < changes.size(); i++) {
- def changeDetailsURL = teamCityURL + "guestAuth/app/rest/changes/id:" + changes[i][email protected]()
- def changeDetailsXml = new XmlSlurper().parse(changeDetailsURL)
- def changeComment = changeDetailsXml.comment.text().trim()
- out << "* " + changeComment + "\n"
- }
- } else {
- out << "No Changes detected!"
- }
- out.close()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement