buildscript { repositories { mavenCentral() maven { name = "forge" url = "https://files.minecraftforge.net/maven" } } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true // classpath 'com.matthewprenger:CurseGradle:1.0-SNAPSHOT' } } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven' // apply plugin: 'com.matthewprenger.cursegradle' ext.configFile = file('build.properties') ext.config = parseConfig(configFile) ext.priv = parseConfig(file('private.properties')) version = "${config.version}-${config.build_number}" group = "vazkii.botania" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = config.mod_name sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' minecraft { mappings channel: 'snapshot', version: '20190214-1.13.1' accessTransformer = file('src/main/resources/META-INF/botania_at.cfg') runs { client = { properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP' properties 'forge.logging.console.level': 'debug' workingDirectory project.file('run').canonicalPath source sourceSets.main } server = { properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP' properties 'forge.logging.console.level': 'debug' workingDirectory project.file('run').canonicalPath source sourceSets.main } } // replace 'GRADLE:BUILD', config.build_number // replace 'GRADLE:VERSION', config.version // replaceIn 'LibMisc.java' //I may have missed another file, though I can only find it in here. } dependencies { minecraft 'net.minecraftforge:forge:1.13.2-25.0.10' } repositories { mavenCentral() maven { name = "buildcraft" url = "https://mod-buildcraft.com/maven" } maven { name = "thiakil" url = "http://maven.thiakil.com" } maven { url = "http://dvs1.progwml6.com/files/maven" } maven { url = "http://minecraft.curseforge.com/api/maven/" } } if (System.getenv().BUILD_NUMBER != null) { //adds the build number to the end of the version string if on a build server version += ".${System.getenv().BUILD_NUMBER}" } //This here is for SCP configurations { sshAntTask } //End of the SCP config jar { manifest { attributes(["Specification-Title": "botania", "Specification-Vendor": "botania", "Specification-Version": "24.0", "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor": "botania", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],) } //rename the default output, for some better... sanity with scipts archiveName = "${baseName} ${version}.${extension}" exclude "**/*.bat" exclude "**/*.psd" exclude "**/*.exe" } dependencies { //deobfCompile "com.mod-buildcraft:buildcraft-api:7.99.17" //deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2" //deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220" //deobfCompile "thaumcraft:Thaumcraft:1.12.2:6.1.BETA26" //and a bit more for SCP sshAntTask "org.apache.ant:ant-jsch:1.7.1", "jsch:jsch:0.1.29" } task deobfJar(type: Jar) { from(sourceSets.main.output) archiveName = "${baseName} ${version}-deobf.${extension}" } task srcJar(type: Jar) { from(sourceSets.main.java) classifier = 'sources' archiveName = "${baseName} ${version}-sources.${extension}" } task apiJar(type: Jar) { // Remove sources from the api jar when MinecraftForge/ForgeGradle#369 is fixed from(sourceSets.main.allJava) from(sourceSets.main.output) include 'vazkii/botania/api/**' classifier = 'api' archiveName = "${baseName} ${version}-api.${extension}" } artifacts { archives srcJar, apiJar } /** * Increments the buildnumber in your config file, and saves it * Note: The doFirst is important, without it the build number * will be incremented every time tasks are configured, i.e every * time gradle is run on this project. */ task incrementBuildNumber { doFirst { config.build_number = (config.build_number.toString().toInteger()) + 1 configFile.withWriter { config.toProperties().store(it, "") } // todo make this flexibile - collection of supported mc versions file('web/versions.ini').append("\n${version}=${minecraft.version}") file("${config.dir_repo}/version/${minecraft.version}.txt").write("${version}") } } import java.util.regex.Pattern task sortArtifacts(type: Copy) { from jar.destinationDir into config.dir_output //Put each jar with a classifier in a subfolder with the classifier as its name eachFile { //This matcher is used to get the classifier of the jar def matcher = Pattern.compile("$config.mod_name $version-(?\\w+).jar").matcher(it.name) //Only change the destination for full matches, i.e jars with classifiers if (matcher.matches()) { def classifier = matcher.group('classifier') /* Set the relative path to change the destination, since * Gradle doesn't seem to like the absolute path being set*/ it.relativePath = it.relativePath.parent.append(false, classifier, it.name) } } } // This is the upload task from the build.xml task upload { doLast { scp('/') { fileset(file: 'web/changelog.txt') fileset(file: 'web/versions.ini') } } } // This is deploy_web task task deployWeb { doLast { scp('/') { fileset(dir: 'web') //everything from the web directory } } } def scp(String dir, Closure antFileset = {}) { ant { taskdef( name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp', classpath: configurations.sshAntTask.asPath) String dirstr = priv.scp_dir + dir Map scpArgs = [ todir : dirstr, password : priv.scp_pass, sftp: true, trust: 'yes' ] delegate.scp(scpArgs) { antFileset.delegate = delegate antFileset() } } } def parseConfig(File config) { if(config.exists()){ config.withReader { def prop = new Properties() prop.load(it) return (new ConfigSlurper().parse(prop)) } } else { return null } } /* curseforge { if(priv == null){ return } apiKey = priv.cfkey project { id = "225643" changelog = """ See http://botaniamod.net/changelog.php#${version} """ releaseType = "release" addGameVersion "${config.cf_meta_version}" relations { requiredLibrary 'baubles' optionalLibrary 'quark' optionalLibrary 'albedo' } } } */ uploadArchives { repositories { mavenDeployer { repository(url: "file://" + (System.getenv("local_maven") != null ? System.getenv("local_maven") : System.getenv("bamboo_local_maven"))) } } } // tasks.uploadArchives.dependsOn reobfJar defaultTasks 'clean', 'build', 'sortArtifacts', 'incrementBuildNumber', 'upload'