When using the Gradle plugin to run the producer tests, it looks as though the new stub layout is causing compilation errors. The generateContractTests task is generating an invalid package name due to the project version
We are pulling the contracts from a maven repo using contractDependency{}
The GAV + Classifier
com.example:hello-world:1.0.0:stubs
Produces
/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/META_INF/com.example/hello_world/1.0.0/ContractsTest.java
The package name in ContractsTest.java =>
package org.springframework.cloud.contract.verifier.tests.META_INF.com.example.hello_world.1.0.0;
This is an invalid package name and the compileTestGroovy task fails.
/Users/lnxmad/IdeaProjects/hello-world/build/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/META_INF/com.example/hello_world/1.0.0/ContractsTest.java:1:` error: ';' expected
package org.springframework.cloud.contract.verifier.tests.META_INF.com.example.hello_world.1.0.0;
^
1 error
startup failed:
Compilation failed; see the compiler error output for details.
1 error
:compileTestGroovy FAILED
Introduced with Changing the default layout of stubs
That's really strange cause we have changed the way the stubs are stored, not the way tests are generated. Do you have a sample that you could publish somewhere?
Oh I think I see that. I'll fix this in a moment and I'll ask you to test it with latest snapshots ok?
@marcingrzejszczak is this change included in 1.1.1.BUILD-SNAPSHOT?
yeah it should be
Your fix did not work for me. I am still getting a compile error with the generated contracts test using 1.1.1.BUILD-SNAPSHOT.
dale-api44/build/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/META_INF/com.uscm/dale_api44_spec/0.1.0_dev.1.uncommitted+d1174dd/ContractsTest.java:1: error: ';' expected
package org.springframework.cloud.contract.verifier.tests.META_INF.com.uscm.dale_api44_spec.0.1.0_dev.1.uncommitted+d1174dd;
Oh I see... I'll check this out tomorrow again and I'll reopen this issue
Can you show your plugin configuration?
Here is my plugin config:
contracts {
baseClassForTests = "com.daleapi44.contract.ContractBase"
// Don't pull from local repo
contractsWorkOffline = false
contractDependency {
groupId = "com"
artifactId = "dale-api44-spec"
classifier = "stubs"
stringNotation = "com:dale-api44-spec-server:0.1.0-dev.1.uncommitted+d1174dd:stubs"
}
contractsPath = "/"
contractsRepositoryUrl = "https://artifactory/artifactory/maven-repo-local/"
}
I've added a test - https://github.com/spring-cloud-samples/spring-cloud-contract-samples/commit/3997b091c34cbaea2820aae0013e4b0cd5a93f69 in samples. I've managed to replicate the issue and now it seems to be fixed. Can you confirm this on your side?
@marcingrzejszczak I will test your change today
馃帀 @marcingrzejszczak I tested your latest change and it resolved my compile error. 馃帀
Yay!!!!!