From 22ac272d0a37fe1023af153ec68aef3ab7926849 Mon Sep 17 00:00:00 2001 From: Alex Boyko Date: Thu, 20 Jun 2024 07:35:40 -0400 Subject: [PATCH] Maven runtime dependency is on the compile scope (#4273) * Runtime dependency becomes compile scope dependency issue fix * Polish * Polish * Polish text block in unit test Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Remove duplicate closing `` tag from test --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek --- .../openrewrite/maven/tree/ResolvedPom.java | 2 +- .../openrewrite/maven/MavenParserTest.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java index 18fbcb8a2dd..a351c9bf890 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/ResolvedPom.java @@ -816,7 +816,7 @@ public List resolveDependencies(Scope scope, Map + 4.0.0 + com.example + cache-2 + 0.0.1-SNAPSHOT + + + org.glassfish.jaxb + jaxb-runtime + 4.0.5 + runtime + + + + """, + spec -> spec.afterRecipe(pomXml -> { + MavenResolutionResult resolution = pomXml.getMarkers().findFirst(MavenResolutionResult.class).orElseThrow(); + assertThat(resolution.findDependencies("org.glassfish.jaxb", "jaxb-runtime", Scope.Runtime)).isNotEmpty(); + assertThat(resolution.findDependencies("org.glassfish.jaxb", "jaxb-runtime", Scope.Compile)).isEmpty(); + assertThat(resolution.findDependencies("jakarta.xml.bind", "jakarta.xml.bind-api", Scope.Compile)).isEmpty(); + }) + ) + ); + } }