Coverage Report - org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem
 
Classes in this File Line Coverage Branch Coverage Complexity
ArtifactItem
100%
54/54
100%
6/6
1.143
 
 1  
 package org.apache.maven.plugin.dependency.fromConfiguration;
 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  
 
 24  
 import org.apache.maven.artifact.Artifact;
 25  
 import org.codehaus.plexus.util.StringUtils;
 26  
 
 27  
 /**
 28  
  * ArtifactItem represents information specified in the plugin configuration
 29  
  * section for each artifact.
 30  
  * 
 31  
  * @since 1.0
 32  
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
 33  
  * @version $Id: ArtifactItem.java 728546 2008-12-21 22:56:51Z bentmann $
 34  
  */
 35  
 public class ArtifactItem
 36  
 {
 37  
     /**
 38  
      * Group Id of Artifact
 39  
      * 
 40  
      * @parameter
 41  
      * @required
 42  
      */
 43  
     private String groupId;
 44  
 
 45  
     /**
 46  
      * Name of Artifact
 47  
      * 
 48  
      * @parameter
 49  
      * @required
 50  
      */
 51  
     private String artifactId;
 52  
 
 53  
     /**
 54  
      * Version of Artifact
 55  
      * 
 56  
      * @parameter
 57  
      */
 58  493
     private String version = null;
 59  
 
 60  
     /**
 61  
      * Type of Artifact (War,Jar,etc)
 62  
      * 
 63  
      * @parameter
 64  
      * @required
 65  
      */
 66  493
     private String type = "jar";
 67  
 
 68  
     /**
 69  
      * Classifier for Artifact (tests,sources,etc)
 70  
      * 
 71  
      * @parameter
 72  
      */
 73  
     private String classifier;
 74  
 
 75  
     /**
 76  
      * Location to use for this Artifact. Overrides default location.
 77  
      * 
 78  
      * @parameter
 79  
      */
 80  
     private File outputDirectory;
 81  
 
 82  
     /**
 83  
      * Provides ability to change destination file name
 84  
      * 
 85  
      * @parameter
 86  
      */
 87  
     private String destFileName;
 88  
 
 89  
     /**
 90  
      * Force Overwrite..this is the one to set in pom
 91  
      */
 92  
     private String overWrite;
 93  
 
 94  
     /**
 95  
      * Force Overwrite
 96  
      */
 97  
     private boolean needsProcessing;
 98  
 
 99  
     /**
 100  
      * Artifact Item
 101  
      */
 102  
     private Artifact artifact;
 103  
     
 104  
     /**
 105  
      * A comma separated list of file patterns to include when unpacking the
 106  
      * artifact.
 107  
      */
 108  
     private String includes;
 109  
 
 110  
     /**
 111  
      * A comma separated list of file patterns to exclude when unpacking the
 112  
      * artifact.
 113  
      */
 114  
     private String excludes;
 115  
 
 116  
     public ArtifactItem()
 117  24
     {
 118  
         // default constructor
 119  24
     }
 120  
 
 121  
     public ArtifactItem( Artifact artifact )
 122  469
     {
 123  469
         this.setArtifact( artifact );
 124  469
         this.setArtifactId( artifact.getArtifactId() );
 125  469
         this.setClassifier( artifact.getClassifier() );
 126  469
         this.setGroupId( artifact.getGroupId() );
 127  469
         this.setType( artifact.getType() );
 128  469
         this.setVersion( artifact.getVersion() );
 129  469
     }
 130  
 
 131  
     private String filterEmptyString( String in )
 132  
     {
 133  2515
         if ( in == null || in.equals( "" ) )
 134  
         {
 135  381
             return null;
 136  
         }
 137  
         else
 138  
         {
 139  2134
             return in;
 140  
         }
 141  
     }
 142  
 
 143  
     /**
 144  
      * @return Returns the artifactId.
 145  
      */
 146  
     public String getArtifactId()
 147  
     {
 148  144
         return artifactId;
 149  
     }
 150  
 
 151  
     /**
 152  
      * @param artifactId
 153  
      *            The artifactId to set.
 154  
      */
 155  
     public void setArtifactId( String artifact )
 156  
     {
 157  492
         this.artifactId = filterEmptyString( artifact );
 158  492
     }
 159  
 
 160  
     /**
 161  
      * @return Returns the groupId.
 162  
      */
 163  
     public String getGroupId()
 164  
     {
 165  132
         return groupId;
 166  
     }
 167  
 
 168  
     /**
 169  
      * @param groupId
 170  
      *            The groupId to set.
 171  
      */
 172  
     public void setGroupId( String groupId )
 173  
     {
 174  492
         this.groupId = filterEmptyString( groupId );
 175  492
     }
 176  
 
 177  
     /**
 178  
      * @return Returns the type.
 179  
      */
 180  
     public String getType()
 181  
     {
 182  122
         return type;
 183  
     }
 184  
 
 185  
     /**
 186  
      * @param type
 187  
      *            The type to set.
 188  
      */
 189  
     public void setType( String type )
 190  
     {
 191  492
         this.type = filterEmptyString( type );
 192  492
     }
 193  
 
 194  
     /**
 195  
      * @return Returns the version.
 196  
      */
 197  
     public String getVersion()
 198  
     {
 199  175
         return version;
 200  
     }
 201  
 
 202  
     /**
 203  
      * @param version
 204  
      *            The version to set.
 205  
      */
 206  
     public void setVersion( String version )
 207  
     {
 208  485
         this.version = filterEmptyString( version );
 209  485
     }
 210  
 
 211  
     /**
 212  
      * @return Classifier.
 213  
      */
 214  
     public String getClassifier()
 215  
     {
 216  142
         return classifier;
 217  
     }
 218  
 
 219  
     /**
 220  
      * @param classifier
 221  
      *            Classifier.
 222  
      */
 223  
     public void setClassifier( String classifier )
 224  
     {
 225  491
         this.classifier = filterEmptyString( classifier );
 226  491
     }
 227  
 
 228  
     public String toString()
 229  
     {
 230  85
         if ( this.classifier == null )
 231  
         {
 232  56
             return groupId + ":" + artifactId + ":" + StringUtils.defaultString( version, "?" ) + ":" + type;
 233  
         }
 234  
         else
 235  
         {
 236  29
             return groupId + ":" + artifactId + ":" + classifier + ":" + StringUtils.defaultString( version, "?" )
 237  
                 + ":" + type;
 238  
         }
 239  
     }
 240  
 
 241  
     /**
 242  
      * @return Returns the location.
 243  
      */
 244  
     public File getOutputDirectory()
 245  
     {
 246  525
         return outputDirectory;
 247  
     }
 248  
 
 249  
     /**
 250  
      * @param location
 251  
      *            The location to set.
 252  
      */
 253  
     public void setOutputDirectory( File outputDirectory )
 254  
     {
 255  71
         this.outputDirectory = outputDirectory;
 256  71
     }
 257  
 
 258  
     /**
 259  
      * @return Returns the location.
 260  
      */
 261  
     public String getDestFileName()
 262  
     {
 263  393
         return destFileName;
 264  
     }
 265  
 
 266  
     /**
 267  
      * @param destFileName
 268  
      *            The destFileName to set.
 269  
      */
 270  
     public void setDestFileName( String destFileName )
 271  
     {
 272  63
         this.destFileName = filterEmptyString( destFileName );
 273  63
     }
 274  
 
 275  
     /**
 276  
      * @return Returns the needsProcessing.
 277  
      */
 278  
     public boolean isNeedsProcessing()
 279  
     {
 280  73
         return this.needsProcessing;
 281  
     }
 282  
 
 283  
     /**
 284  
      * @param needsProcessing
 285  
      *            The needsProcessing to set.
 286  
      */
 287  
     public void setNeedsProcessing( boolean needsProcessing )
 288  
     {
 289  77
         this.needsProcessing = needsProcessing;
 290  77
     }
 291  
 
 292  
     /**
 293  
      * @return Returns the overWriteSnapshots.
 294  
      */
 295  
     public String getOverWrite()
 296  
     {
 297  77
         return this.overWrite;
 298  
     }
 299  
 
 300  
     /**
 301  
      * @param overWriteSnapshots
 302  
      *            The overWriteSnapshots to set.
 303  
      */
 304  
     public void setOverWrite( String overWrite )
 305  
     {
 306  8
         this.overWrite = overWrite;
 307  8
     }
 308  
 
 309  
     /**
 310  
      * @return Returns the artifact.
 311  
      */
 312  
     public Artifact getArtifact()
 313  
     {
 314  685
         return this.artifact;
 315  
     }
 316  
 
 317  
     /**
 318  
      * @param artifact
 319  
      *            The artifact to set.
 320  
      */
 321  
     public void setArtifact( Artifact artifact )
 322  
     {
 323  546
         this.artifact = artifact;
 324  546
     }
 325  
     
 326  
     /**
 327  
      * @return Returns a comma separated list of excluded items
 328  
      */
 329  
     public String getExcludes ()
 330  
     {
 331  241
         return this.excludes;
 332  
     }
 333  
     
 334  
     /**
 335  
      * @param excludes 
 336  
      *                         A comma seperated list of items to exclude 
 337  
      *                         i.e.  **\/*.xml, **\/*.properties
 338  
      */
 339  
     public void setExcludes ( String excludes )
 340  
     {
 341  57
         this.excludes = excludes;
 342  57
     }
 343  
     
 344  
     /**
 345  
      * @return Returns a comma seperated list of included items
 346  
      */
 347  
     public String getIncludes()
 348  
     {
 349  288
             return this.includes;
 350  
     }
 351  
 
 352  
     /**
 353  
      * @param includes
 354  
      *                         A comma seperated list of items to inmclude 
 355  
      *                         i.e.  **\/*.xml, **\/*.properties
 356  
      */
 357  
     public void setIncludes ( String includes )
 358  
     {
 359  55
         this.includes = includes;
 360  55
     }
 361  
 }