Search code examples
javamavenmaven-assembly-pluginmaven-release-pluginarchiva

Maven release plugin jar-with-dependencies


I've got the maven-assembly-plugin section of the pom file made like this:

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.my.package.MyMainClass</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>.</Class-Path>
                    </manifestEntries>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
             <execution>
                 <id>make-assembly</id>
                 <goals>
                     <goal>single</goal>
                 </goals>
             </execution>
            </executions>
        </plugin>

and the maven-release-plugin like:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <goals>deploy</goals>
                <checkModificationExcludeList>pom.xml</checkModificationExcludeList>
                <tagNameFormat>@{project.version}</tagNameFormat>
                <providerImplementations>
                    <git>jgit</git>
                </providerImplementations>                  
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.scm</groupId>
                    <artifactId>maven-scm-provider-jgit</artifactId>
                    <version>1.9.2</version>
                </dependency>
            </dependencies>
        </plugin>

I need to release for Archiva a jar-with-dependency file, but the release:perform command upploads only the jar without any dependencies inside. What am I missing?


Solution

  • Ok..I'll have to answer my own question. It was just missing the execution phase "package" into the assembly plugin. This is the new one:

             <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.my.package.MyMainClass</mainClass>
                        </manifest>
                        <manifestEntries>
                            <Class-Path>.</Class-Path>
                        </manifestEntries>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                 <execution>
                     <id>make-assembly</id>
                     <goals>
                         <goal>single</goal>
                     </goals>
                 </execution>
    
                 <!-- was missing the following one -->
                 <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
    
                </executions>
            </plugin>
    

    Thanks Sergey for pointing me on the package phase.