Hi, I’m trying to use the maven-publish plugin to publish an artifact with a custom pom. The actual artifact is being generated from a source folder that is also a git repository. I’m using the gradle-git plugin and the GitLog task to extract the commit id that corresponds to the source zip. My publication snippet looks like this
publishing {
repositories distConfig
publications {
sourcePkg(MavenPublication) {
artifact source: sourceZip, classifier: "src", extension: "zip"
pom.withXml {
asNode().appendNode('scm').appendNode('tag', new File("$buildDir/$versionClassifier").text )
}
}
}
}
I am attempting to configure the pom to put in the git commit id in the pom.scm.tag element. I have created a custom task of type GitLog, that parses the last commit id and saves it into a file
task gitLog(type: GitLog) {
repoPath = "${gitDependenciesDir}/${project.name}"
maxCommits = 1
doLast {
versionFile = new File("$buildDir/$versionClassifier")
log.each {
versionFile.write( it.abbreviatedId )
}
}
}
When i run something like “gradle publishToMavenLoca”, i am getting an error that the file is not there since it seems the eneratePomFileForSourcePkgPublication task is being called before my GitLog task.
Can someone provide some insight into how i can take the output of the GitLog task and save it somehow so that i can use it in the publication to configure my pom?