Added one more ant pattern to gradle and maven plugins
The bug is related to the fact that initially, we were supporting slash-separated paths to projects. E.g. if the group id was `a.b.c` then we did checked for `a/b/c` folder. At certain point we've started building stubs with the `groupid` folder as such e.g. `a.b.c/artifact-id`. This is where the bug comes in. For Maven and Gradle we're using ant patterns for copying files. We're only providing the slash-separated ant pattern. With this fix, we're backward compatible (we're leaving the slash-separated one) and we're adding support for dot-delimited group id. fixes gh-555
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
:numbered:
|
||||
:icons: font
|
||||
:sectlinks: true
|
||||
:branch: master
|
||||
:branch: 1.2.x
|
||||
|
||||
= Spring Cloud Contract
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
:introduction_url: https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/master
|
||||
:introduction_url: https://raw.githubusercontent.com/spring-cloud/spring-cloud-contract/{branch}
|
||||
|
||||
== Spring Cloud Contract FAQ
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
:branch: 1.2.x
|
||||
:samples_branch: master
|
||||
|
||||
=== Stub Runner Core
|
||||
|
||||
Runs stubs for service collaborators. Treating stubs as contracts of services allows to use stub-runner as an implementation of
|
||||
@@ -120,8 +123,8 @@ The producer would setup the contracts like this:
|
||||
|
||||
To achieve proper stub packaging.
|
||||
|
||||
Or using the https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer_with_restdocs/pom.xml[Maven `assembly` plugin] or
|
||||
https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer_with_restdocs/build.gradle[Gradle Jar] task you have to create the following
|
||||
Or using the https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/{samples_branch}/producer_with_restdocs/pom.xml[Maven `assembly` plugin] or
|
||||
https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/{samples_branch}/producer_with_restdocs/build.gradle[Gradle Jar] task you have to create the following
|
||||
structure in your stubs jar.
|
||||
|
||||
[source,bash]
|
||||
@@ -389,8 +392,8 @@ Stub Runner can integrate with Spring Cloud.
|
||||
|
||||
For real life examples you can check the
|
||||
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/master/producer[producer app sample]
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/master/consumer_with_discovery[consumer app sample]
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/{samples_branch}/producer[producer app sample]
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/tree/{samples_branch}/consumer_with_discovery[consumer app sample]
|
||||
|
||||
==== Stubbing Service Discovery
|
||||
|
||||
|
||||
@@ -23,16 +23,21 @@ class ContractsCopyTask extends ConventionTask {
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(getExtension())
|
||||
File file = getDownloader().downloadAndUnpackContractsIfRequired(getExtension(), props)
|
||||
String antPattern = "${props.includedRootFolderAntPattern}*.*"
|
||||
String slashSeparatedGroupId = project.group.toString().replace(".", File.separator)
|
||||
String slashSeparatedAntPattern = antPattern.replace(slashSeparatedGroupId, project.group.toString())
|
||||
String root = OutputFolderBuilder.buildRootPath(project)
|
||||
ext.contractVerifierConfigProperties = props
|
||||
File outputContractsFolder = getExtension().stubsOutputDir != null ?
|
||||
project.file("${getExtension().stubsOutputDir}/${root}/contracts") :
|
||||
project.file("${project.buildDir}/stubs/${root}/contracts")
|
||||
ext.contractsDslDir = outputContractsFolder
|
||||
project.logger.info("Downloading and unpacking files from [$file] to [$outputContractsFolder]. The inclusion ant pattern is [$antPattern]")
|
||||
project.logger.info("Downloading and unpacking files from [$file] to [$outputContractsFolder]. The inclusion ant patterns are [${antPattern}] and [${slashSeparatedAntPattern}]")
|
||||
project.copy {
|
||||
from(file)
|
||||
// by default group id is slash separated...
|
||||
include(antPattern)
|
||||
// ...we also want to allow dot separation
|
||||
include(slashSeparatedAntPattern)
|
||||
if (props.isExcludeBuildFolders()) {
|
||||
exclude "**/target/**", "**/build/**"
|
||||
}
|
||||
|
||||
@@ -53,7 +53,11 @@ class CopyContracts {
|
||||
+ "[" + this.config.getIncludedContracts() + "] pattern will end up in "
|
||||
+ "the final JAR with stubs.");
|
||||
Resource resource = new Resource();
|
||||
resource.addInclude(this.config.getIncludedRootFolderAntPattern() + "*.*");
|
||||
// by default group id is slash separated...
|
||||
String includedRootFolderAntPattern = this.config.getIncludedRootFolderAntPattern() + "*.*";
|
||||
resource.addInclude(includedRootFolderAntPattern);
|
||||
// ...we also want to allow dot separation
|
||||
resource.addInclude(includedRootFolderAntPattern.replace(slashSeparatedGroupId(), this.project.getGroupId()));
|
||||
if (this.config.isExcludeBuildFolders()) {
|
||||
resource.addExclude("**/target/**");
|
||||
resource.addExclude("**/build/**");
|
||||
@@ -77,4 +81,8 @@ class CopyContracts {
|
||||
}
|
||||
}
|
||||
|
||||
private String slashSeparatedGroupId() {
|
||||
return this.project.getGroupId().replace(".", File.separator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
:samples_branch: master
|
||||
|
||||
= Spring Cloud Contract Maven Plugin
|
||||
|
||||
Just to make long story short - Spring Cloud Contract Verifier is a tool that enables Consumer Driven Contract (CDC) development of JVM-based applications.
|
||||
@@ -18,5 +20,5 @@ This plugin allows you to:
|
||||
You can check out the https://github.com/spring-cloud-samples/spring-cloud-contract-samples[Spring Cloud Contract Samples project] for
|
||||
examples of Maven plugin setup.
|
||||
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer/pom.xml[Producer application with a test dependency added to the plugin]
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer/pom.xml[Producer application referencing a repo with contracts and regular expression based base class mapping]
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/{samples_branch}/producer/pom.xml[Producer application with a test dependency added to the plugin]
|
||||
- https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/{samples_branch}/producer/pom.xml[Producer application referencing a repo with contracts and regular expression based base class mapping]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
:branch: 1.2.x
|
||||
|
||||
== Java Project with JUnit Tests
|
||||
|
||||
Sample minimal configuration for Java Project with JUnit tests.
|
||||
@@ -26,4 +28,4 @@ include::../../../src/test/projects/spring-boot-java/src/test/java/hello/BaseAcc
|
||||
|
||||
=== Project source code
|
||||
|
||||
https://github.com/spring-cloud/spring-cloud-contract/tree/master/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/test/projects/spring-boot-java
|
||||
https://github.com/spring-cloud/spring-cloud-contract/tree/{branch}/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/test/projects/spring-boot-java
|
||||
@@ -1,3 +1,5 @@
|
||||
:branch: 1.2.x
|
||||
|
||||
== Groovy Project with Spock Specifications
|
||||
|
||||
Sample minimal configuration for Groovy Project with Spock Specification
|
||||
@@ -26,4 +28,4 @@ include::../../../src/test/projects/spring-boot-groovy/src/test/groovy/hello/Bas
|
||||
|
||||
=== Project source code
|
||||
|
||||
https://github.com/spring-cloud/spring-cloud-contract/tree/master/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/test/projects/spring-boot-groovy
|
||||
https://github.com/spring-cloud/spring-cloud-contract/tree/{branch}/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/test/projects/spring-boot-groovy
|
||||
|
||||
Reference in New Issue
Block a user