ForgePatch/build.gradle

324 lines
9.6 KiB
Groovy
Raw Normal View History

2013-11-10 03:48:53 +00:00
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
2013-12-10 02:47:55 +00:00
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
2013-11-10 03:48:53 +00:00
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
2013-11-10 03:48:53 +00:00
}
}
apply plugin: "maven"
apply plugin: "net.minecraftforge.gradle.patcher"
apply plugin: "net.minecraftforge.gradle.launch4j"
2013-11-20 00:47:50 +00:00
minecraft {
version = "1.8"
//mappings = 'stable_16'
mappings = "snapshot_nodoc_20141130"
workspaceDir = "projects"
versionJson = "fml/jsons/1.8-dev.json"
buildUserdev = true
buildInstaller = true
installerVersion = "1.4"
2013-11-10 03:48:53 +00:00
def common = {
patchPrefixOriginal "../src-base/minecraft"
patchPrefixChanged "../src-work/minecraft"
mainClassClient "net.minecraft.launchwrapper.Launch"
tweakClassClient "net.minecraftforge.fml.common.launcher.FMLTweaker"
mainClassServer "net.minecraft.launchwrapper.Launch"
tweakClassServer "net.minecraftforge.fml.common.launcher.FMLServerTweaker"
}
projects {
// fml {
// rootDir 'fml'
// patchDir "fml/patches/minecraft"
// patchAfter "clean"
// genPatchesFrom "clean"
//
// with common
// }
forge {
rootDir "."
patchDir "patches/minecraft"
patchAfter "clean"
genPatchesFrom "clean"
with common
}
2013-11-10 03:48:53 +00:00
}
}
group = 'net.minecraftforge'
version = getVersionFromJava(file("src/main/java/net/minecraftforge/common/ForgeVersion.java"))
extractForgeSources { exclude "**/SideOnly.java", "**/Side.java" }
genGradleProjects { addTestCompileDep "junit:junit:4.12" }
processJson {
releaseJson = "fml/jsons/1.8-rel.json"
addReplacements([
"@minecraft_version@": project.minecraft.version,
"@version@": project.version,
"@project@": "forge",
"@artifact@": "net.minecraftforge:forge:${project.version}",
"@universal_jar@": { outputJar.archiveName },
"@timestamp@": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
])
2013-11-10 03:48:53 +00:00
}
task changelog(type: JenkinsChangelog) {
2013-11-10 03:48:53 +00:00
// skip if there is no forge jenkins pass
onlyIf {
project.hasProperty('forgeJenkinsPass')
project.file("build/distributions/${project.name}-${project.version}-changelog.txt").text = ""
}
outputs.upToDateWhen { false } // never up to date
serverRoot = "http://ci.jenkins.minecraftforge.net/"
jobName = "minecraftforge"
targetBuild = System.env['BUILD_NUMBER'] ?: 0;
authName = "console_script"
authPassword = project.hasProperty('forgeJenkinsPass') ? project.getProperty('forgeJenkinsPass') : "";
output = "build/distributions/${project.name}-${project.version}-changelog.txt"
}
task crowdin(type: CrowdinDownload) {
output = "build/crowdin.zip"
projectId = 'minecraft-forge'
extract = false // we wanna keep it as a zip. not extract it to a folder named "crowdin.zip"
// task auomatically skips if this is null
if (project.hasProperty('crowdinKey'))
apiKey = project.crowdinKey
2013-11-10 03:48:53 +00:00
}
def extraTxts = [
changelog, // yeah we can do thi, because gradle and groovy are awesome
"fml/LICENSE-fml.txt",
"fml/CREDITS-fml.txt",
"MinecraftForge-Credits.txt",
"MinecraftForge-License.txt",
"Paulscode SoundSystem CodecIBXM License.txt",
"Paulscode IBXM Library License.txt"
]
2014-10-15 06:07:15 +00:00
outputJar {
classifier = 'universal'
from extraTxts
// add crowdin locales
from { crowdin.getDidWork() ? zipTree(crowdin) : null}
dependsOn 'crowdin'
manifest.attributes([
"Main-Class": "net.minecraftforge.fml.relauncher.ServerLaunchWrapper",
"TweakClass": "net.minecraftforge.fml.common.launcher.FMLTweaker",
"Class-Path": getServerClasspath(file("fml/jsons/1.8-rel.json"))
])
}
installer {
classifier = 'installer'
from extraTxts
from "src/main/resources/forge_logo.png"
rename "forge_logo\\.png", "big_logo.png"
}
task signUniversal(type: SignJar, dependsOn: 'outputJar') {
onlyIf {
project.hasProperty('jarsigner')
}
def jarsigner = [:];
if (project.hasProperty('jarsigner'))
jarsigner = project.jarsigner;
alias = 'forge'
exclude "paulscode/**"
storePass = jarsigner.storepass
keyPass = jarsigner.keypass
keyStore = jarsigner.keystore
inputFile = outputJar.archivePath
outputFile = outputJar.archivePath
}
uploadArchives.dependsOn signUniversal
build.dependsOn signUniversal
// launch4j
2014-10-15 06:07:15 +00:00
2013-11-19 20:17:46 +00:00
launch4j {
jar = installer.archivePath.canonicalPath
outfile = file("build/distributions/${project.name}-${project.version}-installer-win.exe").canonicalPath
icon = file('icon.ico').canonicalPath
manifest = file('l4jManifest.xml').canonicalPath
2013-11-19 20:17:46 +00:00
jreMinVersion = '1.6.0'
initialHeapPercent = 5;
maxHeapPercent = 100;
}
tasks.generateXmlConfig.dependsOn installer
tasks.build.dependsOn 'launch4j'
// MAVEN
artifacts {
archives changelog.output
archives file("build/distributions/${project.name}-${project.version}-installer-win.exe")
2013-11-19 20:17:46 +00:00
}
2013-11-10 03:48:53 +00:00
uploadArchives {
2013-11-20 00:47:50 +00:00
repositories.mavenDeployer {
dependsOn 'build'
if (project.hasProperty('forgeMavenPass'))
{
repository(url: "http://files.minecraftforge.net/maven/manage/upload") {
2015-08-01 19:08:04 +00:00
authentication(userName: "forge", password: project.getProperty('forgeMavenPass')) // the elvis operator. look it up.
2013-11-20 00:47:50 +00:00
}
}
else
{
// local repo folder. Might wanna juset use gradle install if you wanans end it to maven-local
2013-11-20 00:47:50 +00:00
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
}
2013-11-10 03:48:53 +00:00
2013-11-20 00:47:50 +00:00
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'Minecraft Forge API'
2013-11-20 00:47:50 +00:00
url 'https://github.com/MinecraftForge/MinecraftForge'
2013-11-10 03:48:53 +00:00
scm {
url 'https://github.com/MinecraftForge/MinecraftForge'
connection 'scm:git:git://github.com/MinecraftForge/MinecraftForge.git'
developerConnection 'scm:git:git@github.com:MinecraftForge/MinecraftForge.git'
2013-11-10 03:48:53 +00:00
}
2013-11-20 00:47:50 +00:00
issueManagement {
system 'github'
url 'https://github.com/MinecraftForge/MinecraftForge/issues'
2013-11-20 00:47:50 +00:00
}
licenses {
license {
name 'Forge Public License'
url 'https://raw.github.com/MinecraftForge/MinecraftForge/master/MinecraftForge-License.txt'
distribution 'repo'
}
2013-11-20 00:47:50 +00:00
}
developers {
developer {
id 'cpw'
name 'cpw'
roles { role 'developer' }
}
developer {
id 'LexManos'
name 'Lex Manos'
roles { role 'developer' }
}
developer {
id 'AbrarSyed'
name 'Abrar Syed'
roles { role 'contributor' }
}
2013-11-20 00:47:50 +00:00
}
2013-11-10 03:48:53 +00:00
}
}
}
}
// HELPER METHODS
import groovy.json.JsonSlurper;
String getServerClasspath(File file)
{
def node = new JsonSlurper().parse(file);
def out = new StringBuilder()
node.versionInfo.libraries.each { lib ->
if (lib.serverreq)
{
// group : artifact : version
def split = lib.name.split(':')
def group = split[0].replace('.', '/')
def artifact = split[1]
def version = split[2]
out += "libraries/$group/$artifact/$version/$artifact-${version}.jar "
}
}
out += "minecraft_server.${minecraft.version}.jar"
return out.toString();
}
String getVersionFromJava(File file)
{
String major = "0";
String minor = "0";
String revision = "0";
String build = "0";
String prefix = "public static final int";
file.eachLine{ String s ->
s = s.trim();
if (s.startsWith(prefix))
{
s = s.substring(prefix.length(), s.length() - 1);
s = s.replace('=', ' ').replace("Version", "").replaceAll(" +", " ").trim();
String[] pts = s.split(" ");
if (pts[0].equals("major")) major = pts[pts.length - 1];
else if (pts[0] == "minor") minor = pts[pts.length - 1];
else if (pts[0] == "revision") revision = pts[pts.length - 1];
}
}
if (System.getenv().containsKey("BUILD_NUMBER"))
{
build = System.getenv("BUILD_NUMBER");
}
String branch = null;
if (!System.getenv().containsKey("GIT_BRANCH"))
{
// TODO: use grgit
branch = "git rev-parse --abbrev-ref HEAD".execute().text.trim()
}
else
{
branch = System.getenv("GIT_BRANCH");
branch = branch.substring(branch.lastIndexOf('/') + 1);
}
def out = "${minecraft.version.replace('-', '_')}-$major.$minor.$revision.$build"
if (branch && branch != 'master' && branch != 'HEAD')
out += "-$branch"
return out;
}
2015-06-29 17:56:23 +00:00
// re-add old tasks for jenkins compat
// should be remvoed, and the jenkisn fixed when no longer building with FG 1.2
task setupForge { dependsOn 'setup' }
task buildPackages { dependsOn 'build' }