blob: 8cd58ea391d3ec2dd62ec9e25dac5496037208ca [file] [log] [blame]
-----
Cookbook - How to attach source and javadoc artifacts
-----
Vincent Siveton
-----
2008-01-01
-----
~~ Licensed to the Apache Software Foundation (ASF) under one
~~ or more contributor license agreements. See the NOTICE file
~~ distributed with this work for additional information
~~ regarding copyright ownership. The ASF licenses this file
~~ to you under the Apache License, Version 2.0 (the
~~ "License"); you may not use this file except in compliance
~~ with the License. You may obtain a copy of the License at
~~
~~ http://www.apache.org/licenses/LICENSE-2.0
~~
~~ Unless required by applicable law or agreed to in writing,
~~ software distributed under the License is distributed on an
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~~ KIND, either express or implied. See the License for the
~~ specific language governing permissions and limitations
~~ under the License.
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
Cookbook: How to attach source and javadoc artifacts?
* Summary
This recipe describes how to attach source and javadoc artifacts to your build.
* Prerequisite Plugins
Here is the list of the plugins used:
*-----------------------------------------------------------+--------------+
|| <<Plugin>> || <<Version>>
*-----------------------------------------------------------+--------------+
| {{{../../plugins/maven-source-plugin/} <<<source>>>}} | 2.0.4
*-----------------------------------------------------------+--------------+
| {{{../../plugins/maven-javadoc-plugin/} <<<javadoc>>>}} | 2.3
*-----------------------------------------------------------+--------------+
* Sample Generated Output
+-----+
attach-source-javadoc
|-- pom.xml
|-- src\
`-- target
`-- attach-source-javadoc-1.0-SNAPSHOT.jar
`-- attach-source-javadoc-1.0-SNAPSHOT-javadoc.jar
`-- attach-source-javadoc-1.0-SNAPSHOT-sources.jar
+-----+
* Recipe
** Configuring Maven Source Plugin
We execute the <<<{{{../../plugins/maven-source-plugin/jar-mojo.html}source:jar}}>>> goal from the source plugin during the <<<package>>> phase.
%{snippet|id=source|url=https://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/attach-source-javadoc/pom.xml}
** Configuring Maven Javadoc Plugin
Same thing for the <<<{{{../../plugins/maven-javadoc-plugin/jar-mojo.html}javadoc:jar}}>>> goal from the javadoc plugin.
%{snippet|id=javadoc|url=https://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/attach-source-javadoc/pom.xml}
** Running Maven
Just call Maven to generate the packages:
+-----+
mvn package
+-----+
* Other Tips
To improve the build time or for a release, you could also define these plugins in a profile.
* Resources
* Source code: {{{https://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/attach-source-javadoc}https://svn.apache.org/repos/asf/maven/sandbox/trunk/site/cookbook/attach-source-javadoc}}
* {{{../../plugins/maven-javadoc-plugin/} Maven Javadoc Plugin}}
* {{{../../plugins/maven-source-plugin/} Maven Source Plugin}}
[]