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 org.apache.maven.plugins.annotations.LifecyclePhase; 23 import org.apache.maven.plugins.annotations.Mojo; 24 import org.apache.maven.plugins.annotations.Parameter; 25 import org.apache.maven.plugins.annotations.ResolutionScope; 26 27 import java.io.File; 28 29 /** 30 * Build a JAR from the current project. 31 * 32 * @author <a href="evenisse@apache.org">Emmanuel Venisse</a> 33 * @version $Id: JarMojo.java 1525834 2013-09-24 10:39:09Z olamy $ 34 */ 35 @Mojo( name = "jar", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true, 36 requiresDependencyResolution = ResolutionScope.RUNTIME ) 37 public class JarMojo 38 extends AbstractJarMojo 39 { 40 /** 41 * Directory containing the classes and resource files that should be packaged into the JAR. 42 */ 43 @Parameter( defaultValue = "${project.build.outputDirectory}", required = true ) 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( property = "maven.jar.classifier", defaultValue = "" ) 52 private String classifier; 53 54 protected String getClassifier() 55 { 56 return classifier; 57 } 58 59 /** 60 * @return type of the generated artifact 61 */ 62 protected String getType() 63 { 64 return "jar"; 65 } 66 67 /** 68 * Return the main classes directory, so it's used as the root of the jar. 69 */ 70 protected File getClassesDirectory() 71 { 72 return classesDirectory; 73 } 74 }