-
-
Save PiotrNowicki/2989390 to your computer and use it in GitHub Desktop.
WebArchive archive = ShrinkWrap.create(WebArchive.class).addPackages(true, "eu.awaketech.mymodule") | |
.addAsWebInfResource("beans.xml", "beans.xml") | |
.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml"); | |
// To remove some package, I need to do: | |
archive.delete("/WEB-INF/classes/eu/awaketech/mymodule/config"); | |
// Wish I could do: | |
// - archive.delete(DataSource.class.getPackage()); | |
// - archive.delete(DataSource.class); |
Anytime buddy :)
Of course, excluding (applying a filter) before adding is the reason we haven't supported "delete" historically.
But now I think I've got a Use Case: The user might accept an Archive which was previously-created/populated from some source he/she does not control. And perhaps the user needs to modify that input archive to remove stuff. Currently we provide the ability to delete from String. This is API consistency; you can add a Class or Package but not remove it?
Piotr, would you like to open a JIRA? [1] And if so, any chance you'd like to work on this one?
S,
ALR
And here's the JIRA: https://issues.jboss.org/browse/SHRINKWRAP-411
Sure! I would gladly work on this one. I'll be able to take a look at it in the following week (vacation, so more free time, yay!)
If that's ok than you can count me in ;-)
Cheers!
Super - we'll save it for you!
Dev Instructions: https://community.jboss.org/docs/DOC-14304
And please apply here for the CLA? https://cla.jboss.org
@ALRubinger - wanted to get started with it and just to be sure about it - those delete Class (Classes) and Package (Packages) methods should be in the ClassContainer API, right?
Just asking because none of the containers (org.jboss.shrinkwrap.api.container.) have any delete methods - just additions are present. The only delete methods are on the Archive level, but this is too general as not every Archive must be capable of holding a Class/Package artifacts, right?
Exactly. For everything that has an "add", we should have a corresponding "delete". Go for it!
Just stumbled across this one myself in my current use case, where I would like to remove a couple of classes in a jar built by a third party, to stub out that particular functionality. Nice to see that you've taken this issue Piotr, it'll be a nice enhancement to the API.
@tommysdk great that you also find it useful :-)
The pull request is here shrinkwrap/shrinkwrap#58
Don't know if it should be linked with the JIRA right away or after the review and acceptance?
I made a quick review and thought it looked good. I think you can link the pull request to the JIRA issue right away (that's what I usually do). If it needs further adjustments @ALRubinger will let you know :-)
Ok, JIRA updated, CLA signed.
Just waiting for @ALRubinger review :-)
Aaaah, and there it is! http://docs.jboss.org/shrinkwrap/1.0.0-cr-3/org/jboss/shrinkwrap/api/Filters.html
Problem solved, thanks Bartosz!