Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/rewrite/jakarta-faces-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,19 @@ recipeList:
- org.openrewrite.xml.ChangeTagAttribute:
attributeName: version
elementName: web-app
oldValue: ^[1234]\.\d+$
newValue: 5.0
regex: true
- org.openrewrite.xml.ChangeTagAttribute:
attributeName: xmlns
elementName: web-app
newValue: https://jakarta.ee/xml/ns/jakartaee
- org.openrewrite.xml.ChangeTagAttribute:
attributeName: xsi:schemaLocation
elementName: web-app
oldValue: .*xml/ns/javaee.*
newValue: https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd
regex: true
- org.openrewrite.text.FindAndReplace:
find: "javax."
replace: "jakarta."
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/META-INF/rewrite/jakarta-faces-4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,15 @@ recipeList:
- org.openrewrite.xml.ChangeTagAttribute:
attributeName: version
elementName: web-app
oldValue: ^[12345]\.\d+$
newValue: 6.0
regex: true
- org.openrewrite.xml.ChangeTagAttribute:
attributeName: xsi:schemaLocation
elementName: web-app
newValue: https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd
oldValue: (?<prefix>[\S\s]*https://jakarta\.ee/xml/ns/jakartaee/web-app_)5_\d+(?<suffix>\.xsd[\S\s]*)
Copy link
Member

@timtebeek timtebeek Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A character group of [\S\s] would just mean anything right? Then .* feels more intuitive.

\s	A whitespace character: [ \t\n\x0B\f\r]
\S	A non-whitespace character: [^\s]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.* does not match on \n where \s\S will match on these newline variations also. I did not get it to work with .* and the added unit test/newlines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah guess that would require a multiline flag to be added; in that case we can go with this option, or prefix the regex with (?m) to make it explicit that we tolerate multilines as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the multiline, I indeed also tried.

That would work if we do not expect the entire string to match. That matches the line (so as of the newline) that matches the string, not the entire value.
I did find that the dotall flag does match the entire surrounding values.
Screenshot 2025-09-25 at 01 32 52
Screenshot 2025-09-25 at 01 32 46

newValue: ${prefix}6_0${suffix}
regex: true
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.jakarta.FacesManagedBeansRemoved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,25 @@ void fileNotWebXml() {
)
);
}

@Test
void alreadyMigrated() {
rewriteRun(
//language=xml
xml(
"""
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">
<display-name>Unit testing</display-name>
</web-fragment>
""",
sourceSpecs -> sourceSpecs.path("web.xml")
)
);
}
}
}