Skip to content

spring-cloud-contract gradle plugin overrides pom.xml on publish #482

@huzaus

Description

@huzaus

If you have service code and contracts in the same module, then publishStubsPublicationToNexus-releasesRepository task will override original pom.xml

See gradle-default-setup.

:service:generatePomFileForMavenJavaPublication // correct pom
:service:compileJava NO-SOURCE 
:service:compileGroovy NO-SOURCE
:service:processResources NO-SOURCE
:service:classes UP-TO-DATE
:service:jar
:service:publishMavenJavaPublicationToNexus-releasesRepository
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.jar
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.jar.sha1
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.jar.md5
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.pom /// pom upload 
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.pom.sha1
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.pom.md5
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/maven-metadata.xml
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/maven-metadata.xml.sha1
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/maven-metadata.xml.md5
:service:generatePomFileForStubsPublication //incorrect pom.xml
:service:copyContracts
:service:generateClientStubs
:service:verifierStubsJar
:service:publishStubsPublicationToNexus-releasesRepository
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.pom //pom override
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.pom.sha1
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1.pom.md5
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1-stubs.jar
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1-stubs.jar.sha1
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/0.0.1/service-0.0.1-stubs.jar.md5
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/maven-metadata.xml
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/maven-metadata.xml.sha1
Upload http://nexus.local/nexus/content/repositories/releases/com/shuzau/service/maven-metadata.xml.md5
:service-now:publish

Workaround:

    publications {
        mavenJava(MavenPublication) {
            from components.java

            artifact sourceJar {
                classifier 'sources'
            }
        }
        stubs(MavenPublication) {
            artifactId "$project.name-stubs"
            artifact verifierStubsJar {
                classifier 'stubs'
            }
        }
    }

or

    publications {
        stubs(MavenPublication) {
            from components.java

            artifact sourceJar {
                classifier 'sources'
            }
            artifact verifierStubsJar {
                classifier 'stubs'
            }
        }
    }

It would be nice to add option for spring-cloud-contract gradle plugin to disable stubs publication.

Example:

contracts {
   disableStubPublication = true
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions