-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Includeresource duplicate strategy to append to existing file when unrolling jar #6326
base: master
Are you sure you want to change the base?
Includeresource duplicate strategy to append to existing file when unrolling jar #6326
Conversation
NOTHING, OVERWRITE, APPEND Signed-off-by: Christoph Rueger <[email protected]> use SequenceInputStream to concatenate... resources to avoid intermediate Strings Signed-off-by: Christoph Rueger <[email protected]> handle duplicates for :literal useful for testcases Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
20a2822
to
7c6bb03
Compare
@pkriens one thing I am thinking about and would like to discuss is, wether or not we shoud add a way to enforce a
a line break is not required, since the first file ends with one. One option would be another strategy in addition to APPEND.
|
You are becoming the Elon Musk of bnd :-) Nice productivity. Some comments.
|
Your approach sounds good and more flexible.
I recognize a pattern here. I am always one level too deep 🤣
What about the existing method with the This was the main reason why I have put it here. But since it is public, we have to keep it anyway.
Are you talking plugin as in ? Ok I will try to digest your ideas and see what I can do. |
No, sometimes multiple levels 😎 When I was younger you had "structured design", DeMarco, Michael Jackson, Yourdan, etc. They were talking about coupling and cohesion. Did not get the cohesion until a few years ago but I think it is paramount. I try to write software based on reusable components. So each component must do one thing and one thing only otherwise reuse becomes hard. So I now strife to create classes and methods that do one thing. Very useful in there is not not do control (if/then/switch/case) and actual work in the same method. Anyway, in bnd it is relatively straightforward. Whenever there is choice, it should be in a processor. Things like JAR, Resource, Parameters, etc. are reusable and should just do their work and not take decisions. |
Few questions @pkriens :
I ask because I have things setup so far (not pushed), but not sure how simple or complex the "plugin"-mechanism should be. |
to handle -includeresource expressions like this, as suggested by @pkriens : -includeresource @jar1.jar, @jar2.jar;dup_overwrite:=*, @jar3.jar;dup_skip:="META-INF/services/*,META-INF/MANIFEST.MF" The value of these directives is a list of globs on the paths in the resource. Priority is probably merge (if plugin exists), overwrite, skip. Error/Warning should always be executed even if it matches the other ones. Signed-off-by: Christoph Rueger <[email protected]> rework to MergeFiles plugin
226d669
to
5df7631
Compare
should avoid re-creating multiple Globs (Pattern.compile()) for each file. Should speed up things e.g. for unrolling jars with lots of files Signed-off-by: Christoph Rueger <[email protected]>
@pkriens I pushed the first prototype of this approach. Example: dup_merge AND dup_warning combined:
Warnings are displayed (TODO for me: the message is not correct. the word "overwritten" should not appear when same file is also affected by dup_merge in effect: line break added in META-INF/services files but other files outside META-INF/services will be just appended (without line break). This part is what I would like to discuss: I have created two MergeFiles plugins and iterate over them via
But that does not feel right, because the order of the plugins is important.
|
- instead of iterating of plugins we just check directly which of the two plugins to use, whether we have a META-INF/services file or not (we can get more dynamic in the future if we want, since all is still private) - and add testcases add test for mixed files in META-INF to test that META-INF/services files are merged differently than files in META-INF although they are captured by the same dub_merge glob Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Closes #6325
Adds a duplicate strategy to
-includeresource
(similar to:flatten
or:rename
)dup_merge:=*
@pkriens This is a first draft based on our discussion last week.