>From the small snippet of log, it's bit confusing, because it looks like the 
>artifact you are assembling is named the same as the dependency you are 
>pulling in. Because you have this setting in the maven-assembly-plugin: 
                                 <appendAssemblyId>                             
         false                               </appendAssemblyId>

The generated Artifact is being named:
        MyArtifact-8.0.0.jar

Instead of being named:
        MyArtifact-bin-8.0.0.jar

Additionally, look at version range declaration for MyArtifact...

<version>[8.0.0-SNAPSHOT,9.0.0-SNAPSHOT)</version>

Per this enforcer docs: 
https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html

I would read your requirement as 
        8.0.0-SNAPSHOT >= X < 9.0.0-SNAPSHOT

So it's not renaming your jar, it is fetching the most current version of the 
dependent artifact defined for that range and adding it into your current 
project assembly which just so happens to now have the same name AND a similar 
version number.


Jim Klo
Senior Software Engineer
Center for Software Engineering
SRI International
 t.             @nsomnac 
 

On 12/15/17, 8:51 AM, "Wilson, Sam" <sawil...@akamai.com> wrote:

    Sorry to bump and old thread, but I’d appreciate it if someone had any 
insight.
    
    Sam
    
    From: Sam Wilson <sawil...@akamai.com>
    Reply-To: Maven Users List <users@maven.apache.org>
    Date: Friday, November 24, 2017 at 11:12 AM
    To: "users@maven.apache.org" <users@maven.apache.org>
    Subject: Re: Maven Assembly Plugin renaming jar
    
    Oh, I should mention that I've tried this with maven-assembly-plugin 2.4
    and 3.1.0.
    
    Sam
    
    On 11/24/2017 11:07 AM, Wilson, Sam wrote:
    Hey!
    Hopefully you can help me out. Maven assembly plugin seems to be renaming a 
jar file without being told to, and it’s messing up my MANIFEST.MF classpath.
    You notice in the snippet of mvn -X below the assembly plugin seems to be 
getting version 8.0.2, but it renames it to 8.0.0.
    Thanks,
    Sam
    ---
    mvn -X package
    --
    […]
    [DEBUG] Adding dependency artifact com.example:MyArtifact:jar:8.0.0.
    [DEBUG] Adding artifact: com.example:MyArtifact:jar:8.0.0 with file: 
/Users/me/.m2/repository/com/example/MyArtifact/8.0.2/MyArtifact-8.0.2.jar to 
assembly location: lib/MyArtifact-8.0.0.jar.
    [DEBUG] Adding file: 
/Users/me/.m2/repository/com/example/MyArtifact/8.0.2/MyArtifact-8.0.2.jar to 
archive location: Project/lib/MyArtifact-8.0.0.jar
    […]
    ---
    Project/pom.xml
    ---
    <project>
         <!-- ... -->
         <dependencies>
                 <!-- ... -->
                 <dependency>
                     <groupId>com.example</groupId>
                     <artifactId>MyArtifact</artifactId>
                     <version>[8.0.0-SNAPSHOT,9.0.0-SNAPSHOT)</version>
                 </dependency>
         </dependencies>
         <build>
             <plugins>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-jar-plugin</artifactId>
                     <version>2.4</version>
                     <configuration>
                         <archive>
                             <manifest>
                                 <addClasspath>true</addClasspath>
                                 <classpathPrefix>lib/</classpathPrefix>
                                 <mainClass>com.example.MainClass</mainClass>
                             </manifest>
                         </archive>
                     </configuration>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-assembly-plugin</artifactId>
                     <version>2.2</version>
                     <executions>
                         <execution>
                             <phase>package</phase>
                             <goals>
                                 <goal>single</goal>
                             </goals>
                             <configuration>
                                 <finalName>
                                     ${project.artifactId}
                                 </finalName>
                                 <appendAssemblyId>
                                     false
                                 </appendAssemblyId>
                                 <descriptors>
                                     
<descriptor>src/assembly/bin.xml</descriptor>
                                 </descriptors>
                                 <attach>false</attach>
                             </configuration>
                         </execution>
                     </executions>
                 </plugin>
    </project>
    ---
    Project/src/assembly/bin.xml
    ---
    <assembly
             
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0";
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
             
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
 
http://maven.apache.org/xsd/assembly-1.1.0.xsd";<http://maven.apache.org/xsd/assembly-1.1.0.xsd%22>>
             <id>bin</id>
             <baseDirectory>${artifactId}</baseDirectory>
             <formats>
                     <format>tar.gz</format>
                     <format>dir</format>
             </formats>
             <dependencySets>
                     <dependencySet>
                             <useProjectArtifact>false</useProjectArtifact>
                             <unpack>false</unpack>
                             <scope>runtime</scope>
                             <outputDirectory>lib</outputDirectory>
                     </dependencySet>
             </dependencySets>
             <files>
                     <file>
                             
<source>target/${artifactId}-${version}.${packaging}</source>
                             <outputDirectory>/</outputDirectory>
                             <destName>${artifactId}.${packaging}</destName>
                     </file>
                     <file>
                             
<source>src/main/resources/ProjectConfiguration.properties</source>
                             <destName>${artifactId}.properties</destName>
                             <outputDirectory>/</outputDirectory>
                     </file>
                     <file>
                             <source>log4j2.xml</source>
                             <outputDirectory>/</outputDirectory>
                     </file>
             </files>
    </assembly>
    
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: 
users-unsubscr...@maven.apache.org<mailto:users-unsubscr...@maven.apache.org>
    For additional commands, e-mail: 
users-h...@maven.apache.org<mailto:users-h...@maven.apache.org>
    
    
    

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to