Optimize task storeGitComInf lifecycle detection

by having Gradle monitor .git directory changes
to speed up subsequent builds with min changes.
This commit is contained in:
reger24 2022-02-07 18:22:48 +01:00
parent 3867741a41
commit 8be55472d9

View File

@ -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'