Open williamsuane opened 3 years ago
@williamsuane thanks for the report.
With the help of @wilkinsona, we've been reminded that Maven handles certain dependency type with "magic strings", see the documentation. To make things consistent between the two model we may need to handle these too considering that type is a shared attribute between the two models.
So that works but, unfortunately, requesting the jar without a type fails as the dependency is not found in the bom. It is declared like this (correctly according to Maven):
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<version>${spring-cloud-stream.version}</version>
<type>test-jar</type>
<scope>test</scope>
<classifier>test-binder</classifier>
</dependency>
With the following: testImplementation 'org.springframework.cloud:spring-cloud-stream:test-binder
we get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
> Could not find org.springframework.cloud:spring-cloud-stream:test-binder.
Required by:
project :
> Could not find org.springframework.cloud:spring-cloud-stream:test-binder.
Required by:
project :
Ignoring the type won't fix this issue as we need to definition to match what's in the bom.
I'm a bit surprised that doesn't work. We could probably fix it with a change in the dependency management plugin. It would also be interesting to know how it behaves when using Gradle's Platform support.
I've just came across the same issue with a project I am working on which uses SpringBoot and SpringCloud with maven.
Adding the dependency on the test binder jar in this manner:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<scope>test</scope>
<classifier>test-binder</classifier>
<type>test-jar</type>
</dependency>
results in that maven picking up the default classifier for test-jar
s which is tests
instead of the overridden test-binder
Failure to find org.springframework.cloud:spring-cloud-stream:jar:tests:3.1.2 in ...
Now, removing the type
from the above dependency declaration makes maven complain about the missing version, but now it uses the correct classifier, i.e. test-binder
'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-stream:jar:test-binder is missing
Adding a version, then fixes everything and the correct jar is downloaded from Maven Central
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<scope>test</scope>
<classifier>test-binder</classifier>
<version>3.1.2</version>
</dependency>
And we get a BUILD SUCCESS
. Here we can see that the classifier is indeed test-binder
and not tests
Any updates on this one?
@dinvlad this issue has all the latest update. We don't have time to work on this at the moment, I am afraid.
Gradle project with spring-cloud-stream does not build, Mockito dependency fails on build due to "org.springframework.cloud:spring-cloud-starter-config" Any updates on this ?
I tried the solution provided by @HackerTheMonkey for spring boot 3 and spring cloud v2022.0.0 when updating a project but ran into the same issue:
org.springframework.cloud:spring-cloud-stream:jar:test-binder:4.0.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt
Generating new Gradle projects that contains
testImplementation("org.springframework.cloud:spring-cloud-stream:test-binder@test-jar")
fails with the following message when buildingHow to replicate
Generate a new project Spring Boot 2.4, Java 11, Cloud Stream and Kafka Binder
Run
./gradlew build
The solution that worked was to replace
testImplementation("org.springframework.cloud:spring-cloud-stream:test-binder@test-jar")
by