build-info
build-info copied to clipboard
[Gradle] Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
Running any Gradle task triggers lots of Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path. messages.
Example build.gradle to reproduce:
plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'maven-publish'
id 'com.jfrog.artifactory' version '4.13.0'
}
group = "com.example.artifactory.gradle.test"
version = "1.2.3.9"
dependencies {
implementation gradleApi()
implementation localGroovy()
implementation "com.google.guava:guava:28.2-jre"
}
gradlePlugin {
plugins {
simplePlugin {
id = 'com.example.artifactory.gradle.test'
implementationClass = 'com.example.artifactory.gradle.test.TestPlugin'
}
}
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'publish-test'
username = artifactory_user
password = artifactory_password
maven = true
}
defaults {
// this is needed because some of our project produce no artifacts but have dependencies (in lots of different custom configurations)
configurations.each { conf ->
if (conf.canBeResolved) publishConfigs(conf.name)
}
// this is needed because otherwise the artifactory plugin does _NOTHING_ publishToMavenLocal works just fine...
project.publishing.publications.each { pub ->
publications(pub.name)
}
publishPom = true
}
}
resolve {
repository {
repoKey = 'dependencies'
username = artifactory_user
password = artifactory_password
maven = true
}
}
}
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
16:57:30 > Task :compileJava NO-SOURCE
16:57:42 > Task :compileGroovy
16:57:42 > Task :pluginDescriptors
16:57:42 > Task :processResources
16:57:42 > Task :classes
16:57:42 > Task :jar
16:57:42 > Task :assemble
16:57:42 > Task :pluginUnderTestMetadata
16:57:42 > Task :artifactoryPublish
16:57:42 Deploying artifact: https://artifactory/artifactory/publish-test/com/example/artifactory/gradle/test/gradle-plugin-test/1.2.3.9/gradle-plugin-test-1.2.3.9.jar
16:57:43 > Task :artifactoryDeploy
16:57:43
16:57:43 BUILD SUCCESSFUL in 23s
16:57:43 7 actionable tasks: 7 executed
Expected behavior:
- I expect that such a simple project (in terms of build.gradle setup of artifacts and dependencies) automatically publishes all artifacts, that
publishToMavenLocalwould publish, to artifactory. - I expect that all dependencies of the build are listed in the build info of such a build (running with Jenkins) also of subprojects that have no artifacts! -> see also inline comments above
- and while we are at this: why are the build dependencies not published in the build infos? having bad jars on the build classpath is also something I would want to get notified by Xray.
So far it seems to be impossible to publish all artifacts and have all dependencies in the build-info without also having MEGABYTES of the warning above in the build logs (our actual builds have many more subprojects obviously)
I am facing the same issue on spotless checks.
Anyone found answer?
same issue...
bump the plugin to the latest version and add a publishing block, e.g.
plugins {
id 'java-library'
id 'maven-publish'
id "com.jfrog.artifactory" version "4.21.0"
}
...
artifactoryPublish {
skip = false //Skip build info analysis and publishing (false by default)
contextUrl = artifactoryContextURL
publications ('ALL_PUBLICATIONS')
clientConfig.publisher.repoKey = artifactoryRepository
clientConfig.publisher.username = "${artifactoryUser}"
clientConfig.publisher.password = "${artifactoryToken}"
}
artifactory {
contextUrl = artifactoryContextURL
publish {
repository {
repoKey = artifactoryRepository
username = "${artifactoryUser}"
password = "${artifactoryToken}"
maven = true
}
defaults {
publications('ALL_PUBLICATIONS')
publishConfigs('archives', 'published')
publishBuildInfo = true
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
clientConfig.setIncludeEnvVars(true)
}
publishing {
publications {
myLibrary(MavenPublication) {
from components.java
}
}
}
This doesn't help for me! And just adding a random publication is cumbersome, the java-gradle-plugin already adds proper publications...
What Gradle version are you using? I tried with both 6.2 and 7.0
Using 7.0 Please post your build.gradle Troubleshooting build.gradle is unfortunately a lot of trial and error. Without the publications block, I don't get the pom.xml
Ensure:
- using latest plugin version: 4.21.0
- using plugins id syntax, not apply plugins
- don't use the org.jfrog.buildinfo:build-info-extractor-gradle since you get that already from the plugin and an old version can mess it up
I'm using Gradle 6.9. Plugin version 4.29.0. Single project.
plugins {
id 'war'
id 'maven-publish'
id 'com.jfrog.artifactory' version '4.29.0'
}
// Let me know if you want more sections of my build.gradle
publishing {
publications {
maven(MavenPublication) {
from components.web
artifact createTar
}
}
}
artifactory {
contextUrl = 'http://artifactory.mycorp.com/artifactory'
publish {
repository {
repoKey = version.endsWith('SNAPSHOT') ? "twd-maven-snapshot-local-dev" : "twd-maven-local-dev"
username = System.getenv('PUBLISH_USERNAME')
password = System.getenv('PUBLISH_PASSWORD')
}
defaults {
publications('ALL_PUBLICATIONS')
publishConfigs('archives', 'published')
properties = [
'build.branch': System.getenv('CI_COMMIT_BRANCH'),
'build.key': "${artifactId}-${System.getenv('CI_PIPELINE_ID')}"
]
}
publishBuildInfo = false // FIXME - remove after RITM0074898 is fixed
publishArtifacts = true
publishPom = true
publishIvy = false
}
}
It does appear to be publishing the pom (see below). Maybe the error is spurious?
$ dotenv run gradle artifactoryPublish
Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.
[pool-2-thread-1] Deploying artifact: http://artifactory.mycorp.com/artifactory/twd-maven-snapshot-local-dev/com/tw/twd/realtime/twdpubsub/1.5-SNAPSHOT/twdpubsub-1.5-SNAPSHOT.module
[pool-2-thread-1] Deploying artifact: http://artifactory.mycorp.com/artifactory/twd-maven-snapshot-local-dev/com/tw/twd/realtime/twdpubsub/1.5-SNAPSHOT/twdpubsub-1.5-SNAPSHOT.tar
[pool-2-thread-1] Deploying artifact: http://artifactory.mycorp.com/artifactory/twd-maven-snapshot-local-dev/com/tw/twd/realtime/twdpubsub/1.5-SNAPSHOT/twdpubsub-1.5-SNAPSHOT.war
[pool-2-thread-1] Deploying artifact: http://artifactory.mycorp.com/artifactory/twd-maven-snapshot-local-dev/com/tw/twd/realtime/twdpubsub/1.5-SNAPSHOT/twdpubsub-1.5-SNAPSHOT.pom
BUILD SUCCESSFUL in 4s
9 actionable tasks: 5 executed, 4 up-to-date
Same issue even with Gradle-7.6.1 & Plugin version 4.31.4. Please, share update if anyone found any workaround to avoid a bunch of these error in build console logs?
Here's the build.gradle I'm using to publish jars to artifactory with maven pom.xml, stripped down to the basics.
Using gradle 7.4.1
You'll need to ensure all the relevant ENV are set to use.
buildscript {
ext {
javaVersion = JavaVersion.VERSION_11
}
}
plugins {
id 'java-library'
id 'idea'
id 'maven-publish'
id "com.jfrog.artifactory" version "4.21.0"
}
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
def artifactoryUser = System.getenv('ARTIFACT_REPOSITORY_USER')
def artifactoryToken = System.getenv('ARTIFACT_REPOSITORY_TOKEN')
def artifactoryGroupPrefix = System.getenv('JAR_GROUP_ID_PREFIX')
def artifactoryContextURL = System.getenv('ARTIFACT_REPOSITORY_URL')
def tagName = System.getenv('GIT_TAG_NAME')
def artifactoryRepository = System.getenv('JAR_REPOSITORY')
group = artifactoryGroupPrefix
version = System.getenv('GIT_TAG_NAME') ?: version
repositories {
mavenLocal() {
metadataSources {
mavenPom()
artifact()
}
}
maven {
url "https://local-maven-goes-here.com/"
}
mavenCentral()
}
dependencies {
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
}
test {
systemProperties System.properties
useJUnitPlatform()
}
allprojects {
apply plugin: "com.jfrog.artifactory"
}
artifactoryPublish {
skip = false //Skip build info analysis and publishing (false by default)
contextUrl = artifactoryContextURL
publications ('ALL_PUBLICATIONS')
clientConfig.publisher.repoKey = artifactoryRepository
clientConfig.publisher.username = "${artifactoryUser}"
clientConfig.publisher.password = "${artifactoryToken}"
}
// Here we are using artifactory gradle plugin to publish Jar. It is not required and perhaps you can use
// any method to publish Jar being agnostic of the artifact repository
artifactory {
contextUrl = artifactoryContextURL
publish {
repository {
repoKey = artifactoryRepository
username = "${artifactoryUser}"
password = "${artifactoryToken}"
maven = true
}
defaults {
publications('ALL_PUBLICATIONS')
publishConfigs('archives', 'published')
publishBuildInfo = true
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
clientConfig.setIncludeEnvVars(true)
}
publishing {
publications {
myLibrary(MavenPublication) {
from components.java
}
}
}
tasks.withType(Jar) {
duplicatesStrategy = DuplicatesStrategy.INHERIT
}