From c0dc488d810f4256c0aad0e3d520d0015544bddf Mon Sep 17 00:00:00 2001
From: buildmaster com/example/server
tests and the stubs. Due to this convention the producer team will know which consumer teams will be broken
when some incompatible changes are done.
The rest of the flow looks the same.
To avoid messaging contracts duplication in the common repo, when few producers writing messages to one topic, we could create the structure when the rest contracts would be placed in a folder per producer and messaging -contracts in the folder per topic.
To make it possible to work on the producer side we could do the following things (all via Maven plugins):
<dependency> - <groupId>com.example</groupId> - <artifactId>common-repo</artifactId> - <version>${common-repo.version}</version> -</dependency>
<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>unpack-dependencies</id> - <phase>process-resources</phase> - <goals> - <goal>unpack</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>com.example</groupId> - <artifactId>common-repo</artifactId> - <type>jar</type> - <overWrite>false</overWrite> - <outputDirectory>${project.build.directory}/contracts</outputDirectory> - </artifactItem> - </artifactItems> - </configuration> - </execution> - </executions> -</plugin>
<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.8</version> - <executions> - <execution> - <phase>process-resources</phase> - <goals> - <goal>run</goal> - </goals> - <configuration> - <tasks> - <delete includeemptydirs="true"> - <fileset dir="${project.build.directory}/contracts"> - <include name="**/*" /> - <!--Producer artifactId--> - <exclude name="**/${project.artifactId}/**" /> - <!--List of the supported topics--> - <exclude name="**/${first-topic}/**" /> - <exclude name="**/${second-topic}/**" /> - </fileset> - </delete> - </tasks> - </configuration> - </execution> - </executions> -</plugin>
<plugin> +contracts in the folder per topic.To make it possible to work on the producer side we should specify an inclusion pattern for +filtering common repository jar by messaging topics we are interested in.
property ofincludedFiles+allows us to do that. AlsoMaven Spring Cloud Contract pluginneed to be specified since the default path would be the common repositorycontractsPath.groupid/artifactid<plugin> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-contract-maven-plugin</artifactId> <version>${spring-cloud-contract.version}</version> - <extensions>true</extensions> <configuration> - <packageWithBaseClasses>com.example</packageWithBaseClasses> + <contractsMode>REMOTE</contractsMode> + <contractsRepositoryUrl>http://link/to/your/nexus/or/artifactory/or/sth</contractsRepositoryUrl> + <contractDependency> + <groupId>com.example</groupId> + <artifactId>common-repo-with-contracts</artifactId> + <version>+</version> + </contractDependency> + <contractsPath>/</contractsPath> <baseClassMappings> <baseClassMapping> - <contractPackageRegex>.*intoxication.*</contractPackageRegex> - <baseClassFQN>com.example.intoxication.BeerIntoxicationBase</baseClassFQN> + <contractPackageRegex>.*messaging.*</contractPackageRegex> + <baseClassFQN>com.example.services.MessagingBase</baseClassFQN> + </baseClassMapping> + <baseClassMapping> + <contractPackageRegex>.*rest.*</contractPackageRegex> + <baseClassFQN>com.example.services.TestBase</baseClassFQN> </baseClassMapping> </baseClassMappings> - <contractsDirectory>${project.build.directory}/contracts</contractsDirectory> + <includedFiles> + <includedFile>**/${project.artifactId}/**</includedFile> + <includedFile>**/${first-topic}/**</includedFile> + <includedFile>**/${second-topic}/**</includedFile> + </includedFiles> </configuration> </plugin>
- Add a custom configuration for the common-repo dependency:
ext { conractsGroupId = "com.example" diff --git a/multi/multi__using_the_pluggable_architecture.html b/multi/multi__using_the_pluggable_architecture.html index 8b13b63426..5ec2f2dc66 100644 --- a/multi/multi__using_the_pluggable_architecture.html +++ b/multi/multi__using_the_pluggable_architecture.html @@ -421,7 +421,7 @@ to clone the repository and use it as a source of contracts to generate tests or stubs.Either via environment variables, system properties, properties set inside the plugin or contracts repository configuration you can tweak the downloader’s behaviour. Below you can find the list of -properties
Table 10.1. SCM Stub Downloader properties
Type of a property
Name of the property
Description
*
git.branch(plugin prop) +propertiesTable 10.1. SCM Stub Downloader properties
Type of a property
Name of the property
Description
*
git.branch(plugin prop)*
stubrunner.properties.git.branch(system prop)*
STUBRUNNER_PROPERTIES_GIT_BRANCH(env prop)master
Which branch to checkout
*
git.username(plugin prop)*
stubrunner.properties.git.username(system prop) @@ -437,7 +437,7 @@ to fetch the Pact contract definitions from the Pact Broker. Whatever is set afterpact://will be parsed as the Pact Broker URL.Either via environment variables, system properties, properties set inside the plugin or contracts repository configuration you can tweak the downloader’s behaviour. Below you can find the list of -properties
Table 10.2. SCM Stub Downloader properties
Name of a property
Default
Description
*
pactbroker.host(plugin prop) +propertiesTable 10.2. SCM Stub Downloader properties
Name of a property
Default
Description
*
pactbroker.host(plugin prop)*
stubrunner.properties.pactbroker.host(system prop)*
STUBRUNNER_PROPERTIES_PACTBROKER_HOST(env prop)Host from URL passed to
repositoryRootWhat is the URL of Pact Broker
*
pactbroker.port(plugin prop)*
stubrunner.properties.pactbroker.port(system prop) diff --git a/single/spring-cloud-contract.html b/single/spring-cloud-contract.html index d71465e6f8..470367cf93 100644 --- a/single/spring-cloud-contract.html +++ b/single/spring-cloud-contract.html @@ -1073,74 +1073,36 @@ and contracts present under thecom/example/servertests and the stubs. Due to this convention the producer team will know which consumer teams will be broken when some incompatible changes are done.The rest of the flow looks the same.
To avoid messaging contracts duplication in the common repo, when few producers writing messages to one topic, we could create the structure when the rest contracts would be placed in a folder per producer and messaging -contracts in the folder per topic.
To make it possible to work on the producer side we could do the following things (all via Maven plugins):
- Add common repo dependency to your classpath:
<dependency> - <groupId>com.example</groupId> - <artifactId>common-repo</artifactId> - <version>${common-repo.version}</version> -</dependency>
- Download the JAR with the contracts and unpack the JAR to target:
<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>unpack-dependencies</id> - <phase>process-resources</phase> - <goals> - <goal>unpack</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>com.example</groupId> - <artifactId>common-repo</artifactId> - <type>jar</type> - <overWrite>false</overWrite> - <outputDirectory>${project.build.directory}/contracts</outputDirectory> - </artifactItem> - </artifactItems> - </configuration> - </execution> - </executions> -</plugin>
- Rip out all the folders we’re not interested in:
<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.8</version> - <executions> - <execution> - <phase>process-resources</phase> - <goals> - <goal>run</goal> - </goals> - <configuration> - <tasks> - <delete includeemptydirs="true"> - <fileset dir="${project.build.directory}/contracts"> - <include name="**/*" /> - <!--Producer artifactId--> - <exclude name="**/${project.artifactId}/**" /> - <!--List of the supported topics--> - <exclude name="**/${first-topic}/**" /> - <exclude name="**/${second-topic}/**" /> - </fileset> - </delete> - </tasks> - </configuration> - </execution> - </executions> -</plugin>
- Run the contract plugin by pointing to the contracts to the folder under target:
<plugin> +contracts in the folder per topic.To make it possible to work on the producer side we should specify an inclusion pattern for +filtering common repository jar by messaging topics we are interested in.
property ofincludedFiles+allows us to do that. AlsoMaven Spring Cloud Contract pluginneed to be specified since the default path would be the common repositorycontractsPath.groupid/artifactid<plugin> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-contract-maven-plugin</artifactId> <version>${spring-cloud-contract.version}</version> - <extensions>true</extensions> <configuration> - <packageWithBaseClasses>com.example</packageWithBaseClasses> + <contractsMode>REMOTE</contractsMode> + <contractsRepositoryUrl>http://link/to/your/nexus/or/artifactory/or/sth</contractsRepositoryUrl> + <contractDependency> + <groupId>com.example</groupId> + <artifactId>common-repo-with-contracts</artifactId> + <version>+</version> + </contractDependency> + <contractsPath>/</contractsPath> <baseClassMappings> <baseClassMapping> - <contractPackageRegex>.*intoxication.*</contractPackageRegex> - <baseClassFQN>com.example.intoxication.BeerIntoxicationBase</baseClassFQN> + <contractPackageRegex>.*messaging.*</contractPackageRegex> + <baseClassFQN>com.example.services.MessagingBase</baseClassFQN> + </baseClassMapping> + <baseClassMapping> + <contractPackageRegex>.*rest.*</contractPackageRegex> + <baseClassFQN>com.example.services.TestBase</baseClassFQN> </baseClassMapping> </baseClassMappings> - <contractsDirectory>${project.build.directory}/contracts</contractsDirectory> + <includedFiles> + <includedFile>**/${project.artifactId}/**</includedFile> + <includedFile>**/${first-topic}/**</includedFile> + <includedFile>**/${second-topic}/**</includedFile> + </includedFiles> </configuration> </plugin>
- Add a custom configuration for the common-repo dependency:
ext { conractsGroupId = "com.example" @@ -5969,7 +5931,7 @@ to clone the repository and use it as a source of contracts to generate tests or stubs.Either via environment variables, system properties, properties set inside the plugin or contracts repository configuration you can tweak the downloader’s behaviour. Below you can find the list of -properties
Table 10.1. SCM Stub Downloader properties
Type of a property
Name of the property
Description
*
git.branch(plugin prop) +propertiesTable 10.1. SCM Stub Downloader properties
Type of a property
Name of the property
Description
*
git.branch(plugin prop)*
stubrunner.properties.git.branch(system prop)*
STUBRUNNER_PROPERTIES_GIT_BRANCH(env prop)master
Which branch to checkout
*
git.username(plugin prop)*
stubrunner.properties.git.username(system prop) @@ -5985,7 +5947,7 @@ to fetch the Pact contract definitions from the Pact Broker. Whatever is set afterpact://will be parsed as the Pact Broker URL.Either via environment variables, system properties, properties set inside the plugin or contracts repository configuration you can tweak the downloader’s behaviour. Below you can find the list of -properties
Table 10.2. SCM Stub Downloader properties
Name of a property
Default
Description
*
pactbroker.host(plugin prop) +propertiesTable 10.2. SCM Stub Downloader properties
Name of a property
Default
Description
*
pactbroker.host(plugin prop)*
stubrunner.properties.pactbroker.host(system prop)*
STUBRUNNER_PROPERTIES_PACTBROKER_HOST(env prop)Host from URL passed to
repositoryRootWhat is the URL of Pact Broker
*
pactbroker.port(plugin prop)*
stubrunner.properties.pactbroker.port(system prop) diff --git a/spring-cloud-contract-maven-plugin/generateTests-mojo.html b/spring-cloud-contract-maven-plugin/generateTests-mojo.html index 36c46d0b50..6b4b5d62d3 100644 --- a/spring-cloud-contract-maven-plugin/generateTests-mojo.html +++ b/spring-cloud-contract-maven-plugin/generateTests-mojo.html @@ -544,6 +544,17 @@ folder after running tests
Default value is: true.
+ + +includedFiles + +List + +- + +Patterns that should be taken into account for processing +
User property is: includedFiles.+ -mavenTestSkip boolean @@ -553,7 +564,7 @@ folder after running tests
Default value is: true.
(no description)
Default value is: false.
User property is: maven.test.skip.+ - nameSuffixForTests @@ -564,7 +575,7 @@ folder after running tests
Default value is: true.
(no description) + - packageWithBaseClasses @@ -583,7 +594,7 @@ test source file that will have the package last folders to and attach Base to its name.
User property is: packageWithBaseClasses.
+ - ruleClassForTests @@ -594,7 +605,7 @@ last folders to and attach Base to its name.
User property is(no description) + - skip @@ -605,7 +616,7 @@ last folders to and attach Base to its name.
User property is(no description)
Default value is: false.
User property is: spring.cloud.contract.verifier.skip.+ - skipTests @@ -616,7 +627,7 @@ last folders to and attach Base to its name.
User property is(no description)
Default value is: false.
User property is: skipTests.+ - staticImports @@ -627,7 +638,7 @@ last folders to and attach Base to its name.
User property isStatic imports that should be added to generated tests + - testFramework @@ -638,7 +649,7 @@ last folders to and attach Base to its name.
User property is(no description)
Default value is: JUNIT.+ testMode @@ -919,6 +930,18 @@ folder after running testsRequired: No
+ + +Patterns that should be taken into account for processing+ ++ +
- Type: java.util.List
+ +- Required: No
+ +- User Property: includedFiles
+
(no description)diff --git a/spring-cloud-contract.xml b/spring-cloud-contract.xml index 556fdf6ee8..126e0e6fd3 100644 --- a/spring-cloud-contract.xml +++ b/spring-cloud-contract.xml @@ -1762,98 +1762,37 @@ we could create the structure when the rest contracts would be placed in a folde contracts in the folder per topic.For Maven Project -To make it possible to work on the producer side we could do the following things (all via Maven plugins): -- -- -Add common repo dependency to your classpath: -<dependency> - <groupId>com.example</groupId> - <artifactId>common-repo</artifactId> - <version>${common-repo.version}</version> -</dependency> -- -- -Download the JAR with the contracts and unpack the JAR to target: -<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <id>unpack-dependencies</id> - <phase>process-resources</phase> - <goals> - <goal>unpack</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>com.example</groupId> - <artifactId>common-repo</artifactId> - <type>jar</type> - <overWrite>false</overWrite> - <outputDirectory>${project.build.directory}/contracts</outputDirectory> - </artifactItem> - </artifactItems> - </configuration> - </execution> - </executions> -</plugin> -- -- -Rip out all the folders we’re not interested in: -<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.8</version> - <executions> - <execution> - <phase>process-resources</phase> - <goals> - <goal>run</goal> - </goals> - <configuration> - <tasks> - <delete includeemptydirs="true"> - <fileset dir="${project.build.directory}/contracts"> - <include name="**/*" /> - <!--Producer artifactId--> - <exclude name="**/${project.artifactId}/**" /> - <!--List of the supported topics--> - <exclude name="**/${first-topic}/**" /> - <exclude name="**/${second-topic}/**" /> - </fileset> - </delete> - </tasks> - </configuration> - </execution> - </executions> -</plugin> -- +- -Run the contract plugin by pointing to the contracts to the folder under target: -To make it possible to work on the producer side we should specify an inclusion pattern for +filtering common repository jar by messaging topics we are interested in. property of includedFiles +allows us to do that. Also Maven Spring Cloud Contract plugin need to be specified since the default path would be the common repository contractsPath . groupid/artifactid <plugin> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-contract-maven-plugin</artifactId> <version>${spring-cloud-contract.version}</version> - <extensions>true</extensions> <configuration> - <packageWithBaseClasses>com.example</packageWithBaseClasses> + <contractsMode>REMOTE</contractsMode> + <contractsRepositoryUrl>http://link/to/your/nexus/or/artifactory/or/sth</contractsRepositoryUrl> + <contractDependency> + <groupId>com.example</groupId> + <artifactId>common-repo-with-contracts</artifactId> + <version>+</version> + </contractDependency> + <contractsPath>/</contractsPath> <baseClassMappings> <baseClassMapping> - <contractPackageRegex>.*intoxication.*</contractPackageRegex> - <baseClassFQN>com.example.intoxication.BeerIntoxicationBase</baseClassFQN> + <contractPackageRegex>.*messaging.*</contractPackageRegex> + <baseClassFQN>com.example.services.MessagingBase</baseClassFQN> + </baseClassMapping> + <baseClassMapping> + <contractPackageRegex>.*rest.*</contractPackageRegex> + <baseClassFQN>com.example.services.TestBase</baseClassFQN> </baseClassMapping> </baseClassMappings> - <contractsDirectory>${project.build.directory}/contracts</contractsDirectory> + <includedFiles> + <includedFile>**/${project.artifactId}/**</includedFile> + <includedFile>**/${first-topic}/**</includedFile> + <includedFile>**/${second-topic}/**</includedFile> + </includedFiles> </configuration> </plugin>