-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example with external contracts and contractsMode CLASSPATH #107
Comments
Hi!
I don't think we have ever assumed that someone would use the classpath mode with external contracts.
For sure you need to add the dependency to the classpath.
This seems to mean that the snapshot dependency of the plugin couldn't have been found. I don't think you need to disable the extensions to retrieve it. Since you've already downloaded the plugin, can you rollback to point number 1 and try again. I'm actually surprised that the CLASSPATH thing works anyways ;) But it's good to see that it does |
Thanks for the fast feedback!
I have the same error message with version
But this is only relevant for Are you interested to provide an example for classpath mode with external contracts or is this scenario too specific? |
wow, I'm surprised!
I think that it's specific, but if you're interested, feel free to provide a PR to this repo with a working sample (Maven and Gradle). That way, if anyone is interested, we'll show that there's an option to make this work :) |
I created a draft for a PR in #108.
you just have to edit the module Remove <extensions>
<extension>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
</extension>
</extensions> Change <extensions>false</extensions> to <extensions>true</extensions> |
Bumping this. |
+1 to this issue |
Preamble
My setup contains the following modules:
I wanted to execute the Spring Cloud Contract tests during the build with
contractsMode CLASSPATH
.For that reason, I created an aggregator containing these three modules und executed
mvn clean test
.In the samples, the
beer_contracts
module with external contracts does not provide the artifact with the classifierstubs
.I choose another approach for my project.
The module
my-contracts
does provide the artifact with the classifierstubs
.The modules
my-consumer
andmy-producer
do not know each other but the API and the modulemy-contracts
.Issue
To demonstrate how Spring Cloud Contract works with external contracts, the samples contain already the modules
beer_contracts
andproducer_with_external_contracts
.This works with
contractsMode LOCAL
but not withcontractsMode CLASSPATH
.In my project this has a couple of reasons:
After setting
contractsMode
toCLASSPATH
inmy-producer
the following problems occur:No stubs were found on classpath for [com.example:beer-contracts]
I had to add the dependency of
beer-contracts
to the plugin dependencies inproducer_with_external_contracts
like this:The next error message is the following:
[ERROR] Unresolveable build extension: Plugin org.springframework.cloud:spring-cloud-contract-maven-plugin:2.1.3.BUILD-SNAPSHOT or one of its dependencies could not be resolved
Normally Maven will resolve the dependencies of modules and plugins during the build.
The problem here is the
<extensions>true</extensions>
tag.I guess that dependencies of extensions have to be available at the time the build starts and can not be resolved during the build.
To fix it, I just had to include the
spring-cloud-contract-maven-plugin
to the extensions and remove the<extensions>true</extensions>
tag (or set it to false):After these fixes, the build and all Spring Cloud Contract tests run properly.
Now I have the following questions:
Is my approach with
my-contracts
and artifact with classifierstubs
used in consumer and producer by Spring Cloud Contracts intended?How would a setup look with given modules
beer_contracts
andproducer_with_external_contracts
withcontractsMode CLASSPATH
?Just adapting my fixes does not work.
The text was updated successfully, but these errors were encountered: