Skip to content

How to automatically resolve the latest consumer stub version in Spring Cloud Contract (provider-side)? #2447

@Awakuruf

Description

@Awakuruf

Background

I'm running provider-side contract verification in a Spring Cloud Contract (SCC) setup where the consumer publishes stub JARs to Artifactory. The provider's pom.xml has a property that pins the consumer stub version:

<consumer-service.contract.version>3.1.15-SNAPSHOT</consumer-service.contract.version>

This version is passed to the SCC Maven plugin as the contractDependency version so the provider pulls the correct stub JAR during generateTests.

The Problem

Pinning a static version creates a silent false-positive problem:

  • The consumer continuously publishes new SNAPSHOTs (3.1.15-SNAPSHOT, 3.1.16-SNAPSHOT, etc.) with updated contracts
  • The provider's pom.xml is never updated to match
  • Provider CI keeps verifying against an old stub — breaking changes in the consumer's contracts go completely undetected
  • All tests pass, but the provider and consumer are actually out of sync

This defeats the purpose of consumer-driven contract testing.

What I tried

Using + or leaving the version blank in the SCC plugin configuration — both result in:

No stubs or contracts were found for [com:consumer-service:+:stubs]

SCC's LATEST_VERSION (+) doesn't seem to resolve correctly against our internal Artifactory instance for SNAPSHOT artifacts.

Question

Is there a built-in or idiomatic way in Spring Cloud Contract to always resolve the latest available stub version from a remote Artifactory repository without having to manually maintain a version pin or use an external script?

Specifically:

  1. Is there a supported version syntax (similar to Maven's LATEST or RELEASE) that SCC's contractDependency resolution actually honours against Artifactory SNAPSHOT repos?
  2. Is there a plugin configuration option (e.g., snapshotCheckSkip, updateSnapshots, or resolver settings) that would force re-resolution to the latest SNAPSHOT on every build?
  3. Or is a pre-build metadata query (like my shell script approach) the accepted pattern for this use case?

Any guidance appreciated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions