buildscript { repositories { mavenLocal() maven { url = 'https://files.minecraftforge.net/maven' } jcenter() mavenCentral() } // This is only here while i'm activly developing FG, Remind me to remove when we publically release configurations { classpath.resolutionStrategy { cacheDynamicVersionsFor 10, 'seconds' cacheChangingModulesFor 0, 'seconds' } } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true } } apply plugin: 'net.minecraftforge.gradle' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'maven' apply plugin: 'eclipse' // This is a simple flatdir repository for "uploadArchives" when you don't have a remote repo to target repositories { flatDir { name "fileRepo" dirs "repo" } maven { name 'DVS1 Maven FS' url 'http://dvs1.progwml6.com/files/maven' } } // This is our group. I'm cpw.mods group = "cpw.mods" // http://maven.apache.org/guides/mini/guide-naming-conventions.html // This is our actual project within the group. Note: FML has "fml" here. But this is ironchest. archivesBaseName = "ironchest" sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. compileJava { sourceCompatibility = targetCompatibility = '1.8' } minecraft { mappings channel: 'snapshot', version: mappings_version runs { client = { main "net.minecraftforge.userdev.UserdevLauncher" workingDirectory = project.file("run").canonicalPath environment "target", "fmluserdevclient" environment "assetDirectory", downloadAssets.output.absolutePath environment "FORGE_VERSION", forge_version environment "FORGE_GROUP", forge_group environment "MCP_VERSION", mappings_version environment "MC_VERSION", minecraft_version environment "MOD_CLASSES", "${sourceSets.main.output.resourcesDir}${File.pathSeparator}${sourceSets.main.output.classesDirs.join(File.pathSeparator)}" } server = { main "net.minecraftforge.userdev.UserdevLauncher" workingDirectory = project.file("run").canonicalPath environment "target", "fmluserdevserver" environment "assetDirectory", downloadAssets.output.absolutePath environment "FORGE_VERSION", forge_version environment "FORGE_GROUP", forge_group environment "MCP_VERSION", mappings_version environment "MC_VERSION", minecraft_version environment "MOD_CLASSES", "${sourceSets.main.output.resourcesDir}${File.pathSeparator}${sourceSets.main.output.classesDirs.join(File.pathSeparator)}" } } } dependencies { minecraft 'net.minecraftforge.test:forge:' + minecraft_version + '-' + forge_version compile 'net.minecraftforge.test:forge:' + minecraft_version + '-' + forge_version + ':launcher' } // IronChest uses git tagging to mark major versions. This sets up the project version to that version data def versionInfo = getGitVersion() version = minecraft_version + "-${versionInfo['IronChest.version']}" // This wrangles the resources for the jar files- stuff like textures and languages processResources { // we're omitting the .xcf files - they're development only exclude '**/*.xcf' // we only want to do search/replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'META-INF/mods.toml' // replace version and mcversion expand 'version': project.version, 'mcversion': minecraft_version } // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'META-INF/mods.toml' } // generate version.properties file from the git version data earlier doLast { def propsFile = new File(destinationDir, 'version.properties') def properties = new Properties() properties.putAll(versionInfo) properties['IronChest.build.mcversion'] = minecraft_version properties.store(propsFile.newWriter(), null) } } // Configure an upload task. this is setup for uploading to files.minecraftforge.net. There are other examples around uploadArchives { repositories.mavenDeployer { dependsOn 'build' if (project.hasProperty('forgeMavenPassword')) { repository(url: "http://files.minecraftforge.net/maven/manage/upload") { authentication(userName: project.getProperty('forgeMavenUser'), password: project.getProperty('forgeMavenPassword')) // the elvis operator. look it up. } } else { // local repo folder. Might wanna juset use gradle install if you wanans end it to maven-local repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath()) } // This is just the pom data for the maven repo pom { groupId = project.group // Force the maven upload to use the - syntax preferred at files version = "${project.version}" artifactId = project.archivesBaseName project { name project.archivesBaseName packaging 'jar' description 'IronChest' url 'https://github.com/progwml6/IronChest' scm { url 'https://github.com/progwml6/IronChest' connection 'scm:git:git://github.com/progwml6/IronChest.git' developerConnection 'scm:git:git@github.com:progwml6/IronChest.git' } issueManagement { system 'github' url 'https://github.com/progwml6/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' } } } } } } } // This is a special task for pulling the version information from git and the environment (for BUILD_NUMBER) 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("PROMOTED_NUMBER") ?: 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 }