buildscript { repositories { mavenCentral() maven { name "forge" url "https://files.minecraftforge.net/maven" } } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.0.+' // classpath 'com.matthewprenger:CurseGradle:1.0-SNAPSHOT' } } plugins { id 'org.hidetake.ssh' version '2.10.1' } 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: "${config.mc_mappings}" accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') runs { client { properties 'forge.logging.markers': 'REGISTRIES,REGISTRYDUMP' properties 'forge.logging.console.level': 'debug' properties 'fml.earlyprogresswindow': 'false' workingDirectory project.file('run') mods { botania { source sourceSets.main } } } server { properties 'forge.logging.markers': 'REGISTRIES,REGISTRYDUMP' properties 'forge.logging.console.level': 'debug' workingDirectory project.file('run') mods { botania { source sourceSets.main } } } data { properties 'forge.logging.markers': 'REGISTRIES,REGISTRYDUMP' properties 'forge.logging.console.level': 'debug' properties 'fml.earlyprogresswindow': 'false' workingDirectory project.file('run') mods { botania { source sourceSets.main } } args '--mod', 'botania', '--all', '--output', file('src/generated/resources/') } } // 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. } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { mavenCentral() maven { name "yarn2mcp" url "https://maven.tterrag.com/" } maven { url "https://maven.blamejared.com" } maven { url "https://dvs1.progwml6.com/files/maven" } maven { url "https://minecraft.curseforge.com/api/maven/" } maven { name "curios" url "https://maven.theillusivec4.top/" } } dependencies { minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}" compile fg.deobf("vazkii.patchouli:Patchouli:1.1-25.4") { transitive = false } compileOnly fg.deobf("mezz.jei:jei-1.15.1:6.0.0.1:api") runtimeOnly fg.deobf("mezz.jei:jei-1.15.1:6.0.0.1") compileOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.1-2.0-beta:api") runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.1-2.0-beta") } 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}" } jar { manifest { attributes(["Specification-Title": "botania", "Specification-Vendor": "botania", "Specification-Version": "1", "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" } processResources { // Exclude datagenerator .cache directory exclude '.cache' filesMatching('data/botania/patchouli_books/lexicon/book.json') { filter { it.replaceAll("buildNumber", config.build_number) } } } 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, "") } file('web/versions.ini').append("\n${project.version}=${config.mc_version}") file("${config.dir_repo}/version/${config.mc_version}.txt").write("${project.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) } } } // SCP servers remotes { if (priv != null) web { host = 'botaniamod.net' user = priv.scp_user password = priv.scp_pass knownHosts = allowAnyHosts } } task upload { doLast { ssh.run { session(remotes.web) { put from: 'web/changelog.txt', into: priv.scp_dir + "/changelog.txt" put from: 'web/versions.ini', into: priv.scp_dir + "/versions.ini" } } } } task deployWeb { doLast { ssh.run { session(remotes.web) { def parent = file('web').toPath() for (f in fileTree(dir: 'web')) { def rel = parent.relativize(f.toPath()).toString().replace(File.separator, '/') def dest = priv.scp_dir + rel put from: f, into: dest } } } } } 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.mc_version}" relations { requiredLibrary 'curios' 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', 'runData', 'build', 'sortArtifacts', 'incrementBuildNumber', 'upload'