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

Gáb*_*ták 4 maven-2 maven maven-release-plugin maven-javadoc-plugin maven-source-plugin

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

Rag*_*ram 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.


Sea*_*oyd 10

使用releaseProfiles参数(example :)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>
Run Code Online (Sandbox Code Playgroud)