Open tbitonti opened 4 years ago
Exact matching is simple and fast, but more choice may be needed some times. So we could support a regex choice. For example, if the string starts with /
then we can consider it a regex/replacement pattern (sort of sed-like)
/javax\.foo(\..*)/jakarta.bar$1/
This would rename any package starting with javax.foo
to a package starting with jakarta.bar
.
This would open up all the power of Java regex.
We currently have a wildcard (suffix only) option for the key. So you can say javax.transaction.*=jakarta.transaction
That would transform all subpackages of javax.transaction including javax.transaction.xa
To avoid that one case, you could specify:
javax.transaction.*=jakarta.transaction
jakarta.transaction.xa.*=javax.transaction.xa
As long as we apply those in the right order, I think it does what you want.
A wildcard "prefix" applies to a general transformer, but is probably not needed for the Jakarta transformer.
Could we pack more into the package renames properties file? Instead of having:
initial=final
Have something like:
keyword,...;initial=final
For example:
exact;initial=final
regex;initial=final
allowSuffix;initial=final
allowSuffix;disallowSuffix(.xa);initial=final
This would be specifically for package substitution cases, which have specific rules which don't apply for simple string replacement.
I'm not liking my "disallowSuffix" syntax, but I'm not sure how to do the transaction.xa case with regular expressions.
The rules for matching package names needs to be reviewed.
The question is to require exact whole package matches, or to allow prefix matching.
For example, currently, "javax.servlet" matches "javax.servlet" but not "prefixjavax.servlet", "prefix.javax.servlet", "javax.servletsuffix", or "javax.servlet.suffix".
This might be widened to enable matching against "prefix.javax.servlet" and "javax.servlet.suffix".
However, the case of "javax.transaction.xa" is a problem. "javax.transaction" was renamed within Jakarta EE 9, but "javax.transaction.xa" was not renamed. Any prefix and suffix matching which is added must provide settings which disallow the transaction case.
That is, if "javax.transaction" is allowed to match "javax.transaction.suffix", it must be disallowed at the same time from matching "javax.transaction.xa".