[shrinkwrap-issues] [JBoss JIRA] (SHRINKRES-290) Shrinkwrap resolver does not honor war dependencies

Mark S (JIRA) issues at jboss.org
Tue Aug 14 13:54:00 EDT 2018


Mark S created SHRINKRES-290:
--------------------------------

             Summary: Shrinkwrap resolver does not honor war dependencies
                 Key: SHRINKRES-290
                 URL: https://issues.jboss.org/browse/SHRINKRES-290
             Project: ShrinkWrap Resolvers
          Issue Type: Bug
    Affects Versions: 2.2.6
         Environment: * Windows 10
* Eclipse Photon (4.8.0)
* org/jboss/shrinkwrap/resolver/shrinkwrap-resolver-impl-maven/2.2.6/shrinkwrap-resolver-impl-maven-2.2.6.jar
            Reporter: Mark S


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
{code:java}
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
{code}

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 - {code:xml}<build>
    <finalName>myproject-engine</finalName>
</build>{code}
* 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+*

* https://github.com/shrinkwrap/resolver/compare/2.2.4...2.2.6
    * impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenResolvedArtifactImpl.java

*+Details+*



{code:java}
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);

}
{code}

This issue is related to SHRINKRES-263




--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the shrinkwrap-issues mailing list