ShrinkWrap Maven Resolver - remove the -SNAPSHOT- trail from a dependency artifact
maikelnait Mar 12, 2013 10:43 PMHi all.
My problem is pretty simple, but as I am new to ShrinkWrap and Arquillian, I still cannot figure out how to solve it. I would like to try getting a response in the forum. Thanks in advance !!
We have a J2EE application ( an EAR file ) with one particularity :
Some dependencies are actually SNAPSHOT dependencies , but in the final EAR file, those dependency artifacts are stored without the version , or the SNAPSHOT label.
So for example, if we have a dependency on the artifact MyArtifact-1.2-SNAPSHOT.jar , the EAR stores the artifact as MyArtifact.jar
Additionally, the EAR has some EJB jars ( including old EJB 2.1 !! ) which are also referencing MyArtifact.jar in the Class-path of the MANIFEST.MF file
Now, when trying to use Arquillian + ShrinkWrap to build a "micro-EAR" with only the needed dependencies, I'm of course getting some X.X-SNAPSHOT dependencies.
However, I can't find a way to store those SNAPSHOT dependencies without the version or SNAPSHOT label, same as we do in the daily maven build.
( in Maven , you can use the tag <bundleFileName> to store an artifact with a different name on the EAR file )
I'm using shrinkwrap-resolver-bom 2.0.0-alpha-5
Is there any way to achieve this ?
Thanks !
So far what I have coded in my test class is this :
@RunWith(Arquillian.class)
public class ServiceMgmtTest {
@Deployment
public static EnterpriseArchive createDeployment() {
Collection<String> dependencies = new ArrayList<String>();
dependencies.add("com.wn.almiqui:Platform");
dependencies.add("com.wn.almiqui:PlatformServices");
dependencies.add("com.wn.almiqui:PlatformServicesEE");
dependencies.add("com.wn.almiqui:UserMgmt");
File[] mavenDeps = Maven.configureResolver().fromFile("C:/DevTools/apache-maven-3.0.4/conf/settings.xml")
.loadPomFromFile("testing-pom.xml").resolve(dependencies).withTransitivity()
.asFile();
EnterpriseArchive earFile = ShrinkWrap.create(EnterpriseArchive.class)
.addAsModules(mavenDeps)
.addAsModule(createServiceMgmtJar())
.addAsManifestResource("application-test.xml", "application.xml");
return earFile;
}
private static JavaArchive createServiceMgmtJar() {
JavaArchive serviceMgmtJar = ShrinkWrap.create(JavaArchive.class, "ServiceMgmt.jar");
serviceMgmtJar.addPackages(true, ServiceMgmtServiceFactory.class.getPackage());
serviceMgmtJar.addAsResource("test-persistence.xml", "META-INF/persistence.xml");
serviceMgmtJar.addAsResource("ejb-jar-testing.xml", "META-INF/ejb-jar.xml");
serviceMgmtJar.addAsResource("jboss-testing.xml", "META-INF/jboss.xml");
return serviceMgmtJar;
}
@EJB
private ServiceMgmtServiceBean serviceMgmtServiceBean;
@Test
public void test() {
Assert.assertNotNull(serviceMgmtServiceBean);
}
}