source.jar和javadoc.jar的Maven Release Plugin部署

时间:2011-01-17 12:55:07

标签: maven-2 maven maven-release-plugin maven-javadoc-plugin maven-source-plugin

我使用maven发布插件来生成项目的发布。我不想在构建时生成Javadoc。另一方面,当我调用release:perform时,我想如果maven会生成sources.jar和javadoc.jar并将其部署到maven发布存储库。只是因为我很好奇如何禁用部署source.jar,因为它看起来默认是部署的。

2 个答案:

答案 0 :(得分:10)

Maven Release Plugin的文档中,有一个useReleaseProfile参数,用于确定Whether to use the release profile that adds sources and javadocs to the released artifact, if appropriate。默认情况下为true。您可以尝试根据需要进行更改以启用/禁用source / javadocs。

答案 1 :(得分:10)

使用releaseProfiles参数(例如:src,javadoc)打开一个或多个配置文件,并在这些配置文件中定义源和javadoc生成:

<profiles>
    <profile>
        <id>src</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.1.2</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>javadoc</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.7</version>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>