This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
The following commit(s) were added to refs/heads/main by this push: new df6501d Set jakarta.servlet.* version range to [5.0.0,7.0.0] if specified df6501d is described below commit df6501daf8c6eb9131a3b9e330311e868fa4152e Author: Ivan Furnadjiev <i...@eclipsesource.com> AuthorDate: Thu Jan 26 12:56:27 2023 +0200 Set jakarta.servlet.* version range to [5.0.0,7.0.0] if specified If javax.servlet.* packages are imported with version constraints in the MANIFEST.MF, the conversion should fix this range to the one corresponding to jakarta.servlet.* spec [5.0.0,7.0.0]. Otherwise, in OSGi environment the conversion leads to broken application. Fix #39 --- .../org/apache/tomcat/jakartaee/ManifestConverter.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/org/apache/tomcat/jakartaee/ManifestConverter.java b/src/main/java/org/apache/tomcat/jakartaee/ManifestConverter.java index d07435f..f3516ab 100644 --- a/src/main/java/org/apache/tomcat/jakartaee/ManifestConverter.java +++ b/src/main/java/org/apache/tomcat/jakartaee/ManifestConverter.java @@ -29,6 +29,8 @@ import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.commons.io.IOUtils; @@ -128,6 +130,7 @@ public class ManifestConverter implements Converter { // Update package names in values for (Entry<Object,Object> entry : attributes.entrySet()) { String newValue = profile.convert((String) entry.getValue()); + newValue = replaceVersion(newValue); // Object comparison is deliberate if (newValue != entry.getValue()) { entry.setValue(newValue); @@ -136,4 +139,17 @@ public class ManifestConverter implements Converter { } return converted; } + + private String replaceVersion(String entryValue) { + if (entryValue.contains("jakarta.servlet")) { + StringBuilder builder = new StringBuilder(); + Matcher matcher = Pattern.compile("jakarta.servlet([^,]*);version=\"(.*?)\"").matcher(entryValue); + while (matcher.find()) { + matcher.appendReplacement(builder, "jakarta.servlet$1;version=\"[5.0.0,7.0.0)\""); + } + matcher.appendTail(builder); + return builder.toString(); + } + return entryValue; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org