Thursday 16 May 2013

Maven Sources Plugin

This useful plugin will generate and install a jar of the sources of the project.  Most of the time a really simple configuration works.  However, there is one thing worth noting.  If this is used with the wrong goal the sources will be regenerated.  If this is used in conjunction with the Maven Replacer Plugin then the replacer will not run as the goal for this is usually prepare-package.

So, the configuration which will not frig with the sources is


    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
            <execution>
                <id>attach-sources</id>
                <phase>verify</phase>
                <goals>
                    <goal>jar-no-fork</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

The jar-no-fork will force this plugin to use the sources which already exist.  If this is only jar then the sources will be regenerated.

No comments:

Post a Comment