-
1. Re: Adding a jar to the archive
aslak Nov 12, 2010 9:23 AM (in response to nbhatia)You could use archive.merge(archive) to join the test.jar with your other.jar..
archive.merge(
ShrinkWrap.create(JavaArchive.class).as(ZipImporter.class).import(file))
or simply add based on packages from the other.jar:
archive.addPackages(true, OtherClass.class.getPackage())
but in general you probably want to deploy as something that could hold libraries, e.g WebArchive
-
2. Re: Adding a jar to the archive
nbhatia Nov 15, 2010 8:37 PM (in response to aslak)Thanks Aslak. I have changed my deployment to create a war. It is working fine now.
WebArchive archive = ShrinkWrap.create(WebArchive.class, "test.war").addClasses(SecurityService.class).addPackage(UserRepository.class.getPackage()).addManifestResource("test-persistence.xml", "persistence.xml").addWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));return ShrinkWrap
.create(WebArchive.class, "test.war")
.addClasses(SecurityService.class)
.addPackage(UserRepository.class.getPackage())
.addManifestResource("test-persistence.xml", "persistence.xml")
.addWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
-
3. Re: Adding a jar to the archive
iapazmino Mar 2, 2011 9:50 PM (in response to aslak)To merge the jar with the test archive you need to cast-back to JavaArchive the ZipImporter
ZipImporter zip = ShrinkWrap.create(JavaArchive.class).as(ZipImporter.class).importZip(file); archive.merge(zip.as(JavaArchive.class));