Coverage Report - org.apache.maven.archetype.mojos.JarMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
JarMojo
0%
0/9
N/A
5
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 
 20  
 package org.apache.maven.archetype.mojos;
 21  
 
 22  
 import java.io.IOException;
 23  
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 24  
 import org.apache.maven.plugin.AbstractMojo;
 25  
 import org.apache.maven.plugin.MojoExecutionException;
 26  
 import org.apache.maven.plugin.MojoFailureException;
 27  
 import org.apache.maven.project.MavenProject;
 28  
 import java.io.File;
 29  
 import org.apache.maven.archetype.Archetype;
 30  
 
 31  
 /**
 32  
  * @author           rafale
 33  
  * @goal             jar
 34  
  * @phase            package
 35  
  * @requiresProject
 36  
  */
 37  0
 public class JarMojo
 38  
     extends AbstractMojo
 39  
 {
 40  
     /**
 41  
      * Directory containing the classes.
 42  
      *
 43  
      * @parameter  expression="${project.build.outputDirectory}"
 44  
      * @required
 45  
      */
 46  
     private File archetypeDirectory;
 47  
 
 48  
     /**
 49  
      * Name of the generated JAR.
 50  
      *
 51  
      * @parameter  alias="jarName" expression="${project.build.finalName}"
 52  
      * @required
 53  
      */
 54  
     private String finalName;
 55  
 
 56  
     /**
 57  
      * Directory containing the generated JAR.
 58  
      *
 59  
      * @parameter  expression="${project.build.directory}"
 60  
      * @required
 61  
      */
 62  
     private File outputDirectory;
 63  
 
 64  
     /**
 65  
      * The maven project.
 66  
      *
 67  
      * @parameter  expression="${project}"
 68  
      * @required
 69  
      * @readonly
 70  
      */
 71  
     private MavenProject project;
 72  
 
 73  
     /**
 74  
      * The archetype component.
 75  
      *
 76  
      * @component
 77  
      */
 78  
     private Archetype archetype;
 79  
 
 80  
     public void execute( )
 81  
         throws MojoExecutionException, MojoFailureException
 82  
     {
 83  
         try
 84  
         {
 85  0
             File jarFile = archetype.archiveArchetype( archetypeDirectory, outputDirectory, finalName );
 86  
 
 87  0
             project.getArtifact().setFile( jarFile );
 88  
         }
 89  0
         catch ( DependencyResolutionRequiredException ex )
 90  
         {
 91  0
             throw new MojoExecutionException( ex.getMessage(  ), ex );
 92  
         }
 93  0
         catch ( IOException ex )
 94  
         {
 95  0
             throw new MojoExecutionException( ex.getMessage(  ), ex );
 96  0
         }
 97  0
     }
 98  
 }