Although the  ShrinkWrap.create(JavaArchive.class, “test.jar”).addPackage() method works fantastically, sometimes you require that the complete projects classes be included in the archive. In those cases, I find the ExplodedImporter a great way to include the contents of a directory into the archive.


public static JavaArchive getCompleteArchive() throws Exception {
 return ShrinkWrap.create(JavaArchive.class, "test.jar")
 .as(ExplodedImporter.class).importDirectory((new File("./target/classes")))
 .as(JavaArchive.class);

}

Advertisements