[ 
https://issues.apache.org/jira/browse/MASSEMBLY-937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17152878#comment-17152878
 ] 

Michael Pilone commented on MASSEMBLY-937:
------------------------------------------

Good question. In my case I don't need the pom itself, just the transitive 
dependencies the pom brings in. I'm basically using the pom project like a 
build of materials (BOM) so I get all the associated dependencies without 
having to list them all. Of course this approach was before Maven supported 
"bom" types directly so there are probably better ways to do it now.

But there may be cases where you want the pom included and if you were using 
this functionality before with an output directory, I think you'd expect it to 
keep working the same way. That is, not filtering the pom out regardless of the 
output directory structure.

So I think the right solution is to change the line in 
{{AddDependencySetsTask.addNonArchiveDependency}} to read:
{code:java}
// omit the last char if ends with / or \\
if ( outputDirectory.isEmpty() || outputDirectory.endsWith( "/" ) || 
outputDirectory.endsWith( "\\" ) ) {code}
FWIW, I think the "/" entry is being added by plexus-archiver.ZipArchiver when 
"/jetty-deps-25.5.pom" is added. It looks like the archiver implementation 
crawls the parent path and creates a separate entry for each so all the 
directories are created when unzipping. In this case it is just crawling "/" 
and adding an entry for it. Therefore, if the above change is made, it should 
fix the empty "/" entry issue as well.

> Module pom dependency with empty outputDirectory is prefixed with forward 
> slash (/)
> -----------------------------------------------------------------------------------
>
>                 Key: MASSEMBLY-937
>                 URL: https://issues.apache.org/jira/browse/MASSEMBLY-937
>             Project: Maven Assembly Plugin
>          Issue Type: Bug
>    Affects Versions: 3.3.0
>         Environment: MacOS 10.14.6
> openjdk version "11.0.3" 2019-04-16
> OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
> OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
> Maven home: /Users/mpilone/Applications/apache-maven-3.6.3
> Java version: 11.0.3, vendor: AdoptOpenJDK, runtime: 
> /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
> Default locale: en_US, platform encoding: UTF-8
> OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
>            Reporter: Michael Pilone
>            Priority: Major
>         Attachments: bug-maven-assembly.zip
>
>
> I have a project with a pom dependency:
> {code:java}
> <dependency>
>     <groupId>org.prss.contentdepot</groupId>
>     <artifactId>jetty-deps</artifactId>
>     <version>${project.version}</version>
>     <type>pom</type>
> </dependency> {code}
> I then attempt to assemble a zip with dependencies using the assembly 
> definition:
> {code:java}
> <id>zip-with-dependencies</id>
>   <formats>
>     <format>zip</format>
>   </formats>
>   <includeBaseDirectory>false</includeBaseDirectory>  
> <dependencySets>
>     <dependencySet>
>       <outputDirectory></outputDirectory>
>       <unpack>false</unpack>
>     </dependencySet>
>   </dependencySets> {code}
> This results in the pom being prefixed with a "/" which causes unzip to 
> complain later:
> {code: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 {code}
> Unzip later:
> {code: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      {code}
> 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:
> {code: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=
> {code}
> 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:
> {code: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 {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to