Coverage Report - org.apache.maven.plugin.assembly.mojos.AttachComponentDescriptorMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
AttachComponentDescriptorMojo
0%
0/8
N/A
1
 
 1  
 package org.apache.maven.plugin.assembly.mojos;
 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.artifact.Artifact;
 23  
 import org.apache.maven.artifact.factory.ArtifactFactory;
 24  
 import org.apache.maven.artifact.handler.ArtifactHandler;
 25  
 import org.apache.maven.plugin.AbstractMojo;
 26  
 import org.apache.maven.plugin.MojoExecutionException;
 27  
 import org.apache.maven.plugin.MojoFailureException;
 28  
 import org.apache.maven.project.MavenProject;
 29  
 import org.apache.maven.project.MavenProjectHelper;
 30  
 
 31  
 import java.io.File;
 32  
 
 33  
 /**
 34  
  * @version $Id: AttachComponentDescriptorMojo.java 610981 2008-01-10 23:10:00Z vsiveton $
 35  
  * @goal attach-component-descriptor
 36  
  * @phase package
 37  
  */
 38  0
 public class AttachComponentDescriptorMojo
 39  
     extends AbstractMojo
 40  
 {
 41  
 
 42  
     /**
 43  
      * @parameter default-value="src/main/resources/assembly-component.xml"
 44  
      * @required
 45  
      */
 46  
     private File componentDescriptor;
 47  
 
 48  
     /**
 49  
      * @parameter default-value="${project}"
 50  
      * @required
 51  
      * @readonly
 52  
      */
 53  
     private MavenProject project;
 54  
 
 55  
     /**
 56  
      * @component role-hint="assembly-component"
 57  
      */
 58  
     private ArtifactHandler handler;
 59  
 
 60  
     /**
 61  
      * @component
 62  
      */
 63  
     private MavenProjectHelper projectHelper;
 64  
 
 65  
     /**
 66  
      * @component
 67  
      */
 68  
     private ArtifactFactory factory;
 69  
 
 70  
     public void execute()
 71  
         throws MojoExecutionException, MojoFailureException
 72  
     {
 73  0
         Artifact artifact = factory.createProjectArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion() );
 74  0
         artifact.setFile( project.getFile() );
 75  
 
 76  0
         getLog().debug( "Replacing main project artifact with POM artifact: " + artifact.getId() );
 77  
 
 78  0
         project.setArtifact( artifact );
 79  
 
 80  0
         getLog().info( "Attaching assembly-component descriptor: " + componentDescriptor + " to the main project artifact under type: " + handler.getExtension() + " and classifier: " + handler.getClassifier() );
 81  
 
 82  0
         projectHelper.attachArtifact( project, handler.getExtension(), handler.getClassifier(), componentDescriptor );
 83  0
     }
 84  
 
 85  
 }