Skip to content

Commit 5f641bb

Browse files
committed
filtering of jakarta namespace in xml files
Signed-off-by: Olivier Lamy <[email protected]>
1 parent 1392c6b commit 5f641bb

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
<postBuildHookScript>verify</postBuildHookScript>
224224
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
225225
<settingsFile>src/it/settings.xml</settingsFile>
226+
<streamLogsOnFailures>true</streamLogsOnFailures>
226227
<goals>
227228
<goal>clean</goal>
228229
<goal>test-compile</goal>

src/it/filtering-it/src/main/config/web.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<web-app
3-
xmlns="http://java.sun.com/xml/ns/javaee"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
6-
metadata-complete="false"
7-
version="3.0">
2+
<web-app
3+
xmlns="https://jakarta.ee/xml/ns/jakartaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
6+
metadata-complete="false"
7+
version="5.0">
88

99
<display-name>Test WebApp</display-name>
1010

src/it/filtering-it/verify.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ File source = new File( basedir, "target/test-classes/web.xml" );
22
assert source.isFile()
33
assert !source.text.contains( 'ee9' )
44
assert !source.text.contains( 'jakarta')
5+
assert !source.text.contains( 'version="5.0"')
6+
assert !source.text.contains( 'web-app_5_0.xsd')
57

68
assert source.text.contains( 'org.eclipse.jetty.ee8.plus.webapp.PlusDescriptorProcessorTest$TestInjections');
79
assert source.text.contains( 'javax.servlet.Foo');
10+
11+
12+

src/main/java/org/eclipse/jetty/toolchain/modifysources/ResourcesFiltering.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,21 @@ public void copyFile(File from, final File to, boolean filtering, List<FilterWra
7777
if (filtering && Files.exists(from.toPath())) {
7878
// well it is definitely not the best option to read the full content but shouldn't be too big files
7979
String content = Files.readString(from.toPath());
80-
if(StringUtils.contains(content, "jakarta.")) {
81-
content = StringUtils.replace(content, "jakarta.", "javax.");
82-
}
83-
if(StringUtils.contains(content, "jakarta/")) {
84-
content = StringUtils.replace(content, "jakarta/", "javax/");
85-
}
86-
if(StringUtils.contains(content, "ee9")) {
87-
content = StringUtils.replace(content, "ee9", "ee8");
88-
}
80+
81+
content = StringUtils.replace(content, "https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd",
82+
"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd");
83+
84+
content = StringUtils.replace(content, "https://jakarta.ee/xml/ns/jakartaee",
85+
"http://xmlns.jcp.org/xml/ns/javaee");
86+
87+
content = StringUtils.replace(content, "jakarta.", "javax.");
88+
content = StringUtils.replace(content, "jakarta/", "javax/");
89+
content = StringUtils.replace(content, "ee9", "ee8");
90+
91+
content = StringUtils.replace(content, "version=\"5.0\"",
92+
"version=\"4.0\"");
93+
94+
8995
Files.writeString(to.toPath(), content, StandardCharsets.UTF_8);
9096
buildContext.refresh( to );
9197
}

0 commit comments

Comments
 (0)