I use maven release plugin for generating release of my project. I do not want to generate Javadoc all time I build. On the other hand when I call release:perform I would like if maven would generate sources.jar and javadoc.jar and would deploy it to maven release repository. Just because I am curious how deploying source.jar can be disabled, since It looks like it is deployed by default.
            Asked
            
        
        
            Active
            
        
            Viewed 7,498 times
        
    2 Answers
11
            
            
        From the documentation of Maven Release Plugin, there is a useReleaseProfile parameter, which determines Whether to use the release profile that adds sources and javadocs to the released artifact, if appropriate. This is true by default.  You can try changing this as appropriate to enable/disable source/javadocs.
 
    
    
        Raghuram
        
- 51,854
- 11
- 110
- 122
- 
                    Sadly, this now appears to be "deprecated". – tekHedd Oct 05 '20 at 18:06
10
            Use the releaseProfiles parameter (example: src,javadoc) to turn on one or more profiles, and in these profiles, define the source and javadoc generation:
<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>
 
    
    
        Sean Patrick Floyd
        
- 292,901
- 67
- 465
- 588
- 
                    Interesting, that it works only with the plugin version 2.1. So you have to say like: mvn org.apache.maven.plugins:maven-release-plugin:2.1:prepare, since with default version 2.0.beta8 is not working with this -releaseprofiles argument. – Gábor Lipták Jan 18 '11 at 08:22
