Coverage Report - org.apache.maven.tools.plugin.DefaultPluginToolsRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultPluginToolsRequest
25 %
8/31
0 %
0/4
1,133
 
 1  
 package org.apache.maven.tools.plugin;
 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.repository.ArtifactRepository;
 24  
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 25  
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 26  
 import org.apache.maven.project.MavenProject;
 27  
 import org.codehaus.plexus.util.ReaderFactory;
 28  
 import org.codehaus.plexus.util.StringUtils;
 29  
 
 30  
 import java.util.HashSet;
 31  
 import java.util.List;
 32  
 import java.util.Set;
 33  
 
 34  
 /**
 35  
  * Default implementation of {@link PluginToolsRequest}, which is used to pass parameters to components used to extract
 36  
  * {@link MojoDescriptor} instances from different types of metadata for a given plugin.
 37  
  *
 38  
  * @author jdcasey
 39  
  * @since 2.5
 40  
  */
 41  
 public class DefaultPluginToolsRequest
 42  
     implements PluginToolsRequest
 43  
 {
 44  
 
 45  1
     private static final String DEFAULT_ENCODING = ReaderFactory.FILE_ENCODING;
 46  
 
 47  
     private PluginDescriptor pluginDescriptor;
 48  
 
 49  
     private MavenProject project;
 50  
 
 51  5
     private String encoding = DEFAULT_ENCODING;
 52  
 
 53  
     private boolean skipErrorNoDescriptorsFound;
 54  
 
 55  
     private Set<Artifact> dependencies;
 56  
 
 57  
     private List<ArtifactRepository> remoteRepos;
 58  
 
 59  
     private ArtifactRepository local;
 60  
 
 61  
     public DefaultPluginToolsRequest( MavenProject project, PluginDescriptor pluginDescriptor )
 62  5
     {
 63  5
         this.project = project;
 64  5
         this.pluginDescriptor = pluginDescriptor;
 65  5
     }
 66  
 
 67  
     /**
 68  
      * {@inheritDoc}
 69  
      */
 70  
     public PluginDescriptor getPluginDescriptor()
 71  
     {
 72  25
         return pluginDescriptor;
 73  
     }
 74  
 
 75  
     /**
 76  
      * {@inheritDoc}
 77  
      */
 78  
     public PluginToolsRequest setPluginDescriptor( PluginDescriptor pluginDescriptor )
 79  
     {
 80  0
         this.pluginDescriptor = pluginDescriptor;
 81  0
         return this;
 82  
     }
 83  
 
 84  
     /**
 85  
      * {@inheritDoc}
 86  
      */
 87  
     public MavenProject getProject()
 88  
     {
 89  0
         return project;
 90  
     }
 91  
 
 92  
     /**
 93  
      * {@inheritDoc}
 94  
      */
 95  
     public PluginToolsRequest setProject( MavenProject project )
 96  
     {
 97  0
         this.project = project;
 98  0
         return this;
 99  
     }
 100  
 
 101  
     /**
 102  
      * {@inheritDoc}
 103  
      */
 104  
     public String getEncoding()
 105  
     {
 106  0
         return this.encoding;
 107  
     }
 108  
 
 109  
     /**
 110  
      * {@inheritDoc}
 111  
      */
 112  
     public PluginToolsRequest setEncoding( String encoding )
 113  
     {
 114  0
         if ( StringUtils.isNotEmpty( encoding ) )
 115  
         {
 116  0
             this.encoding = encoding;
 117  
         }
 118  
         else
 119  
         {
 120  0
             this.encoding = DEFAULT_ENCODING;
 121  
         }
 122  
 
 123  0
         return this;
 124  
     }
 125  
 
 126  
     /**
 127  
      * {@inheritDoc}
 128  
      */
 129  
     public boolean isSkipErrorNoDescriptorsFound()
 130  
     {
 131  1
         return skipErrorNoDescriptorsFound;
 132  
     }
 133  
 
 134  
     /**
 135  
      * {@inheritDoc}
 136  
      */
 137  
     public PluginToolsRequest setSkipErrorNoDescriptorsFound( boolean skipErrorNoDescriptorsFound )
 138  
     {
 139  0
         this.skipErrorNoDescriptorsFound = skipErrorNoDescriptorsFound;
 140  0
         return this;
 141  
     }
 142  
 
 143  
     public Set<Artifact> getDependencies()
 144  
     {
 145  0
         if ( this.dependencies == null )
 146  
         {
 147  0
             this.dependencies = new HashSet<Artifact>();
 148  
         }
 149  0
         return dependencies;
 150  
     }
 151  
 
 152  
     public PluginToolsRequest setDependencies( Set<Artifact> dependencies )
 153  
     {
 154  0
         this.dependencies = dependencies;
 155  0
         return this;
 156  
     }
 157  
 
 158  
     public List<ArtifactRepository> getRemoteRepos()
 159  
     {
 160  0
         return remoteRepos;
 161  
     }
 162  
 
 163  
     public PluginToolsRequest setRemoteRepos( List<ArtifactRepository> remoteRepos )
 164  
     {
 165  0
         this.remoteRepos = remoteRepos;
 166  0
         return this;
 167  
     }
 168  
 
 169  
     public ArtifactRepository getLocal()
 170  
     {
 171  0
         return local;
 172  
     }
 173  
 
 174  
     public PluginToolsRequest setLocal( ArtifactRepository local )
 175  
     {
 176  0
         this.local = local;
 177  0
         return this;
 178  
     }
 179  
 }