Changed Gradle build regarding prepYaCyProperties to be more reliable

The properties contain info from the local git (the last commitDate and the number of commints since last distribution-label +9000)

currently Gradle build script must execute external jar (libbuild/GitComInf-All.jar) which creates a property file. other build targets relay on the properties - so here is a currently a timing problem.

1. nice would be we could get rid of the whole gitbuildnumber thing on work with current date etc.

Changed it now to create the property file at the end - after a build
so during init no external jar execution is required but just reading the prop file.
At least a bit more stable.

in addition I include it in the repository so that a fresh pime build has it available (even some measure included to use some fake if file is missing)
pull/461/head
reger24 3 years ago
parent bec019049e
commit 0e7251b445

@ -149,40 +149,39 @@ jar {
shadowJar.zip64 = true // saw build error: Execution failed for task ':shadowJar'. shadow.org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries. shadowJar.zip64 = true // saw build error: Execution failed for task ':shadowJar'. shadow.org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries.
// runs the support tool which creates gitbuildnumber.properties from info of local git repository
task runGitComInf(type: JavaExec) {
classpath = files('libbuild/GitComInf-all.jar')
args = [project.projectDir.getPath(), project.projectDir.getPath() + "/build/tmp/gitbuildnumber.properties"]
mainClass = 'GitComInf'
}
// prepare yacyBuildProperties.java from template (needed after commits or new versions) // prepare yacyBuildProperties.java from template (needed after commits or new versions)
// read values from property file generated by GitComInf tool // read values from property file generated by GitComInf tool
import org.apache.tools.ant.filters.ReplaceTokens import org.apache.tools.ant.filters.ReplaceTokens
task prepYaCyProperties (type: Copy, dependsOn : ['runGitComInf']) { task prepYaCyProperties (type: Copy) {
mustRunAfter runGitComInf
def propfile = "build/tmp/gitbuildnumber.properties"; def propfile = "gitbuildnumber.properties";
if (project.file(propfile).exists()) { // must check otherwise any action may stop after clean on this error if (project.file(propfile).exists()) { // must check otherwise any action may stop after clean on this error
file("build/tmp/gitbuildnumber.properties").withReader { file("gitbuildnumber.properties").withReader {
Properties props = new Properties() Properties props = new Properties()
props.load(it) props.load(it)
project.ext.filterTokens.putAll(props) project.ext.filterTokens.putAll(props)
} }
} else } else { // on missing properties file use generic data
logger.error("prepYaCyProperties: file " + propfile + " is missing, you should re-run runGitComInf") logger.error("prepYaCyProperties: file " + propfile + " is missing, you should re-run runGitComInf")
Properties props = new Properties()
String Dstr = new Date().format("yyyyMMDD")
String Tstr = new Date().format("yyyyMMDD-HHmmss")
props.put("branch","-dev")
props.put ("DSTAMP",Dstr )
props.put ("REPL_DATE",Dstr)
props.put ("REPL_REVISION_NR",Tstr)
props.put ("releaseNr",Tstr)
project.ext.filterTokens.putAll(props)
}
String fdirname = sourceSets.main.java.srcDirs[0].name + '/net/yacy/peers/operation' String fdirname = sourceSets.main.java.srcDirs[0].name + '/net/yacy/peers/operation'
copy { from fdirname
from fdirname include('yacyBuildProperties.java.template')
include('yacyBuildProperties.java.template') rename 'yacyBuildProperties.java.template', 'yacyBuildProperties.java'
rename 'yacyBuildProperties.java.template', 'yacyBuildProperties.java' filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.ext.filterTokens)
into (fdirname) filter(ReplaceTokens, tokens: [REPL_VERSION: version, REPL_PKGMANAGER:"false", REPL_RESTARTCMD: "/etc/init.d/yacy restart"]) // gradle.project.version + some defaults from ant
into (fdirname)
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.ext.filterTokens)
filter(ReplaceTokens, tokens: [REPL_VERSION: version, REPL_PKGMANAGER:"false", REPL_RESTARTCMD: "/etc/init.d/yacy restart"]) // gradle.project.version + some defaults from ant
}
} }
compileJava.dependsOn(prepYaCyProperties) // must be executed before compile (due to source template filtering) compileJava.dependsOn(prepYaCyProperties) // must be executed before compile (due to source template filtering)
@ -448,3 +447,22 @@ task distWinInstaller (dependsOn:['copyFilesToDistDir','copyDependenciesForDistr
tasks.findByName('createInstaller').mustRunAfter 'prepNsis' tasks.findByName('createInstaller').mustRunAfter 'prepNsis'
} }
// runs the support tool which creates gitbuildnumber.properties from info of local git repository
task storeGitComInf(type: JavaExec) {
mustRunAfter(build)
classpath = files('libbuild/GitComInf-all.jar')
args = [project.projectDir.getPath(), project.projectDir.getPath() + "/gitbuildnumber.properties"]
mainClass = 'GitComInf'
}
//--- build aliases : define a synonym here if you want a shortcut to run multiple targets
// workaround to run storeGitComInf after a build without adding arbitray dependencies
// this makes sure gitbuildnumber.properties is availabel and up-to-date
def buildAliases = [
'build' : ['build','storeGitComInf']
]
def expandedTaskList = []
gradle.startParameter.taskNames.each {
expandedTaskList << (buildAliases[it] ? buildAliases[it] : it)
}
gradle.startParameter.taskNames = expandedTaskList.flatten()

@ -0,0 +1,7 @@
#
#Wed Jan 26 14:44:44 CET 2022
DSTAMP=20220126
branch=
REPL_REVISION_NR=10210
releaseNr=10210
REPL_DATE=20220126
Loading…
Cancel
Save