Coverage Report - org.apache.maven.plugin.coreit.AggregateTestMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
AggregateTestMojo
0 %
0/14
0 %
0/4
3
 
 1  
 package org.apache.maven.plugin.coreit;
 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.util.Iterator;
 23  
 import java.util.List;
 24  
 
 25  
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 26  
 import org.apache.maven.plugin.MojoExecutionException;
 27  
 import org.apache.maven.project.MavenProject;
 28  
 
 29  
 /**
 30  
  * Combines dependency collection with aggregation. The path parameters of this mojo support the token
 31  
  * <code>&#64;artifactId&#64;</code> to dynamically adjust the output file for each project in the reactor whose
 32  
  * dependencies are dumped.
 33  
  * 
 34  
  * @goal aggregate-test
 35  
  * @requiresDependencyResolution test
 36  
  * @aggregator true
 37  
  * 
 38  
  * @author Benjamin Bentmann
 39  
  * @version $Id: AggregateTestMojo.java 809429 2009-08-30 22:24:31Z bentmann $
 40  
  */
 41  0
 public class AggregateTestMojo
 42  
     extends AbstractDependencyMojo
 43  
 {
 44  
 
 45  
     /**
 46  
      * The path to the output file for the project artifacts, relative to the project base directory. Each line of this
 47  
      * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
 48  
      * disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that
 49  
      * do not contribute to the class path.
 50  
      * 
 51  
      * @parameter expression="${depres.projectArtifacts}"
 52  
      */
 53  
     private String projectArtifacts;
 54  
 
 55  
     /**
 56  
      * The Maven projects in the reactor.
 57  
      * 
 58  
      * @parameter default-value="${reactorProjects}"
 59  
      * @readonly
 60  
      */
 61  
     private List reactorProjects;
 62  
 
 63  
     /**
 64  
      * Runs this mojo.
 65  
      * 
 66  
      * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
 67  
      */
 68  
     public void execute()
 69  
         throws MojoExecutionException
 70  
     {
 71  
         try
 72  
         {
 73  0
             for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
 74  
             {
 75  0
                 MavenProject project = (MavenProject) it.next();
 76  
 
 77  0
                 writeArtifacts( filter( projectArtifacts, project ), project.getArtifacts() );
 78  
 
 79  
                 // NOTE: We can't make any assumptions about the class path but as a minimum it must not cause an exception
 80  0
                 project.getTestClasspathElements();
 81  0
             }
 82  
         }
 83  0
         catch ( DependencyResolutionRequiredException e )
 84  
         {
 85  0
             throw new MojoExecutionException( "Failed to resolve dependencies", e );
 86  0
         }
 87  0
     }
 88  
 
 89  
     private String filter( String filename, MavenProject project )
 90  
     {
 91  0
         String result = filename;
 92  
 
 93  0
         if ( filename != null )
 94  
         {
 95  0
             result = result.replaceAll( "@artifactId@", project.getArtifactId() );
 96  
         }
 97  
 
 98  0
         return result;
 99  
     }
 100  
 
 101  
 }