Skip to content

Commit bc24e7c

Browse files
committed
Update dependency handling
1 parent a870437 commit bc24e7c

File tree

7 files changed

+16
-552
lines changed

7 files changed

+16
-552
lines changed

src/main/resources/META-INF/rewrite/add-inject-dependencies.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ recipeList:
3030
groupId: jakarta.inject
3131
artifactId: jakarta.inject-api
3232
version: 1.0.3
33-
onlyIfUsing:
34-
- javax.inject.*
33+
onlyIfUsing: javax.inject.*
3534

3635
- org.openrewrite.maven.UpgradeDependencyVersion:
3736
groupId: jakarta.inject

src/main/resources/META-INF/rewrite/add-jaxb-dependencies.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,23 @@ tags:
2626
- glassfish
2727

2828
recipeList:
29-
#Add or update the jakarta.xml.bind-api to a maven project. This artifact still uses the javax.xml name space.
29+
# Add or update the jakarta.xml.bind-api to a maven project. This artifact still uses the javax.xml name space.
3030
- org.openrewrite.maven.AddDependency:
3131
groupId: jakarta.xml.bind
3232
artifactId: jakarta.xml.bind-api
3333
version: 2.3.x
34-
onlyIfUsing:
35-
- javax.xml.bind.*
34+
onlyIfUsing: javax.xml.bind.*
3635
- org.openrewrite.maven.UpgradeDependencyVersion:
3736
groupId: jakarta.xml.bind
3837
artifactId: jakarta.xml.bind-api
3938
newVersion: 2.3.x
40-
#Add or update the jaxb-impl to a maven project. This artifact still uses the javax.xml name space.
39+
# Add or update the jaxb-impl to a maven project. This artifact still uses the javax.xml name space.
4140
- org.openrewrite.maven.AddDependency:
4241
groupId: org.glassfish.jaxb
4342
artifactId: jaxb-runtime
4443
version: 2.3.x
4544
scope: runtime
46-
onlyIfUsing:
47-
- javax.xml.bind.*
45+
onlyIfUsing: javax.xml.bind.*
4846
- org.openrewrite.maven.UpgradeDependencyVersion:
4947
groupId: org.glassfish.jaxb
5048
artifactId: jaxb-runtime

src/main/resources/META-INF/rewrite/add-jaxws-dependencies.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ recipeList:
3131
groupId: jakarta.xml.ws
3232
artifactId: jakarta.xml.ws-api
3333
version: 2.3.x
34-
onlyIfUsing:
35-
- javax.jws.*
34+
onlyIfUsing: javax.jws.*
3635
- org.openrewrite.maven.UpgradeDependencyVersion:
3736
groupId: jakarta.xml.ws
3837
artifactId: jakarta.xml.ws-api
@@ -43,8 +42,7 @@ recipeList:
4342
artifactId: jaxws-rt
4443
version: 2.3.x
4544
scope: runtime
46-
onlyIfUsing:
47-
- javax.jws.*
45+
onlyIfUsing: javax.jws.*
4846
- org.openrewrite.maven.UpgradeDependencyVersion:
4947
groupId: com.sun.xml.ws
5048
artifactId: jaxws-rt

src/main/resources/META-INF/rewrite/javax-to-jakarta.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ recipeList:
4949
groupId: jakarta.activation
5050
artifactId: jakarta.activation-api
5151
version: 2.x
52-
onlyIfUsing:
53-
- javax.activation.*
52+
onlyIfUsing: javax.activation.*
5453

5554
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
5655
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -84,8 +83,7 @@ recipeList:
8483
groupId: jakarta.annotation
8584
artifactId: jakarta.annotation-api
8685
version: 2.x
87-
onlyIfUsing:
88-
- javax.annotation.*
86+
onlyIfUsing: javax.annotation.*
8987

9088
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
9189
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -119,8 +117,7 @@ recipeList:
119117
groupId: jakarta.batch
120118
artifactId: jakarta.batch-api
121119
version: 2.x
122-
onlyIfUsing:
123-
- javax.batch.*
120+
onlyIfUsing: javax.batch.*
124121

125122
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
126123
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -184,8 +181,7 @@ recipeList:
184181
groupId: jakarta.inject
185182
artifactId: jakarta.inject-api
186183
version: 2.x
187-
onlyIfUsing:
188-
- javax.batch.*
184+
onlyIfUsing: javax.batch.*
189185

190186
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
191187
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -219,8 +215,7 @@ recipeList:
219215
groupId: jakarta.transaction
220216
artifactId: jakarta.transaction-api
221217
version: 2.x
222-
onlyIfUsing:
223-
- javax.transaction.*
218+
onlyIfUsing: javax.transaction.*
224219

225220
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
226221
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -254,8 +249,7 @@ recipeList:
254249
groupId: jakarta.xml.bind
255250
artifactId: jakarta.xml.bind-api
256251
version: 3.x
257-
onlyIfUsing:
258-
- javax.xml.bind.*
252+
onlyIfUsing: javax.xml.bind.*
259253

260254
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
261255
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -269,8 +263,7 @@ recipeList:
269263
artifactId: jaxb-runtime
270264
version: 3.x
271265
scope: runtime
272-
onlyIfUsing:
273-
- javax.xml.bind.*
266+
onlyIfUsing: javax.xml.bind.*
274267

275268
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
276269
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -309,8 +302,7 @@ recipeList:
309302
groupId: jakarta.xml.ws
310303
artifactId: jakarta.xml.ws-api
311304
version: 3.x
312-
onlyIfUsing:
313-
- javax.xml.ws.*
305+
onlyIfUsing: javax.xml.ws.*
314306

315307
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
316308
- org.openrewrite.maven.UpgradeDependencyVersion:
@@ -324,8 +316,7 @@ recipeList:
324316
artifactId: jaxws-rt
325317
version: 3.x
326318
scope: runtime
327-
onlyIfUsing:
328-
- javax.xml.ws.*
319+
onlyIfUsing: javax.xml.ws.*
329320

330321
# Upgrade the dependency to use the jakarta namespace if an older version already exists.
331322
- org.openrewrite.maven.UpgradeDependencyVersion:

src/test/kotlin/org/openrewrite/java/migrate/JavaxToJakartaTest.kt

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@
1515
*/
1616
package org.openrewrite.java.migrate
1717

18-
import org.assertj.core.api.Assertions
1918
import org.junit.jupiter.api.Test
20-
import org.openrewrite.InMemoryExecutionContext
21-
import org.openrewrite.Parser
2219
import org.openrewrite.Recipe
23-
import org.openrewrite.SourceFile
2420
import org.openrewrite.config.Environment
2521
import org.openrewrite.java.ChangeType
26-
import org.openrewrite.java.JavaParser
2722
import org.openrewrite.java.JavaRecipeTest
28-
import org.openrewrite.maven.AddDependency
29-
import org.openrewrite.maven.MavenParser
30-
import java.util.*
3123

3224
class JavaxToJakartaTest : JavaRecipeTest {
3325
override val recipe: Recipe = Environment.builder()
@@ -308,66 +300,4 @@ class JavaxToJakartaTest : JavaRecipeTest {
308300
}
309301
"""
310302
)
311-
312-
@Test
313-
fun onlyIfUsing() {
314-
val recipe = AddDependency(
315-
"jakarta.xml.bind",
316-
"jakarta.xml.bind-api",
317-
"3.0.0",
318-
null,
319-
true,
320-
null,
321-
null,
322-
null,
323-
null,
324-
null,
325-
listOf("jakarta.xml.bind.*")
326-
)
327-
val javaSource = JavaParser.fromJavaVersion()
328-
.dependsOn(Collections.singletonList(Parser.Input.fromString(
329-
"""
330-
package jakarta.xml.bind;
331-
public class MarshalException extends Exception {
332-
}
333-
""")))
334-
.build().parse("""
335-
package org.openrewrite.java.testing;
336-
import jakarta.xml.bind.MarshalException;
337-
public class A {
338-
MarshalException getMap() {
339-
return new MarshalException();
340-
}
341-
}
342-
""")[0]
343-
val mavenSource = MavenParser.builder().build().parse("""
344-
<project>
345-
<groupId>com.mycompany.app</groupId>
346-
<artifactId>my-app</artifactId>
347-
<version>1</version>
348-
<dependencies>
349-
</dependencies>
350-
</project>
351-
""".trimIndent())[0]
352-
353-
val sources: List<SourceFile> = listOf(javaSource, mavenSource)
354-
val results = recipe.run(sources, InMemoryExecutionContext{ error: Throwable -> throw error})
355-
val mavenResult = results.find { it.before === mavenSource }
356-
Assertions.assertThat(mavenResult).isNotNull
357-
358-
Assertions.assertThat(mavenResult?.after?.print()).isEqualTo("""
359-
<project>
360-
<groupId>com.mycompany.app</groupId>
361-
<artifactId>my-app</artifactId>
362-
<version>1</version>
363-
<dependencies>
364-
<dependency>
365-
<groupId>jakarta.xml.bind</groupId>
366-
<artifactId>jakarta.xml.bind-api</artifactId>
367-
<version>3.0.0</version>
368-
</dependency>
369-
</dependencies>
370-
</project>
371-
""".trimIndent())
372-
}
373303
}

0 commit comments

Comments
 (0)