From 8be55472d9ee9b48e2af2fb1429a6c3b620be5f0 Mon Sep 17 00:00:00 2001 From: reger24 <11603289+reger24@users.noreply.github.com> Date: Mon, 7 Feb 2022 18:22:48 +0100 Subject: [PATCH] Optimize task storeGitComInf lifecycle detection by having Gradle monitor .git directory changes to speed up subsequent builds with min changes. --- build.gradle | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index c4838b9ba..482e1c231 100644 --- a/build.gradle +++ b/build.gradle @@ -150,7 +150,7 @@ jar { shadowJar.zip64 = true // saw build error: Execution failed for task ':shadowJar'. shadow.org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries. // 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 storeGitComInf tool import org.apache.tools.ant.filters.ReplaceTokens task prepYaCyProperties (type: Copy) { @@ -162,7 +162,7 @@ task prepYaCyProperties (type: Copy) { project.ext.filterTokens.putAll(props) } } 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 storeGitComInf") Properties props = new Properties() String Dstr = new Date().format("yyyyMMDD") String Tstr = new Date().format("yyyyMMDD-HHmmss") @@ -177,7 +177,7 @@ task prepYaCyProperties (type: Copy) { 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 + filter(ReplaceTokens, tokens: [REPL_VERSION: project.version, REPL_PKGMANAGER:"false", REPL_RESTARTCMD: "/etc/init.d/yacy restart"]) // gradle.project.version + some defaults from ant into (fdirname) } @@ -269,7 +269,7 @@ distributions { // String rNr = project.ext.filterTokens.get('REPL_REVISION_NR') // String branch = project.ext.filterTokens.get('branch') // - // distributionBaseName = 'yacy' + branch + '_v' + version + '_' + Dst + '_' + rNr + // distributionBaseName = 'yacy' + branch + '_v' + project.version + '_' + Dst + '_' + rNr contents { // fyi: content completed by copyFilesToDistDir from "${buildDir}/RELEASE/MAIN" @@ -340,7 +340,7 @@ task packageDistTar (type : Tar, dependsOn : ['copyDependenciesForDistribution', String Dst = project.ext.filterTokens.get('REPL_DATE') String rNr = project.ext.filterTokens.get('REPL_REVISION_NR') String branch = project.ext.filterTokens.get('branch') - String destName = 'yacy' + branch + '_v' + version + '_' + Dst + '_' + rNr + '.tar.gz' // ! Gradle would use ext .tgz (archiveExtension.get()) + String destName = 'yacy' + branch + '_v' + project.version + '_' + Dst + '_' + rNr + '.tar.gz' // ! Gradle would use ext .tgz (archiveExtension.get()) archiveFileName = destName destinationDirectory = layout.buildDirectory.dir('distributions/legacyDistFiles') @@ -365,7 +365,7 @@ task packageDist (dependsOn : ['packageDistZip','packageDistTar'],group:'distrib // configure Javadoc task tasks.withType (Javadoc) { destinationDir project.file("javadoc") - title = "YaCy " + version + " API Documentation" + title = "YaCy " + project.version + " API Documentation" failOnError = false options.addStringOption("encoding","UTF-8" ) // or any reason to keep the old "iso-8859-1" ? classpath = configurations.compileClasspath @@ -410,7 +410,7 @@ task prepNsis (type: Copy, dependsOn: ['prepYaCyProperties']) { into "${buildDir}/RELEASE/WINDOWS" filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.ext.filterTokens) - filter(ReplaceTokens, tokens: [REPL_VERSION: version]) + filter(ReplaceTokens, tokens: [REPL_VERSION: project.version]) copy { from projectDir @@ -427,7 +427,14 @@ task distWinInstaller (dependsOn:['copyFilesToDistDir','copyDependenciesForDistr // runs the support tool which creates gitbuildnumber.properties from info of local git repository task storeGitComInf(type: JavaExec) { + outputs.file "gitbuildnumber.properties" mustRunAfter(build) + if (file(".git").exists()) { // check if this is a git repos + inputs.files ( fileTree(".git") { + include "refs/**/*" // these two should work and change after commit + include "index" + } ) + } classpath = files('libbuild/GitComInf-1.0-all.jar') args = [project.projectDir.getPath(), project.projectDir.getPath() + "/gitbuildnumber.properties"] mainClass = 'GitComInf'