O'Reilly logo

Apache Maven Cookbook by Raghuram Bharathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. Open a project for which you want to generate and attach the source code (project-with-source-code).
  2. 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> </executions> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required