0

我有一个构建设置来运行各种任务,当我运行mvn release:preparemvn:release:perform. 具体来说,我设置了一个阶段,以便我的 javadocs 和源插件仅在我发布时运行。这使我的构建可以避免大量时间用于mvn clean install. 我想添加我的 maven-assembly-plugin jar-with-dependencies,所以只有在我发布程序集插件时才会运行。

这是我的构建的样子:

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>example</groupId>
    <artifactId>example</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Example</name>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.2.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.9</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <doclet>org.asciidoctor.Asciidoclet</doclet>
                            <docletArtifact>
                                <groupId>org.asciidoctor</groupId>
                                <artifactId>asciidoclet</artifactId>
                                <version>0.1.3</version>
                            </docletArtifact>
                            <linksource>true</linksource>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make-assembly</id>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

maven-source-plugin 和 maven-javadoc-plugin 都在发布阶段运行,但 maven-assembly-plugin 不运行。在 maven 发布期间我需要做什么才能使这个插件运行?

4

1 回答 1

1

单曲没有绑定到默认阶段,因此您必须在执行块中指定它。如果将其与javadoc:jar进行比较,您会发现此目标默认绑定到包阶段。

于 2014-01-12T12:27:24.063 回答