-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of OpenRewrite are you using?
Main branch
How are you running OpenRewrite?
via tests
Problem
When we run org.openrewrite.java.dependencies.search.ModuleHasDependency
with a version we see wrong behavior in search results leading to not fulfilled preconditions in recipes.
Situation
- Dependencies 'org.springframework:spring-core:6.1.5' and 'org.springframework:spring-aop:6.2.2' defined, see below
We search for:
- 'org.springframework:*:6.1.5' with
new ModuleHasDependency("org.springframework", "*", null, 6.1.5, null)
- 'org.springframework:*:5.1.5' with
new ModuleHasDependency("org.springframework", "*", null, 5.1.5, null)
Expectation
- both modules (Gradle and Maven) are marked to have the 'org.springframework:*:6.1.5' Dependency
- no module is marked to have the 'org.springframework:*:6.1.5' Dependency
Observation
- Maven finds nothing, gradle marks
- Maven finds nothing, gradle marks
The problem is that ModuleHasDependency
configures DependencyInsight
incorrectly (switched scope and version).
Line 96 in 98e26f5
Tree t = new DependencyInsight(groupIdPattern, artifactIdPattern, scope, version) |
If we correct this we observe a different, wrong behavior. On maven the Recipe behaves correct, Gradle stops finding not exsiting versions but also finds nothing, except if configured using with a caret range.
Test files
pom.xml
<project>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>6.1.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>6.2.2</version>
</dependency>
</dependencies>
</project>
build.gradle
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework:spring-core:6.1.5'
implementation 'org.springframework:spring-aop:6.2.2'
}
Note
See #150 for reproducing tests.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
No status