How can I filter classes out of my final archive?
public static JavaArchive unitTestJar() {
return ShrinkWrap.create( JavaArchive.class )
.addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" )
.addPackages( false, getCorePackages() );
}
public static String[] getCorePackages( String... args ) {
List<String> strings = Arrays.asList(
"com.lm.util",
"com.lm.infrastructure"
);
strings.addAll( Arrays.asList( args ) );
return (String[]) strings.toArray();
}
I see that there's a Filter API, but I can't seem to find any examples of how to use it. Ultimately I figured I'd just remove anything that is *Test*
. Which is easier than trying to add a class at a time.
Try this:
ShrinkWrap.create(WebArchive.class)
.addPackages(true, Filters.exclude(".*Test.class"), getCorePackages());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With