spring-cloud-contract icon indicating copy to clipboard operation
spring-cloud-contract copied to clipboard

Setting <stubsDirectory> causes generateStubs goal to fail

Open dmfrey opened this issue 2 years ago • 0 comments

Describe the bug When setting the configuration property <stubsDirectory>, the contracts and mappings get moved to the appropriate directory and in the correct directory structure. However, when the generateStubs goal executes, it fails and indicates it's looking for the stubs in the original location. See the following configuration:

Maven Plugin Configuration:

<plugin>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <testFramework>JUNIT5</testFramework>
        <baseClassMappings>
            <baseClassMapping>
                <contractPackageRegex>.*orders-by-customer-id.*</contractPackageRegex>
                <baseClassFQN>com.vmware.tanzulabs.app.adapter.in.endpoint.OrdersByCustomerIdBase</baseClassFQN>
            </baseClassMapping>
        </baseClassMappings>
        <stubsDirectory>${maven.multiModuleProjectDirectory}/stubs</stubsDirectory>
    </configuration>
</plugin>

Error Output:

[ERROR] Failed to execute goal org.springframework.cloud:spring-cloud-contract-maven-plugin:3.1.3:generateStubs (default-generateStubs) on project order-app: Stubs could not be found: [/Users/dfrey/Development/git/spaceforce/daniel-frey-ctr/demo-parent/app-parent/order-app/target/stubs] .

Note the path in the exception is the original target folder and does not match up the actual project directory defined in the property.

As a workaround, setting the configuration property <outputDirectory> instead of <stubsDirectory> fixes the issue:

<outputDirectory>${maven.multiModuleProjectDirectory}/stubs</outputDirectory>

dmfrey avatar Aug 24 '22 19:08 dmfrey