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.1-SNAPSHOT' } } apply plugin: 'forge' repositories { flatDir { name "fileRepo" dirs "repo" } } def versionInfo = getGitVersion() version = "${versionInfo['IronChest.version']}" group= "cpw.mods.ironchest" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "ironchest" minecraft { version = "1.7.2-10.12.0.1024" } logger.lifecycle "IronChest "+version processResources { exclude '**/*.xcf' // 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' } // generate version properties file doLast { def propsFile = new File(destinationDir, 'version.properties') def properties = new Properties() properties.putAll(versionInfo) properties['IronChest.build.mcversion'] = project.minecraft.version properties.store(propsFile.newWriter(), null) } } jar { appendix = 'universal' } task sourceJar(type: Jar) { from sourceSets.main.allSource appendix = 'src' } // because the normal default jar task has been modified to be obfuscated task deobfJar(type: Jar) { from sourceSets.main.output appendix = 'deobf' } artifacts { archives sourceJar archives deobfJar } uploadArchives { repositories { if (project.hasProperty("filesmaven")) { logger.info('Publishing to files server') mavenDeployer { configuration = configurations.deployJars repository(url: project.filesmaven.url) { authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key) } pom { groupId = project.group version = project.version artifactId = project.archivesBaseName project { name project.archivesBaseName packaging 'jar' description 'IronChest' url 'https://github.com/cpw/IronChest' scm { url 'https://github.com/cpw/IronChest' connection 'scm:git:git://github.com/cpw/IronChest.git' developerConnection 'scm:git:git@github.com:cpw/IronChest.git' } issueManagement { system 'github' url 'https://github.com/cpw/IronChest/issues' } licenses { license { name 'GNU Public License (GPL), Version 3.0' url 'http://www.gnu.org/licenses/gpl-3.0.txt' distribution 'repo' } } developers { developer { id 'cpw' name 'cpw' roles { role 'developer' } } } } } } } else { logger.info('Publishing to repo folder') mavenDeployer { repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath()) } } } } // version def getGitVersion() { def out = [:] // call git command. def outStream = new ByteArrayOutputStream() def result = exec { executable = 'git' args = [ 'describe', '--long', "--match=[^(jenkins)]*"] standardOutput = outStream } def fullVersion = outStream.toString().trim() def matcher = fullVersion =~ /(\d+).(\d+)-(\d+)-(.*)/ def maj = matcher[0][1] def min = matcher[0][2] def rev = matcher[0][3] def bn = System.getenv("BUILD_NUMBER") ?: "1" out['IronChest.build.major.number'] = maj.toString() out['IronChest.build.minor.number'] = min.toString() out['IronChest.build.revision.number'] = rev.toString() out['IronChest.build.githash'] = matcher[0][4].toString() out['IronChest.build.number' ] = bn.toString() out['IronChest.version' ] = "${maj}.${min}.${rev}.${bn}".toString() return out }