diff --git a/build.gradle b/build.gradle index 22111dda8..0294d2197 100644 --- a/build.gradle +++ b/build.gradle @@ -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. - -// 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) // read values from property file generated by GitComInf tool import org.apache.tools.ant.filters.ReplaceTokens -task prepYaCyProperties (type: Copy, dependsOn : ['runGitComInf']) { - mustRunAfter runGitComInf +task prepYaCyProperties (type: Copy) { - 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 - file("build/tmp/gitbuildnumber.properties").withReader { + file("gitbuildnumber.properties").withReader { Properties props = new Properties() props.load(it) 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") + 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' - copy { - from fdirname - include('yacyBuildProperties.java.template') - rename 'yacyBuildProperties.java.template', 'yacyBuildProperties.java' - 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 - } + from fdirname + include('yacyBuildProperties.java.template') + rename 'yacyBuildProperties.java.template', 'yacyBuildProperties.java' + 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 + into (fdirname) + } 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' } +// 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() \ No newline at end of file diff --git a/gitbuildnumber.properties b/gitbuildnumber.properties new file mode 100644 index 000000000..05ee0c4c8 --- /dev/null +++ b/gitbuildnumber.properties @@ -0,0 +1,7 @@ +# +#Wed Jan 26 14:44:44 CET 2022 +DSTAMP=20220126 +branch= +REPL_REVISION_NR=10210 +releaseNr=10210 +REPL_DATE=20220126