View Javadoc

1   package org.apache.maven.plugin.jar;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  /**
25   * Build a JAR from the current project.
26   *
27   * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
28   * @version $Id: JarMojo.java 1211837 2011-12-08 11:23:22Z bimargulies $
29   * @goal jar
30   * @phase package
31   * @requiresProject
32   * @threadSafe
33   * @requiresDependencyResolution runtime
34   */
35  public class JarMojo
36      extends AbstractJarMojo
37  {
38      /**
39       * Directory containing the classes and resource files that should be packaged into the JAR.
40       *
41       * @parameter default-value="${project.build.outputDirectory}"
42       * @required
43       */
44      private File classesDirectory;
45  
46      /**
47       * Classifier to add to the artifact generated. If given, the artifact will be attached.
48       * If this is not given,it will merely be written to the output directory
49       * according to the finalName.
50       *
51       * @parameter
52       */
53      private String classifier;
54  
55      protected String getClassifier()
56      {
57          return classifier;
58      }
59  
60      /**
61       * @return type of the generated artifact
62       */
63      protected String getType()
64      {
65          return "jar";
66      }
67  
68      /**
69       * Return the main classes directory, so it's used as the root of the jar.
70       */
71      protected File getClassesDirectory()
72      {
73          return classesDirectory;
74      }
75  }