I am trying to release a multi module project with shaded artifacts. When I run the release:prepare then release:perform the artifacts uploaded to the Nexus repository include only the original jar and not the shaded one.

Is it possible that the Maven "release" runs before the "package" lifecycle?

The command I'm running is:

mvn release:prepare --batch-mode -Dtag=myproject-1.2.0.0000 -DreleaseVersion=1.2.0 -DdevelopmentVersion=1.2.0 -DremoteTagging=false -DsuppressCommitBeforeTag=true -Dresume=false

my parent pom.xml is:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>myproject</name>
<groupId>org.my.project</groupId>
<artifactId>my-project-parent</artifactId>
<version>1.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<description>myproject</description>

<modules>
    <module>module1</module>
    <module>module2</module>
    <module>distribution</module>
</modules>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

    </plugins>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.12.3</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<dependencyManagement>
    <dependencies>
        <!-- self-dependencies -->
        <dependency>
            <groupId>org.my.project</groupId>
            <artifactId>module1</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.my.project</groupId>
            <artifactId>module2</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>
<profiles>
    <profile>
        <id>development</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
</profiles>

The pom.xml of the distribution project looks like

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd"> my-project-parent org.my.project 1.2.0-SNAPSHOT 4.0.0

<artifactId>distribution</artifactId>
        <dependencies>
            <dependency>
                <groupId>org.my.project</groupId>
                <artifactId>module1</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>org.my.project</groupId>
                <artifactId>module2</artifactId>
                <version>${project.version}</version>
            </dependency>                
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <outputFile>${project.build.directory}/myproject-${project.version}.jar</outputFile>
                                <createSourcesJar>true</createSourcesJar>
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>log4j.xml</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <artifactSet>
                                    <includes>
                                        <include>org.my.project:module*</include>
                                    </includes>
                                </artifactSet>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

The folder on my computer has the shaded artifact, but the artifacts in Nexus repository conatin only the original empty Jar.

Is there a way to force the release to grab the shaded jar?

Thanks, Eyal

有帮助吗?

解决方案

You may try to add the tag <shadedArtifactAttached>true</shadedArtifactAttached> in your maven-shade-plugin configuration.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top