Skip to content

Setting <stubsDirectory> causes generateStubs goal to fail  #1812

@dmfrey

Description

@dmfrey

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions