How do I suppress POM and IVY related warnings in Gradle 7?

Viewed 688

After upgrading to Gradle 7 I have many warnings like:

Cannot publish Ivy descriptor if ivyDescriptor not set in task ':myProject:artifactoryPublish' and task 'uploadArchives' does not exist.
Cannot publish pom for project ':myProject' since it does not contain the Maven plugin install task and task ':myProject:artifactoryPublish' does not specify a custom pom path.

The artifactoryPublish task works fine.

My Gradle script:

buildscript {
    repositories{
        maven {
            url = '...'
            credentials {
                username '...'
                password '...'
            }
            metadataSources {
                mavenPom()
                artifact()
            }
        }
    }

    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.24.12"
    }
}

apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            suppressAllPomMetadataWarnings()
        }
    }  
}

group = '...'

artifactory {
    contextUrl = '...'
    publish {
        repository {
            repoKey = '...'
            username = '...'
            password = '...'
        }
        defaults {  
            publishConfigs('archives')  
            publishIvy = false 
            publications("mavenJava")       
        }
    }
}

How do I disable those warnings?

1 Answers

It looks like you mixed between the old Gradle publish-configuration method and the new Gradle publication method.

You applied the maven-publish plugin which allows creating publications. In artifactory.default, you added the "mavenJava" publication as expected.

However, the archives publish-configuration doesn't exist in your build.gradle file. Basically, publish-configurations are created by the legacy maven plugin. The configured mavenJava publication does the same as the archives publish-configuration and therefore all of the JARs are published as expected.

To remove the warning messages you see, remove the publishConfigs('archives') from artifactory.default clause:

artifactory {
    publish {
        defaults {  
            publishConfigs('archives') // <-- Remove this line
            publishIvy = false 
            publications("mavenJava")       
        }
    }
}

Read more:

  1. Gradle Artifactory plugin documentation
  2. Example
Related