Coverage Report - org.apache.maven.plugin.dependency.resolvers.ResolveDependenciesMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
ResolveDependenciesMojo
75%
9/12
50%
1/2
2
 
 1  
 package org.apache.maven.plugin.dependency.resolvers;
 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.IOException;
 23  
 
 24  
 import org.apache.maven.plugin.MojoExecutionException;
 25  
 import org.apache.maven.plugin.dependency.AbstractResolveMojo;
 26  
 import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
 27  
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 28  
 import org.apache.maven.plugin.dependency.utils.filters.ResolveFileFilter;
 29  
 import org.apache.maven.plugin.dependency.utils.markers.SourcesFileMarkerHandler;
 30  
 import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
 31  
 
 32  
 /**
 33  
  * Goal that resolves the project dependencies from the repository.
 34  
  * 
 35  
  * @goal resolve
 36  
  * @requiresDependencyResolution test
 37  
  * @phase generate-sources
 38  
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
 39  
  * @version $Id: ResolveDependenciesMojo.java 728546 2008-12-21 22:56:51Z bentmann $
 40  
  * @since 2.0
 41  
  */
 42  2
 public class ResolveDependenciesMojo
 43  
     extends AbstractResolveMojo
 44  
 {
 45  
 
 46  
     /**
 47  
      * If we should display the scope when resolving
 48  
      * 
 49  
      * @parameter expression="${mdep.outputScope}" default-value="true"
 50  
      * @since 2.0-alpha-2
 51  
      */
 52  
     protected boolean outputScope;
 53  
 
 54  
     /**
 55  
      * Only used to store results for integration test validation
 56  
      */
 57  
     DependencyStatusSets results;
 58  
 
 59  
     /**
 60  
      * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version.
 61  
      * 
 62  
      * @throws MojoExecutionException with a message if an error occurs.
 63  
      */
 64  
     public void execute()
 65  
         throws MojoExecutionException
 66  
     {
 67  
         // get sets of dependencies
 68  2
         results = this.getDependencySets( false );
 69  
 
 70  2
         String output = results.getOutput( outputAbsoluteArtifactFilename, outputScope );
 71  
         try
 72  
         {
 73  2
             if ( outputFile == null )
 74  
             {
 75  2
                 DependencyUtil.log( output, getLog() );
 76  
             }
 77  
             else
 78  
             {
 79  0
                 DependencyUtil.write( output, outputFile, getLog() );
 80  
             }
 81  
         }
 82  0
         catch ( IOException e )
 83  
         {
 84  0
             throw new MojoExecutionException(e.getMessage(),e);
 85  2
         }
 86  2
     }
 87  
 
 88  
     /**
 89  
      * @return Returns the results.
 90  
      */
 91  
     public DependencyStatusSets getResults()
 92  
     {
 93  2
         return this.results;
 94  
     }
 95  
 
 96  
     protected ArtifactsFilter getMarkedArtifactFilter()
 97  
     {
 98  2
         return new ResolveFileFilter( new SourcesFileMarkerHandler( this.markersDirectory ) );
 99  
     }
 100  
 }