Sync docs from master to gh-pages
This commit is contained in:
@@ -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.</simpara>
|
||||
<section xml:id="_for_maven_project">
|
||||
<title>For Maven Project</title>
|
||||
<simpara>To make it possible to work on the producer side we could do the following things (all via Maven plugins):</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>Add common repo dependency to your classpath:</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<programlisting language="xml" linenumbering="unnumbered"><dependency>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>common-repo</artifactId>
|
||||
<version>${common-repo.version}</version>
|
||||
</dependency></programlisting>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>Download the JAR with the contracts and unpack the JAR to target:</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<programlisting language="xml" linenumbering="unnumbered"><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></programlisting>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>Rip out all the folders we’re not interested in:</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<programlisting language="xml" linenumbering="unnumbered"><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></programlisting>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>Run the contract plugin by pointing to the contracts to the folder under target:</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<simpara>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. <literal><literal>includedFiles</literal></literal> property of <literal><literal>Maven Spring Cloud Contract plugin</literal></literal>
|
||||
allows us to do that. Also <literal><literal>contractsPath</literal></literal> need to be specified since the default path would be the common repository <literal><literal>groupid/artifactid</literal></literal>.</simpara>
|
||||
<programlisting language="xml" linenumbering="unnumbered"><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></programlisting>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user