2

我正在尝试发布一个带有阴影工件的多模块项目。当我运行 release:prepare 然后 release:perform 上传到 Nexus 存储库的工件只包括原始 jar 而不是阴影的。

Maven“发布”是否有可能在“包”生命周期之前运行?

我正在运行的命令是:

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

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

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

谢谢, 埃亚尔

4

1 回答 1

1

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

于 2013-06-11T10:13:50.247 回答