0 Replies Latest reply on Dec 7, 2014 11:36 AM by Greg Lanthier

    Is it possible to override the ZipExporter used by ShrinkWrap when it deploys wars to Liberty Profile containers?

    Greg Lanthier Newbie

      I work with WebSphere Liberty Profile on a JEE application that has grown to a hefty size.

       

      I'd like to use Arquillian for testing this project.

       

      I've managed to get unit tests to run properly using @RunWith(Arquillian.class) and can see results - which is great!

       

      What is not so great is the fact that I have to wait for up to 60 seconds for ShrinkWrap to generate a war that it can deploy to the Liberty container.  I'm using the Maven resolver to assemble all the dependencies for the JEE application and there are many many many dependencies.  Zipping up all those dependencies into the test war takes a while.

       

      I thought about this for a while and decided to see if it were possible to use ShrinkWrap to mimic the deployment file that the WebSphere Liberty Profile developer tools for Eclipse generates instead of using ShrinkWrap to package up a war.

       

      The WebSphere Liberty Profile developer tools for Eclipse generates an XML file that has the same name as the WAR file (except with an xml extension) and the contents of the XML file list the paths to the jars that would go into the WAR.  This lets Maven resolve all the dependencies for the application, yet avoids the cost of zipping up all these dependencies into a single WAR file.

       

      For example, if I were working on a project that deployed a war called "foo.war" to Liberty the WebSphere Liberty Profile developer tools for Eclipse would generate an xml file called foo.war.xml that looked something like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <archive>
          <archive targetInArchive="/WEB-INF/lib/component1.jar">
              <dir sourceOnDisk="/home/lanthieg/workspace/foo-parent/component1/target/classes" targetInArchive="/"/>
          </archive>
          ...
          <-- many more sorce projects -->
          ...
          <file sourceOnDisk="/home/lanthieg/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar" targetInArchive="/WEB-INF/lib/commons-io-2.4.jar"/>
          <file sourceOnDisk="/home/lanthieg/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" targetInArchive="/WEB-INF/lib/commons-collections-3.2.1.jar"/>
          <file sourceOnDisk="/home/lanthieg/.m2/repository/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar" targetInArchive="/WEB-INF/lib/slf4j-api-1.7.5.jar"/>
          ...
          <-- many more dependency jars -->
          ...
      </archive>
      

       

      Does anyone have ideas or suggestions on if it would be possible to generate this type of XML file rather than a war is possible with ShrinkWrap?

       

      If you use WebSphere Liberty Profile and Arquillian do you think something like this would be useful?

       

      I guess what I'm hoping is there is someway I can execute code like this:

       

                JavaArchive[] resolvedArtifacts = Maven.configureResolver()
                          .withMavenCentralRepo(false).loadPomFromFile("pom.xml")
                          .importRuntimeAndTestDependencies().resolve()
                          .withTransitivity().as(JavaArchive.class);
      
                WebArchive jar = ShrinkWrap
                          .create(WebArchive.class)
                          .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                          .addAsLibraries(resolvedArtifacts);
      
                jar.as(ZipExporter.class).exportTo(new File("target/foo.war.xml"), true);  // Except use my own implementation of ZipExporter?
      

       

      and get the same type of deployment file that the WebSphere Liberty Profile developer tools for Eclipse would generate.

       

      Is this the sort of thing that would be done in the WebSphere Liberty Profile Container extension for Arquillian?  For example, could this ZipExporter override be accomplished in the following component?

      <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-wlp-managed-8.5</artifactId>
      <version>1.0.0.Beta1</version>
      <scope>test</scope>
      </dependency>
      

       

      I'm using the following Arquillian dependency stanzas in my pom:

      <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-wlp-managed-8.5</artifactId>
      <version>1.0.0.Beta1</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.arquillian.extension</groupId>
      <artifactId>arquillian-jacoco</artifactId>
      <version>1.0.0.Alpha7</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.shrinkwrap.resolver</groupId>
      <artifactId>shrinkwrap-resolver-depchain</artifactId>
      <scope>test</scope>
      <type>pom</type>
      </dependency>
      
      

       

      with the following arquillian bom in my dependenciesManagement section:

      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>1.1.5.Final</version>
      <type>pom</type>
      <scope>import</scope>
      </dependency>
      </dependencies>
      </dependencyManagement>