I am using the maven publish plugin as below inside a subproject
subprojects{
apply plugin: 'maven-publish'
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
}
The version is decided dynamically from the properties file which is loaded under allprojects as below
allprojects {
ant.loadproperties(srcFile: "${rootDir}/version.properties")
}
If I set the version directly as below , publishToMavenLocal works perfectly fine.
But when the version is set as part of figuring out the task in the DAG, it fails to find the jar and throws error
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(release)) {
version "1.00.00.${buildVersion}"
ant.propertyfile(file: "${rootDir}/version.properties" ) {
entry(key: "buildVersion", type: "int", default: "00", operation: "+", pattern: "00")
}
} else {
version "1.00.00.${buildVersion}-SNAPSHOT"
}
}
Error Thrown, it tries to find the jar without any version in it.
* What went wrong:
Execution failed for task ':projectA:publishMavenPublicationToMavenLocal'.
> Failed to publish publication 'maven' to repository 'MavenLocal'
> Invalid publication 'maven': artifact file does not exist: 'C:\Development\poc\projectA\build\libs\projectA.jar'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Is there any work around for this?
Thanks, Arnab