Generating a JAR of the source code
For many projects, it is useful to generate a JAR of the source code along with the artifact. The source thus generated can be imported to IDEs and used for browsing and debugging. Typically, the artifacts of most open source projects are accompanied by sources and Javadocs.
How to do it...
Open a project for which you want to generate and attach the source code (
project-with-source-code
).Add the following plugin configuration to the
pom
file:<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>attach-sources</id> <phase>package</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> ...