1 package org.apache.maven.plugins.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$ 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 * as a supplemental artifact. 49 * If not given this will create the main artifact which is the default behavior. 50 * If you try to do that a second time without using a classifier the build will fail. 51 */ 52 @Parameter 53 private String classifier; 54 55 /** 56 * {@inheritDoc} 57 */ 58 protected String getClassifier() 59 { 60 return classifier; 61 } 62 63 /** 64 * {@inheritDoc} 65 */ 66 protected String getType() 67 { 68 return "jar"; 69 } 70 71 /** 72 * {@inheritDoc} 73 */ 74 protected File getClassesDirectory() 75 { 76 return classesDirectory; 77 } 78 }