Artifactory Deploy path is missing properties in multiproject build
Describe the bug I have a multi-project gradle build that uses the artifactory gradle plugin for publication. If I split out a subproject as a standalone project, it's deployed by artifactoryDeploy to this path (from the debug log, minor details edited):
2021-01-05T12:17:39.546+0000 [DEBUG] [org.jfrog.gradle.plugin.artifactory.task.DeployTask] Full Artifact Http path: PUT https://artifactory.blah/artifactory/maven-snapshot-local/com/cirrus/tools/ignore/IdTest/0.1.0-SNAPSHOT/IdTest-0.1.0-SNAPSHOT-all.jar;build.timestamp=1609849058257;build.name=IdTest;build.number=1609849058617
but when published as part of the multi-project build, it's published without the properties:
2021-01-05T16:09:37.703+0000 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request PUT /artifactory/maven-snapshot-local/com/cirrus/tools/ignore/IdTest/0.1.0-SNAPSHOT/IdTest-0.1.0-SNAPSHOT-all.jar HTTP/1.1
Without the build.timestamp, the artifacts aren't considered as part of the same batch. As the classifier is 'all' and uploads are done alphabetically, this leads to artifacts with 'all' classifiers being considered part of the previous batch of uploads and overwriting the last snapshot, leaving the current snapshot incomplete.
To Reproduce A simplified version of the top level build.gradle:
plugins {
id 'maven-publish'
id 'java-library'
id 'com.jfrog.artifactory' version '4.18.3'
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
subprojects {
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
artifactory {
publish {
contextUrl = 'https://artifactory.blah/artifactory'
repository {
repoKey = 'maven-snapshot-local'
maven = true
m2Compatible = true
}
defaults {
publications('mavenJava', 'shadow')
publishConfigs('archives')
publishArtifacts = true
publishBuildInfo = true
maven = true
}
}
}
...
I've tried with various other combinations of configuration in the top level build.gradle and in the sub project itself.
Expected behavior I thought the location of the project would make no difference to the publication properties. Build info would be included in the deploy properties.
Versions
- Gradle Artifactory plugin version: 4.18.3
- Operating system: macOS
- Artifactory Version: 6.4.1
@broecirr, Thanks for reporting this issue.
The Gradle Artifactory plugin collects the build info from all submodules and publishes them with the build properties once in the end. In order to work properly, the artifactory.publish clause has to be configured in the root project. In the example you provided, the artifactory clause configured separately for each one of the submodules, but it is missing in the root project. Therefore, the build-info is not collected and the build-info properties are not set.
In your case, you can simply move out your artifactory clause to the root of the project:
subprojects {
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
}
artifactory {
publish {
contextUrl = 'https://artifactory.blah/artifactory'
repository {
repoKey = 'maven-snapshot-local'
maven = true
m2Compatible = true
}
defaults {
publications('mavenJava', 'shadow')
publishConfigs('archives')
publishArtifacts = true
publishBuildInfo = true
maven = true
}
}
If you need to define publications separately for a module, you can add them to your specific submodule as following:
publishing {
publications {
customPublication(MavenPublication) {
from components.java
}
}
}
artifactoryPublish {
publications(customPublication)
}
Please let me know if that helped.
For more information:
This worked for me. Thanks