apache / apache/maven-assembly-plugin

[MASSEMBLY-937] Module pom dependency with empty outputDirectory is prefixed with forward slash (/)

Open
#1,149 13 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
110
Forks
75
Avg merge
12h 54m
Merged PRs (30d)
10

Description

**[Michael Pilone](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mpilone)** opened **[MASSEMBLY-937](https://issues.apache.org/jira/browse/MASSEMBLY-937?redirect=false)** and commented

I have a project with a pom dependency:

```java

org.prss.contentdepot
jetty-deps
${project.version}
pom

```

I then attempt to assemble a zip with dependencies using the assembly definition:

```java
zip-with-dependencies

zip

false



false


```

This results in the pom being prefixed with a "/" which causes unzip to complain later:

```java
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:

```java
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:

```java
[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:

```java
[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](https://issues.apache.org/jira/secure/attachment/13007214/bug-maven-assembly.zip) (_9.74 kB_)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with AddDependencySetsTask.addNonArchiveDependency, around the line where outputDirectory and the archive target are assembled, and review the attached bug-maven-assembly.zip reproduction. Verify the empty outputDirectory case produces relative archive entries and that the resulting ZIP can be extracted without the reported absolute-path warnings or exit status 2.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
47/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.