Uploaded image for project: 'ShrinkWrap Resolvers'
  1. ShrinkWrap Resolvers
  2. SHRINKRES-290

Shrinkwrap resolver does not honor war dependencies

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 3.0.0-alpha-3, 2.2.6
    • maven
    • None

      The recent code changes breaks Eclipse Arquillian's use of ShrinkWrap for importing *.war dependencies.

      The File "root" variable gets incorrectly created for a war ("C:\dev\source\myproject\myproject-engine\target\classes" becomes "C:\dev\source\myproject\myproject-engine\target\myproject-engine-0.0.1-SNAPSHOT"), which results in the following exception being thrown

      Caused by: java.lang.IllegalArgumentException: [SHRINKWRAP-93] Cannot use this JDK-based implementation to export as ZIP an archive with no content: myproject-engine-7035561881071493650.war: 0 assets
      

      Looking at the code there seems to be a couple of issues

      • If you don't build with Maven you may NOT create the war artifact in the expected location.
      • If the Maven war artifact has been defined in the pom.xml with a final name it will not be found. For example -
        <build>
            <finalName>myproject-engine</finalName>
        </build>
      • There is no fallback mechanism, if the war build location is not found. What I think should happen is that it falls back to default classes directory (Such as when Eclipse outputs to the classes directory)

      This is no such issue with shrinkwrap-resolver-impl-maven-2.2.4.jar

      Code Details

      Details

      File root = new File(artifact.getFile().getParentFile(), "target/classes");
      if (!Validate.isNullOrEmpty(classifier) && "tests".equals(classifier)) {
      	// SHRINKRES-102, allow test classes to be packaged as well
      	root = new File(artifact.getFile().getParentFile(), "target/test-classes");
      } else if ("war".equals(artifact.getProperty(ArtifactProperties.TYPE, null))) {
      	// SHRINKRES-263, allow .war files to be packaged as well
      	root = new File(artifact.getFile().getParentFile(), "target/" + artifactId + "-" + artifact.getVersion());
      }
      
      try {
      	File archive = File.createTempFile(artifactId + "-", "." + extension);
      	archive.deleteOnExit();
      	PackageDirHelper.packageDirectories(archive, root);
      	return archive;
      } catch (IOException e) {
      	throw new IllegalArgumentException("Unable to get artifact " + artifactId + " from the classpath", e);
      
      }
      

      This issue is related to SHRINKRES-263

              Unassigned Unassigned
              marks1900 Mark N/A (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:

                  Estimated:
                  Original Estimate - 1 hour
                  1h
                  Remaining:
                  Remaining Estimate - 1 hour
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified