Tweak build file slightly - allow passing buildNumber using gradle parameters (-PbuildNumber=...) and provide a "resetBuildNumber" function to reset the buildNumber to zero in the ForgeVersion file. Means builds can be reproducible in-IDE.
This commit is contained in:
parent
7f6f2f0ec1
commit
f4750ae2bf
1 changed files with 10 additions and 9 deletions
17
build.gradle
17
build.gradle
|
@ -89,7 +89,7 @@ task changelog(type: JenkinsChangelog) {
|
||||||
outputs.upToDateWhen { false } // never up to date
|
outputs.upToDateWhen { false } // never up to date
|
||||||
serverRoot = "http://ci.jenkins.minecraftforge.net/"
|
serverRoot = "http://ci.jenkins.minecraftforge.net/"
|
||||||
jobName = "minecraftforge"
|
jobName = "minecraftforge"
|
||||||
targetBuild = System.env['BUILD_NUMBER'] ?: 0;
|
targetBuild = System.env['BUILD_NUMBER'] ?: project.ext.properties.buildNumber ?:0;
|
||||||
authName = "console_script"
|
authName = "console_script"
|
||||||
authPassword = project.hasProperty('forgeJenkinsPass') ? project.getProperty('forgeJenkinsPass') : "";
|
authPassword = project.hasProperty('forgeJenkinsPass') ? project.getProperty('forgeJenkinsPass') : "";
|
||||||
output = "build/distributions/${project.name}-${project.version}-changelog.txt"
|
output = "build/distributions/${project.name}-${project.version}-changelog.txt"
|
||||||
|
@ -218,14 +218,13 @@ artifacts {
|
||||||
|
|
||||||
task ciWriteBuildNumber << {
|
task ciWriteBuildNumber << {
|
||||||
def file = file("src/main/java/net/minecraftforge/common/ForgeVersion.java");
|
def file = file("src/main/java/net/minecraftforge/common/ForgeVersion.java");
|
||||||
def bn = System.getenv("BUILD_NUMBER")?:0;
|
def bn = System.getenv("BUILD_NUMBER")?:project.ext.properties.buildNumber?:0;
|
||||||
def outfile = "";
|
def outfile = "";
|
||||||
def ln = System.getProperty('line.separator')
|
def ln = System.getProperty('line.separator')
|
||||||
|
|
||||||
file.eachLine{ String s ->
|
file.eachLine{ String s ->
|
||||||
if (s.contains("buildVersion") && s.contains("= 0;")) {
|
if (s.matches("^ public static final int buildVersion = [\\d]+;\$"))
|
||||||
s = " public static final int buildVersion = ${bn};";
|
s = " public static final int buildVersion = ${bn};";
|
||||||
}
|
|
||||||
outfile += (s+ln);
|
outfile += (s+ln);
|
||||||
}
|
}
|
||||||
file.write(outfile);
|
file.write(outfile);
|
||||||
|
@ -345,10 +344,8 @@ String getVersionFromJava(File file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.getenv().containsKey("BUILD_NUMBER"))
|
build = System.getenv("BUILD_NUMBER") ?: project.ext.properties.buildNumber ?: 0
|
||||||
{
|
|
||||||
build = System.getenv("BUILD_NUMBER");
|
|
||||||
}
|
|
||||||
|
|
||||||
String branch = null;
|
String branch = null;
|
||||||
if (!System.getenv().containsKey("GIT_BRANCH"))
|
if (!System.getenv().containsKey("GIT_BRANCH"))
|
||||||
|
@ -370,6 +367,10 @@ String getVersionFromJava(File file)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task resetBuildNumber << {
|
||||||
|
project.ext.properties.buildNumber = 0;
|
||||||
|
ciWriteBuildNumber.execute()
|
||||||
|
}
|
||||||
// re-add old tasks for jenkins compat
|
// re-add old tasks for jenkins compat
|
||||||
// should be remvoed, and the jenkisn fixed when no longer building with FG 1.2
|
// should be remvoed, and the jenkisn fixed when no longer building with FG 1.2
|
||||||
task setupForge { dependsOn 'setup' }
|
task setupForge { dependsOn 'setup' }
|
||||||
|
|
Loading…
Reference in a new issue