In the following document we will write about necessary migration steps between versions.
In 1.1.x we have introduced a changed structure of generated stubs. So if you’ve
been using the following @AutoConfigureWireMock notation to use the stubs from classpath
@AutoConfigureWireMock(stubs = "classpath:/customer-stubs/mappings", port = 8084)
It will no longer work with the new stubs. You have to either change the location of stubs
to : classpath:…/META-INF/groupId/artifactId/version/mappings as follows
@AutoConfigureWireMock(stubs = "classpath:customer-stubs/META-INF/travel.components/customer-contract/1.0.2-SNAPSHOT/mappings/", port = 8084)
Or migrate to the new classpath based @AutoConfigureStubRunner.
If however you don’t want to do that and you want to remain with the old structure just set your plugin tasks accordingly. Example for the structure presented in the snippet above.
Maven.
<!-- start of pom.xml --> <properties> <!-- we don't want the verifier to do a jar for us --> <spring.cloud.contract.verifier.skip>true</spring.cloud.contract.verifier.skip> </properties> <!-- ... --> <!-- You need to set up the assembly plugin --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>stub</id> <phase>prepare-package</phase> <goals> <goal>single</goal> </goals> <inherited>false</inherited> <configuration> <attach>true</attach> <descriptor>${basedir}/src/assembly/stub.xml</descriptor> </configuration> </execution> </executions> </plugin> </plugins> </build> <!-- end of pom.xml --> <!-- start of stub.xml--> <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>stubs</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <directory>${project.build.directory}/snippets/stubs</directory> <outputDirectory>customer-stubs/mappings</outputDirectory> <includes> <include>**/*</include> </includes> </fileSet> <fileSet> <directory>${basedir}/src/test/resources/contracts</directory> <outputDirectory>customer-stubs/contracts</outputDirectory> <includes> <include>**/*.groovy</include> </includes> </fileSet> </fileSets> </assembly> <!-- end of stub.xml-->
Gradle.
task copyStubs(type: Copy, dependsOn: 'generateWireMockClientStubs') { // Preserve directory structure from 1.0.X of spring-cloud-contract from "${project.buildDir}/resources/main/customer-stubs/META-INF/${project.group}/${project.name}/${project.version}" into "${project.buildDir}/resources/main/customer-stubs" }
By introducing a method String registeredMappings() in the public interface
HttpServerStub, if you wrote a custom HttpServerStub implementation, you’ll
have to implement that method too. It should return a String representing
all mappings available in a single HttpServerStub. Related to
issue 355.
The flow for setting the generated tests package name will look like this:
basePackageForTestsbasePackageForTests wasn’t set pick the package from baseClassForTestsbaseClassForTests wasn’t set pick packageWithBaseClassesorg.springframework.cloud.contract.verifier.tests valueRelated to issue 260.