You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But in maven-shaded-plugin 3.5.0, it can't work as before, alouthght it SPI file name alao could be changed, but the SPI file content will have no change.
I compared the differneces between the maven-shaded-plugin 3.5.0 and maven-shaded-plugin 3.2.1, finally find in maven-shaded-plugin 3.2.1, file content changed by follow code
but in maven-shaded-plugin 3.5.0, the code change to
private String shadeSourceWithExcludes( String sourceContent, String patternFrom, String patternTo,
Set<String> excludedPatterns )
{
// Usually shading makes package names a bit longer, so make buffer 10% bigger than original source
StringBuilder shadedSourceContent = new StringBuilder( sourceContent.length() * 11 / 10 );
boolean isFirstSnippet = true;
// Make sure that search pattern starts at word boundary and we look for literal ".", not regex jokers
for ( String snippet : sourceContent.split( "\\b" + patternFrom.replace( ".", "[.]" + "\\b" ) ) )
{
boolean doExclude = false;
for ( String excludedPattern : excludedPatterns )
{
if ( snippet.startsWith( excludedPattern ) )
{
doExclude = true;
break;
}
}
if ( isFirstSnippet )
{
shadedSourceContent.append( snippet );
isFirstSnippet = false;
}
else
{
shadedSourceContent.append( doExclude ? patternFrom : patternTo ).append( snippet );
}
}
return shadedSourceContent.toString();
}
In my cases, source content is org.apache.demo1, pattern from is org.apache.demo, pattern to is shaded.org.apache.demo.
Following this checklist to help us incorporate your
contribution quickly and easily:
Make sure there is a JIRA issue filed
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
Each commit in the pull request should have a meaningful subject line and body.
Format the pull request title like [MSHADE-XXX] - Fixes bug in ApproximateQuantiles,
where you replace MSHADE-XXX with the appropriate JIRA issue. Best practice
is to use the JIRA issue title in the pull request title and in the first line of the
commit message.
Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
Run mvn clean verify to make sure basic checks pass. A more thorough check will
be performed on your pull request automatically.
You have run the integration tests successfully (mvn -Prun-its clean verify).
If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
elharo
changed the title
[MSGADE-452]Fix ServiceResourceTransformer not correct issue.
[MSHADE-452]Fix ServiceResourceTransformer not correct issue.
Feb 18, 2024
Hi @hk-lrzy , sorry for the delay (guess the PR popped during holidays).
From my window this PR has the risk to revert some of the fixes done before.
Long story short shade mixing the same API (relocation) for sources (variables, classes, packages), paths and other things, there is always a such a risk so ultimately I think a safer fix would make the relocated file more contextual (if (filePath ~ META-INF/services/xxxxxx then use relocateSPIFile()` to share the idea).
Hi @hk-lrzy , sorry for the delay (guess the PR popped during holidays). From my window this PR has the risk to revert some of the fixes done before. Long story short shade mixing the same API (relocation) for sources (variables, classes, packages), paths and other things, there is always a such a risk so ultimately I think a safer fix would make the relocated file more contextual (if (filePath ~ META-INF/services/xxxxxx then use relocateSPIFile()` to share the idea).
Hope it makes sense.
Thanks for reply, i will recheck the logical follow your suggestion and commit it later.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
We have java path as below
In
maven-shade-plugin 3.2.1, we use relocation to process path and SPI Service file at the same time, and we will follow result.But in
maven-shaded-plugin 3.5.0, it can't work as before, alouthght it SPI file name alao could be changed, but the SPI file content will have no change.I compared the differneces between the
maven-shaded-plugin 3.5.0andmaven-shaded-plugin 3.2.1, finally find inmaven-shaded-plugin 3.2.1, file content changed by follow codebut in
maven-shaded-plugin 3.5.0, the code change toIn my cases, source content is
org.apache.demo1, pattern from isorg.apache.demo, pattern to isshaded.org.apache.demo.Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MSHADE-XXX] - Fixes bug in ApproximateQuantiles,where you replace
MSHADE-XXXwith the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verifyto make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.