Create ear test with Arquillian using Maven resolver
<p>I need to create a real IT test using Arquillian for my EAR application.</p>

<p>Since ShrinkWrap methods <em>addClasses</em> or <em>addPackages</em> are useless in real world - because of too many imports needed - I'd like to use <em>Maven.resolver()</em> which works with <em>pom.xml</em>.</p>

<p>Therefore I've created a Test like this:</p>

<pre><code>@RunWith(Arquillian.class)
public class ArqTest {

@Deployment
public static Archive&lt;?&gt; createTestArchive() {
    System.out.println("START CREATE ARCHIVE");

    //create ear archive  
    EnterpriseArchive ear = ShrinkWrap
            .create(EnterpriseArchive.class);  

    System.out.println("RESOLVING EJB DEPENDENCIES");

    // resolve and add ejbDependencies to ear lib  
    File[] ejbDependencies = Maven.resolver()
            .loadPomFromFile("../ejb/pom.xml")
            .importRuntimeDependencies()
            .resolve()
            .withTransitivity()
            .asFile();   

    System.out.println("ADDING DEPENDENCIES TO EAR");

    for (File archive : ejbDependencies) {  
        ear.addAsLibrary(archive);  
    }   

    System.out.println("START CREATE EJB");
    // resolve ejb (actually jar file cause as of now mavenimporter doesn't support ejb-types ony war and jars so don't be fooled by my naming convention)  
    // then add some external resources, and an empty beans.xml for CDI to work  
    JavaArchive ejb = ShrinkWrap                
            .create(MavenImporter.class)                
            .loadPomFromFile("../ejb/pom.xml")
            .importBuildOutput()                
            .as(JavaArchive.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsResource("app.properties")
            ;

    System.out.println("START CREATE WAR");
    //resolve war and add beans.xml and my html files manually  
    WebArchive war = ShrinkWrap
            .create(MavenImporter.class)
            .loadPomFromFile("pom.xml")
            .importBuildOutput()
            .as(WebArchive.class)               
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            ;

    //add built modules to ear and my application.xml  
    ear.addAsModule(ejb);  
    ear.addAsModule(war);
    ear.setApplicationXML("application.xml");

    System.out.println("END CREATE ARCHIVE");

    return ear;
}
</code></pre>

<p>However, it fails creating archive while "RESOLVING EJB DEPENDENCIES" and throw this error</p>

<pre><code>Caused by: java.lang.IllegalArgumentException: No dependencies were set for resolution
at org.jboss.shrinkwrap.resolver.impl.maven.util.Validate.notEmpty(Validate.java:78)
at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.using(MavenStrategyStageBaseImpl.java:65)
at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.withTransitivity(MavenStrategyStageBaseImpl.java:49)
at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.withTransitivity(MavenStrategyStageBaseImpl.java:38)
at ArqEjbTest.createTestArchive(ArqEjbTest.java:39)
... 61 more
</code></pre>

<p>Anyone had success with creating an archive ?</p>