Coverage Report - org.apache.maven.plugin.dependency.AbstractResolveMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractResolveMojo
10%
1/10
0%
0/2
1.5
 
 1  
 package org.apache.maven.plugin.dependency;
 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.io.File;
 23  
 import java.util.Iterator;
 24  
 import java.util.Set;
 25  
 
 26  
 import org.apache.maven.artifact.Artifact;
 27  
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 28  
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 29  
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 30  
 import org.apache.maven.project.MavenProject;
 31  
 import org.apache.maven.project.MavenProjectBuilder;
 32  
 import org.apache.maven.project.ProjectBuildingException;
 33  
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 34  
 
 35  
 /**
 36  
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
 37  
  * @version $Id: AbstractResolveMojo.java 728546 2008-12-21 22:56:51Z bentmann $
 38  
  * 
 39  
  */
 40  2
 public abstract class AbstractResolveMojo
 41  
     extends AbstractDependencyFilterMojo
 42  
 {
 43  
     /**
 44  
      * Project builder -- builds a model from a pom.xml
 45  
      * 
 46  
      * @component role="org.apache.maven.project.MavenProjectBuilder"
 47  
      * @required
 48  
      * @readonly
 49  
      */
 50  
     protected MavenProjectBuilder mavenProjectBuilder;
 51  
     /**
 52  
      * If specified, this parameter will cause the dependencies to be written to the path specified, instead of writing
 53  
      * to the console.
 54  
      * 
 55  
      * @parameter expression="${outputFile}"
 56  
      * @since 2.0
 57  
      */
 58  
     protected File outputFile;
 59  
     /**
 60  
      * This method resolves the dependency artifacts from the project.
 61  
      * 
 62  
      * @param theProject
 63  
      *            The POM.
 64  
      * @return resolved set of dependency artifacts.
 65  
      * 
 66  
      * @throws ArtifactResolutionException
 67  
      * @throws ArtifactNotFoundException
 68  
      * @throws InvalidDependencyVersionException
 69  
      */
 70  
     protected Set resolveDependencyArtifacts( MavenProject theProject )
 71  
         throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException
 72  
     {
 73  0
         Set artifacts = theProject.createArtifacts( this.factory, Artifact.SCOPE_TEST,
 74  
                                                     new ScopeArtifactFilter( Artifact.SCOPE_TEST ) );
 75  
 
 76  0
         for ( Iterator i = artifacts.iterator(); i.hasNext(); )
 77  
         {
 78  0
             Artifact artifact = (Artifact) i.next();
 79  
             // resolve the new artifact
 80  0
             this.resolver.resolve( artifact, this.remoteRepos, this.local );
 81  0
         }
 82  0
         return artifacts;
 83  
     }
 84  
 
 85  
     /**
 86  
      * This method resolves all transitive dependencies of an artifact.
 87  
      * 
 88  
      * @param artifact
 89  
      *            the artifact used to retrieve dependencies
 90  
      * 
 91  
      * @return resolved set of dependencies
 92  
      * 
 93  
      * @throws ArtifactResolutionException
 94  
      * @throws ArtifactNotFoundException
 95  
      * @throws ProjectBuildingException
 96  
      * @throws InvalidDependencyVersionException
 97  
      */
 98  
     protected Set resolveArtifactDependencies( Artifact artifact )
 99  
         throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException,
 100  
         InvalidDependencyVersionException
 101  
     {
 102  0
         Artifact pomArtifact = this.factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact
 103  
             .getVersion(), "", "pom" );
 104  
 
 105  0
         MavenProject pomProject = mavenProjectBuilder.buildFromRepository( pomArtifact, this.remoteRepos, this.local );
 106  
 
 107  0
         return resolveDependencyArtifacts( pomProject );
 108  
     }
 109  
 }