[MASSEMBLY-937] Module pom dependency with empty outputDirectory is prefixed with forward slash (/)
Michael Pilone opened MASSEMBLY-937 and commented
I have a project with a pom dependency:
<dependency>
<groupId>org.prss.contentdepot</groupId>
<artifactId>jetty-deps</artifactId>
<version>${project.version}</version>
<type>pom</type>
</dependency>
I then attempt to assemble a zip with dependencies using the assembly definition:
<id>zip-with-dependencies</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory></outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
This results in the pom being prefixed with a "/" which causes unzip to complain later:
DEBUG] Extension realms for project org.prss.contentdepot:jetty-deps:pom:25.5: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project org.prss.contentdepot:shared:pom:25.5: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project org.prss.contentdepot:parent:pom:25.5: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Adding file: /Users/mpilone/.m2/repository/org/prss/contentdepot/jetty-deps/25.5/jetty-deps-25.5.pom to archive location: /jetty-deps-25.5.pom
Unzip later:
unzip ../schedulekeeper-25.5-zip-with-dependencies.zip
Archive: ../schedulekeeper-25.5-zip-with-dependencies.zip
warning: stripped absolute path spec from /
mapname: conversion of failed
inflating: orm-25.5.jar
...
inflating: jetty-client-9.4.19.v20190610.jar
inflating: jetty-io-9.4.19.v20190610.jar
warning: stripped absolute path spec from /jetty-deps-25.5.pom
inflating: jetty-deps-25.5.pom
The end result is that unzip returns a '2' error code which causes problems with exit status checks in later deployment scripts.
The root issue appears to be in AddDependencySetsTask.addNonArchiveDependency. Around line 379 (my line numbers might be off a bit from debug output), it checks if outputDirectory ends with forward-slash and if not, it adds one. But in this case outputDirectory is empty so the forward slash should not be added. Here's some debug output from within that method:
[DEBUG] MIKE: source=/Users/mpilone/.m2/repository/org/prss/contentdepot/jetty-deps/25.5/jetty-deps-25.5.pom
[DEBUG] MIKE: destName=jetty-deps-25.5.pom
[DEBUG] MIKE: target=/jetty-deps-25.5.pom
[DEBUG] MIKE: outputDirectory=
It also appears that an empty "/" is somehow getting added to the repository as well. I believe it may be related to the same non-artifact dependency:
[DEBUG] adding entry jetty-client-9.4.19.v20190610.jar
[DEBUG] adding entry jetty-io-9.4.19.v20190610.jar
[DEBUG] adding directory /
[DEBUG] adding entry /jetty-deps-25.5.pom
[DEBUG] adding entry jetty-server-9.4.19.v20190610.jar
Affects: 3.3.0
Attachments:
- bug-maven-assembly.zip (9.74 kB)