maven-release-plugin不包含着色的工件

时间:2013-06-11 10:06:06

标签: maven lifecycle maven-release-plugin maven-shade-plugin

我正在尝试使用着色工件发布多模块项目。 当我运行发布时:准备然后发布:执行上传到Nexus存储库的工件只包括原始jar而不是阴影jar。

Maven“release”是否有可能在“package”生命周期之前运行?

我正在运行的命令是:

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

我的父pom.xml是:

<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>

分发项目的pom.xml看起来像

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

http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT;              我的项目父         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>

我计算机上的文件夹中有阴影工件,但Nexus存储库中的工件只包含原来的空Jar。

有没有办法强制释放以抓住阴影罐?

谢谢, 的Eyal

1 个答案:

答案 0 :(得分:1)

您可以尝试在maven-shade-plugin配置中添加标记<shadedArtifactAttached>true</shadedArtifactAttached>