From c0dc488d810f4256c0aad0e3d520d0015544bddf Mon Sep 17 00:00:00 2001 From: buildmaster Date: Fri, 27 Jul 2018 07:25:55 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- multi/multi__spring_cloud_contract_faq.html | 82 ++++---------- ...lti__using_the_pluggable_architecture.html | 4 +- single/spring-cloud-contract.html | 86 ++++---------- .../generateTests-mojo.html | 39 +++++-- spring-cloud-contract.xml | 105 ++++-------------- 5 files changed, 101 insertions(+), 215 deletions(-) diff --git a/multi/multi__spring_cloud_contract_faq.html b/multi/multi__spring_cloud_contract_faq.html index d0f2614d70..fcb948a7bf 100644 --- a/multi/multi__spring_cloud_contract_faq.html +++ b/multi/multi__spring_cloud_contract_faq.html @@ -293,74 +293,36 @@ and contracts present under the 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.

3.5.5 How can I define messaging contracts per topic not per producer?

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.

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:
<plugin>
+contracts in the folder per topic.

For Maven Project

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. includedFiles property of Maven Spring Cloud Contract plugin +allows us to do that. Also contractsPath need to be specified since the default path would be the common repository 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>

For Gradle Project

  • 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) +properties

Table 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 after pact:// 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) +properties

Table 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 repositoryRoot

What 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 the 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.

3.5.5 How can I define messaging contracts per topic not per producer?

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.

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:
<plugin>
+contracts in the folder per topic.

For Maven Project

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. includedFiles property of Maven Spring Cloud Contract plugin +allows us to do that. Also contractsPath need to be specified since the default path would be the common repository 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>

For Gradle Project

  • 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) +properties

Table 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 after pact:// 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) +properties

Table 10.2. SCM Stub Downloader properties

+ + + + + + + + + + + @@ -553,7 +564,7 @@ folder after running tests
Default value is: true.
- + @@ -564,7 +575,7 @@ folder after running tests
Default value is: true.
- + @@ -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.
- + @@ -594,7 +605,7 @@ last folders to and attach Base to its name.
User property is(no description)
- + @@ -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.
- + @@ -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.
- + @@ -627,7 +638,7 @@ last folders to and attach Base to its name.
User property isStatic imports that should be added to generated tests
- + @@ -638,7 +649,7 @@ last folders to and attach Base to its name.
User property is(no description)
Default value is: JUNIT.
- + @@ -919,6 +930,18 @@ folder after running tests
  • Required: No

  • +

    includedFiles:

    + +
    Patterns that should be taken into account for processing
    + +
      + +
    • Type: java.util.List
    • + +
    • Required: No
    • + +
    • User Property: includedFiles
    • +

    mavenTestSkip:

    (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. includedFiles property of Maven Spring Cloud Contract plugin +allows us to do that. Also contractsPath need to be specified since the default path would be the common repository 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>

    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 repositoryRoot

    What 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.

    includedFilesList-Patterns that should be taken into account for processing
    User property is: includedFiles.
    mavenTestSkip boolean(no description)
    Default value is: false.
    User property is: maven.test.skip.
    nameSuffixForTests(no description)
    packageWithBaseClasses
    ruleClassForTests
    skip
    skipTests
    staticImports
    testFramework
    testMode