-
Notifications
You must be signed in to change notification settings - Fork 496
Description
What version of OpenRewrite are you using?
- OpenRewrite 8.70.2
- Maven plugin 6.26.0
How are you running OpenRewrite?
Maven plugin
Can you share your configuration so that we can rule out any configuration issues?
Running from the commandline:
mvn org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.configLocation=src/main/resources/test.yaml \
-Drewrite.activeRecipes=com.xxx.Flyway
With test.yaml being:
---
type: specs.openrewrite.org/v1beta/recipe
name: com.xxx.Flyway
displayName: Perform Flyway migrations
description: Perform Flyway migrations.
preconditions:
- org.openrewrite.java.dependencies.search.ModuleHasDependency:
groupIdPattern: org.flywaydb
artifactIdPattern: flyway-database-*
recipeList:
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.springframework.boot
artifactId: spring-boot-starter-flyway
version: 4.0.x
What is the smallest, simplest way to reproduce the problem?
See above.
What did you expect to see?
In my multi-module project, I expect the dependency org.flywaydb:flyway-database-postgresql to trigger adding a new dependency org.springframework.boot:spring-boot-starter-flyway
What did you see instead?
No change was made in my multi-module project where the dependency is in a submodule (that is, not the parent pom.xml.
Removing the precondition and the change WAS made.
Moving the dependency from the submodule to the parent pom.xml and the change WAS made.
Note that I also tried using org.openrewrite.maven.search.FindDependency and I experience exactly the same behavior.
I also tried putting this in a unit test, but the test works and does not reflect what I'm seeing when running from the commandline in my actual project:
@Test
void preconditionMultiModuleFindDependency() {
rewriteRun(spec -> spec.recipeFromYaml("""
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.PreconditionTest
description: Test.
preconditions:
- org.openrewrite.maven.search.FindDependency:
groupId: jakarta.activation
artifactId: jakarta.activation-api
recipeList:
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.springframework.boot
artifactId: spring-boot-starter-flyway
version: 4.0.x
""", "org.openrewrite.PreconditionTest"),
pomXml(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>sample</artifactId>
<version>1.0.0</version>
<modules>
<module>sample-module</module>
</modules>
</project>
"""
,
sourceSpecs -> sourceSpecs.path("pom.xml")),
pomXml(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>sample-module</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.1.2</version>
</dependency>
</dependencies>
</project>
""",
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>sample-module</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-flyway</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
</project>
"""
,
sourceSpecs -> sourceSpecs.path("sample-module/pom.xml"))
);
}If this doesn't immediately ring a bell then I'll create a demo project.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status