mavenpom.xmlmaven-source-plugin

How to create jar archive of projects sources with maven


I include the following snippet in a projects object model

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>2.1.2</version>
  </plugin>

according to maven.apache.org the plugin attaches the jar goal to the package phase. However doing "mvn clean ; mvn package" does not generate a project-sources.jar in the target directory.

EDIT: Propably i do not understand the comment from the website, which i quoted: "[The source:jar goal] Binds by default to the lifecycle phase: package." I expected that, when i include the plugin section as shown above maven already binds the source:jar goal to the package phase. Am i mistaking here? What does the comment mean?

matthias.


Solution

  • The documentation is a little misleading. The plugin has a default execution phase of package but there is no default goal. I believe that you have specify a goal in order for the plugin to work.