Coverage Report - org.apache.maven.shared.invoker.DefaultInvocationRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultInvocationRequest
74%
66/89
43%
6/14
1,018
 
 1  
 package org.apache.maven.shared.invoker;
 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.io.InputStream;
 24  
 import java.util.Collections;
 25  
 import java.util.HashMap;
 26  
 import java.util.List;
 27  
 import java.util.Map;
 28  
 import java.util.Properties;
 29  
 
 30  
 /**
 31  
  * Specifies the parameters used to control a Maven invocation.
 32  
  * 
 33  
  * @version $Id: DefaultInvocationRequest.java 807415 2009-08-24 22:32:16Z olamy $
 34  
  */
 35  84
 public class DefaultInvocationRequest
 36  
     implements InvocationRequest
 37  
 {
 38  
 
 39  
     private File basedir;
 40  
 
 41  
     private boolean debug;
 42  
 
 43  
     private InvocationOutputHandler errorHandler;
 44  
 
 45  84
     private String failureBehavior = REACTOR_FAIL_FAST;
 46  
 
 47  
     private List goals;
 48  
 
 49  
     private InputStream inputStream;
 50  
 
 51  
     private boolean interactive;
 52  
 
 53  
     private File localRepository;
 54  
 
 55  
     private boolean offline;
 56  
 
 57  84
     private boolean recursive = true;
 58  
 
 59  
     private InvocationOutputHandler outputHandler;
 60  
 
 61  
     private File pomFile;
 62  
 
 63  
     private Properties properties;
 64  
 
 65  
     private boolean showErrors;
 66  
 
 67  
     private boolean updateSnapshots;
 68  
 
 69  84
     private boolean shellEnvironmentInherited = true;
 70  
 
 71  
     private File userSettings;
 72  
 
 73  
     private String globalChecksumPolicy;
 74  
 
 75  
     private String pomFilename;
 76  
 
 77  
     private File javaHome;
 78  
 
 79  
     private List profiles;
 80  
 
 81  
     private boolean nonPluginUpdates;
 82  
 
 83  
     private Map shellEnvironments;
 84  
 
 85  
     private String mavenOpts;
 86  
     
 87  
     private boolean activatedReactor;
 88  
 
 89  
     private String[] activatedReactorIncludes, activatedReactorExcludes;
 90  
     
 91  
     private boolean showVersion;
 92  
 
 93  
     public InvocationRequest activateReactor( String[] includes, String[] excludes )
 94  
     {
 95  4
         activatedReactor = true;
 96  4
         activatedReactorIncludes = includes;
 97  4
         activatedReactorExcludes = excludes;
 98  4
         return this;
 99  
     }
 100  
 
 101  
     public File getBaseDirectory()
 102  
     {
 103  76
         return basedir;
 104  
     }
 105  
 
 106  
     public File getBaseDirectory( File defaultDirectory )
 107  
     {
 108  0
         return basedir == null ? defaultDirectory : basedir;
 109  
     }
 110  
 
 111  
     public InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler )
 112  
     {
 113  12
         return errorHandler == null ? defaultHandler : errorHandler;
 114  
     }
 115  
 
 116  
     public String getFailureBehavior()
 117  
     {
 118  28
         return failureBehavior;
 119  
     }
 120  
 
 121  
     public List getGoals()
 122  
     {
 123  22
         return goals;
 124  
     }
 125  
 
 126  
     public InputStream getInputStream( InputStream defaultStream )
 127  
     {
 128  12
         return inputStream == null ? defaultStream : inputStream;
 129  
     }
 130  
 
 131  
     public File getLocalRepositoryDirectory( File defaultDirectory )
 132  
     {
 133  46
         return localRepository == null ? defaultDirectory : localRepository;
 134  
     }
 135  
 
 136  
     public InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler )
 137  
     {
 138  12
         return outputHandler == null ? defaultHandler : outputHandler;
 139  
     }
 140  
 
 141  
     public File getPomFile()
 142  
     {
 143  48
         return pomFile;
 144  
     }
 145  
 
 146  
     public Properties getProperties()
 147  
     {
 148  24
         return properties;
 149  
     }
 150  
 
 151  
     public boolean isDebug()
 152  
     {
 153  34
         return debug;
 154  
     }
 155  
 
 156  
     public boolean isInteractive()
 157  
     {
 158  46
         return interactive;
 159  
     }
 160  
 
 161  
     public boolean isOffline()
 162  
     {
 163  34
         return offline;
 164  
     }
 165  
 
 166  
     public boolean isShowErrors()
 167  
     {
 168  18
         return showErrors;
 169  
     }
 170  
 
 171  
     public boolean isUpdateSnapshots()
 172  
     {
 173  34
         return updateSnapshots;
 174  
     }
 175  
 
 176  
     public boolean isRecursive()
 177  
     {
 178  34
         return recursive;
 179  
     }
 180  
 
 181  
     public InvocationRequest setRecursive( boolean recursive )
 182  
     {
 183  0
         this.recursive = recursive;
 184  0
         return this;
 185  
     }
 186  
 
 187  
     public InvocationRequest setBaseDirectory( File basedir )
 188  
     {
 189  28
         this.basedir = basedir;
 190  28
         return this;
 191  
     }
 192  
 
 193  
     public InvocationRequest setDebug( boolean debug )
 194  
     {
 195  16
         this.debug = debug;
 196  16
         return this;
 197  
     }
 198  
 
 199  
     public InvocationRequest setErrorHandler( InvocationOutputHandler errorHandler )
 200  
     {
 201  0
         this.errorHandler = errorHandler;
 202  0
         return this;
 203  
     }
 204  
 
 205  
     public InvocationRequest setFailureBehavior( String failureBehavior )
 206  
     {
 207  6
         this.failureBehavior = failureBehavior;
 208  6
         return this;
 209  
     }
 210  
 
 211  
     public InvocationRequest setGoals( List goals )
 212  
     {
 213  20
         this.goals = goals;
 214  20
         return this;
 215  
     }
 216  
 
 217  
     public InvocationRequest setInputStream( InputStream inputStream )
 218  
     {
 219  0
         this.inputStream = inputStream;
 220  0
         return this;
 221  
     }
 222  
 
 223  
     public InvocationRequest setInteractive( boolean interactive )
 224  
     {
 225  2
         this.interactive = interactive;
 226  2
         return this;
 227  
     }
 228  
 
 229  
     public InvocationRequest setLocalRepositoryDirectory( File localRepository )
 230  
     {
 231  8
         this.localRepository = localRepository;
 232  8
         return this;
 233  
     }
 234  
 
 235  
     public InvocationRequest setOffline( boolean offline )
 236  
     {
 237  4
         this.offline = offline;
 238  4
         return this;
 239  
     }
 240  
 
 241  
     public InvocationRequest setOutputHandler( InvocationOutputHandler outputHandler )
 242  
     {
 243  0
         this.outputHandler = outputHandler;
 244  0
         return this;
 245  
     }
 246  
 
 247  
     public InvocationRequest setPomFile( File pomFile )
 248  
     {
 249  4
         this.pomFile = pomFile;
 250  4
         return this;
 251  
     }
 252  
 
 253  
     public InvocationRequest setProperties( Properties properties )
 254  
     {
 255  10
         this.properties = properties;
 256  10
         return this;
 257  
     }
 258  
 
 259  
     public InvocationRequest setShowErrors( boolean showErrors )
 260  
     {
 261  4
         this.showErrors = showErrors;
 262  4
         return this;
 263  
     }
 264  
 
 265  
     public InvocationRequest setUpdateSnapshots( boolean updateSnapshots )
 266  
     {
 267  2
         this.updateSnapshots = updateSnapshots;
 268  2
         return this;
 269  
     }
 270  
 
 271  
     public boolean isShellEnvironmentInherited()
 272  
     {
 273  18
         return shellEnvironmentInherited;
 274  
     }
 275  
 
 276  
     public InvocationRequest setShellEnvironmentInherited( boolean shellEnvironmentInherited )
 277  
     {
 278  0
         this.shellEnvironmentInherited = shellEnvironmentInherited;
 279  0
         return this;
 280  
     }
 281  
 
 282  
     public File getJavaHome()
 283  
     {
 284  18
         return javaHome;
 285  
     }
 286  
 
 287  
     public InvocationRequest setJavaHome( File javaHome )
 288  
     {
 289  0
         this.javaHome = javaHome;
 290  0
         return this;
 291  
     }
 292  
 
 293  
     public File getUserSettingsFile()
 294  
     {
 295  20
         return userSettings;
 296  
     }
 297  
 
 298  
     public InvocationRequest setUserSettingsFile( File userSettings )
 299  
     {
 300  4
         this.userSettings = userSettings;
 301  4
         return this;
 302  
     }
 303  
 
 304  
     public String getGlobalChecksumPolicy()
 305  
     {
 306  34
         return globalChecksumPolicy;
 307  
     }
 308  
 
 309  
     public InvocationRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
 310  
     {
 311  4
         this.globalChecksumPolicy = globalChecksumPolicy;
 312  4
         return this;
 313  
     }
 314  
 
 315  
     public String getPomFileName()
 316  
     {
 317  30
         return pomFilename;
 318  
     }
 319  
 
 320  
     public InvocationRequest setPomFileName( String pomFilename )
 321  
     {
 322  4
         this.pomFilename = pomFilename;
 323  4
         return this;
 324  
     }
 325  
 
 326  
     public List getProfiles()
 327  
     {
 328  18
         return profiles;
 329  
     }
 330  
 
 331  
     public InvocationRequest setProfiles( List profiles )
 332  
     {
 333  2
         this.profiles = profiles;
 334  2
         return this;
 335  
     }
 336  
 
 337  
     public boolean isNonPluginUpdates()
 338  
     {
 339  34
         return nonPluginUpdates;
 340  
     }
 341  
 
 342  
     public InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates )
 343  
     {
 344  0
         this.nonPluginUpdates = nonPluginUpdates;
 345  0
         return this;
 346  
     }
 347  
 
 348  
     public InvocationRequest addShellEnvironment( String name, String value )
 349  
     {
 350  0
         if ( this.shellEnvironmentInherited )
 351  
         {
 352  0
             this.shellEnvironments = new HashMap();
 353  
         }
 354  0
         this.shellEnvironments.put( name, value );
 355  0
         return this;
 356  
     }
 357  
 
 358  
     public Map getShellEnvironments()
 359  
     {
 360  18
         return shellEnvironments == null ? Collections.EMPTY_MAP : shellEnvironments;
 361  
     }
 362  
 
 363  
     public String getMavenOpts()
 364  
     {
 365  18
         return mavenOpts;
 366  
     }
 367  
 
 368  
     public InvocationRequest setMavenOpts( String mavenOpts )
 369  
     {
 370  0
         this.mavenOpts = mavenOpts;
 371  0
         return this;
 372  
     }
 373  
     
 374  
     public boolean isActivatedReactor()
 375  
     {
 376  28
         return activatedReactor;
 377  
     }
 378  
 
 379  
     public String[] getActivatedReactorIncludes()
 380  
     {
 381  4
         return activatedReactorIncludes;
 382  
     }
 383  
 
 384  
     public String[] getActivatedReactorExcludes()
 385  
     {
 386  4
         return activatedReactorExcludes;
 387  
     }
 388  
 
 389  
     /**
 390  
      * @see org.apache.maven.shared.invoker.InvocationRequest#isShowVersion()
 391  
      */
 392  
     public boolean isShowVersion()
 393  
     {
 394  34
         return this.showVersion;
 395  
     }
 396  
 
 397  
     /**
 398  
      * @see org.apache.maven.shared.invoker.InvocationRequest#setShowVersion(boolean)
 399  
      */
 400  
     public InvocationRequest setShowVersion( boolean showVersion )
 401  
     {
 402  0
         this.showVersion = showVersion;
 403  0
         return this;
 404  
     }
 405  
 
 406  
 }