Coverage Report - org.apache.maven.shared.invoker.DefaultInvocationRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultInvocationRequest
79%
87/110
42%
6/14
1,101
 
 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 1392618 2012-10-01 21:20:53Z rfscholte $
 34  
  */
 35  51
 public class DefaultInvocationRequest
 36  
     implements InvocationRequest
 37  
 {
 38  
 
 39  
     private File basedir;
 40  
 
 41  
     private boolean debug;
 42  
 
 43  
     private InvocationOutputHandler errorHandler;
 44  
 
 45  51
     private String failureBehavior = REACTOR_FAIL_FAST;
 46  
 
 47  
     private List<String> goals;
 48  
 
 49  
     private InputStream inputStream;
 50  
 
 51  
     private boolean interactive;
 52  
 
 53  
     private File localRepository;
 54  
 
 55  
     private boolean offline;
 56  
 
 57  51
     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  51
     private boolean shellEnvironmentInherited = true;
 70  
 
 71  
     private File userSettings;
 72  
 
 73  
     private File globalSettings;
 74  
     
 75  
     private File toolchains;
 76  
 
 77  
     private String globalChecksumPolicy;
 78  
 
 79  
     private String pomFilename;
 80  
 
 81  
     private File javaHome;
 82  
 
 83  
     private List<String> profiles;
 84  
 
 85  
     private boolean nonPluginUpdates;
 86  
 
 87  
     private Map<String, String> shellEnvironments;
 88  
 
 89  
     private String mavenOpts;
 90  
     
 91  
     private boolean activatedReactor;
 92  
 
 93  
     private String[] activatedReactorIncludes, activatedReactorExcludes;
 94  
     
 95  
     private List<String> projects;
 96  
 
 97  
     private boolean alsoMake;
 98  
 
 99  
     private boolean alsoMakeDependents;
 100  
 
 101  
     private String resumeFrom;
 102  
 
 103  
     private boolean showVersion;
 104  
 
 105  
     private String threads;
 106  
 
 107  
     public InvocationRequest activateReactor( String[] includes, String[] excludes )
 108  
     {
 109  2
         activatedReactor = true;
 110  2
         activatedReactorIncludes = includes;
 111  2
         activatedReactorExcludes = excludes;
 112  2
         return this;
 113  
     }
 114  
 
 115  
     public File getBaseDirectory()
 116  
     {
 117  38
         return basedir;
 118  
     }
 119  
 
 120  
     public File getBaseDirectory( File defaultDirectory )
 121  
     {
 122  0
         return basedir == null ? defaultDirectory : basedir;
 123  
     }
 124  
 
 125  
     public InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler )
 126  
     {
 127  6
         return errorHandler == null ? defaultHandler : errorHandler;
 128  
     }
 129  
 
 130  
     public String getFailureBehavior()
 131  
     {
 132  20
         return failureBehavior;
 133  
     }
 134  
 
 135  
     public List<String> getGoals()
 136  
     {
 137  11
         return goals;
 138  
     }
 139  
 
 140  
     public InputStream getInputStream( InputStream defaultStream )
 141  
     {
 142  6
         return inputStream == null ? defaultStream : inputStream;
 143  
     }
 144  
 
 145  
     public File getLocalRepositoryDirectory( File defaultDirectory )
 146  
     {
 147  23
         return localRepository == null ? defaultDirectory : localRepository;
 148  
     }
 149  
 
 150  
     public InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler )
 151  
     {
 152  6
         return outputHandler == null ? defaultHandler : outputHandler;
 153  
     }
 154  
 
 155  
     public File getPomFile()
 156  
     {
 157  24
         return pomFile;
 158  
     }
 159  
 
 160  
     public Properties getProperties()
 161  
     {
 162  12
         return properties;
 163  
     }
 164  
 
 165  
     public boolean isDebug()
 166  
     {
 167  17
         return debug;
 168  
     }
 169  
 
 170  
     public boolean isInteractive()
 171  
     {
 172  23
         return interactive;
 173  
     }
 174  
 
 175  
     public boolean isOffline()
 176  
     {
 177  17
         return offline;
 178  
     }
 179  
 
 180  
     public boolean isShowErrors()
 181  
     {
 182  9
         return showErrors;
 183  
     }
 184  
 
 185  
     public boolean isUpdateSnapshots()
 186  
     {
 187  17
         return updateSnapshots;
 188  
     }
 189  
 
 190  
     public boolean isRecursive()
 191  
     {
 192  17
         return recursive;
 193  
     }
 194  
 
 195  
     public InvocationRequest setRecursive( boolean recursive )
 196  
     {
 197  0
         this.recursive = recursive;
 198  0
         return this;
 199  
     }
 200  
 
 201  
     public InvocationRequest setBaseDirectory( File basedir )
 202  
     {
 203  14
         this.basedir = basedir;
 204  14
         return this;
 205  
     }
 206  
 
 207  
     public InvocationRequest setDebug( boolean debug )
 208  
     {
 209  8
         this.debug = debug;
 210  8
         return this;
 211  
     }
 212  
 
 213  
     public InvocationRequest setErrorHandler( InvocationOutputHandler errorHandler )
 214  
     {
 215  0
         this.errorHandler = errorHandler;
 216  0
         return this;
 217  
     }
 218  
 
 219  
     public InvocationRequest setFailureBehavior( String failureBehavior )
 220  
     {
 221  3
         this.failureBehavior = failureBehavior;
 222  3
         return this;
 223  
     }
 224  
 
 225  
     public InvocationRequest setGoals( List<String> goals )
 226  
     {
 227  10
         this.goals = goals;
 228  10
         return this;
 229  
     }
 230  
 
 231  
     public InvocationRequest setInputStream( InputStream inputStream )
 232  
     {
 233  0
         this.inputStream = inputStream;
 234  0
         return this;
 235  
     }
 236  
 
 237  
     public InvocationRequest setInteractive( boolean interactive )
 238  
     {
 239  1
         this.interactive = interactive;
 240  1
         return this;
 241  
     }
 242  
 
 243  
     public InvocationRequest setLocalRepositoryDirectory( File localRepository )
 244  
     {
 245  4
         this.localRepository = localRepository;
 246  4
         return this;
 247  
     }
 248  
 
 249  
     public InvocationRequest setOffline( boolean offline )
 250  
     {
 251  2
         this.offline = offline;
 252  2
         return this;
 253  
     }
 254  
 
 255  
     public InvocationRequest setOutputHandler( InvocationOutputHandler outputHandler )
 256  
     {
 257  0
         this.outputHandler = outputHandler;
 258  0
         return this;
 259  
     }
 260  
 
 261  
     public InvocationRequest setPomFile( File pomFile )
 262  
     {
 263  2
         this.pomFile = pomFile;
 264  2
         return this;
 265  
     }
 266  
 
 267  
     public InvocationRequest setProperties( Properties properties )
 268  
     {
 269  5
         this.properties = properties;
 270  5
         return this;
 271  
     }
 272  
 
 273  
     public InvocationRequest setShowErrors( boolean showErrors )
 274  
     {
 275  2
         this.showErrors = showErrors;
 276  2
         return this;
 277  
     }
 278  
 
 279  
     public InvocationRequest setUpdateSnapshots( boolean updateSnapshots )
 280  
     {
 281  1
         this.updateSnapshots = updateSnapshots;
 282  1
         return this;
 283  
     }
 284  
 
 285  
     public boolean isShellEnvironmentInherited()
 286  
     {
 287  9
         return shellEnvironmentInherited;
 288  
     }
 289  
 
 290  
     public InvocationRequest setShellEnvironmentInherited( boolean shellEnvironmentInherited )
 291  
     {
 292  0
         this.shellEnvironmentInherited = shellEnvironmentInherited;
 293  0
         return this;
 294  
     }
 295  
 
 296  
     public File getJavaHome()
 297  
     {
 298  9
         return javaHome;
 299  
     }
 300  
 
 301  
     public InvocationRequest setJavaHome( File javaHome )
 302  
     {
 303  0
         this.javaHome = javaHome;
 304  0
         return this;
 305  
     }
 306  
 
 307  
     public File getUserSettingsFile()
 308  
     {
 309  11
         return userSettings;
 310  
     }
 311  
     
 312  
     public InvocationRequest setUserSettingsFile( File userSettings )
 313  
     {
 314  2
         this.userSettings = userSettings;
 315  2
         return this;
 316  
     }
 317  
 
 318  
     public File getGlobalSettingsFile()
 319  
     {
 320  11
         return globalSettings;
 321  
     }
 322  
 
 323  
     public InvocationRequest setGlobalSettingsFile( File globalSettings )
 324  
     {
 325  1
         this.globalSettings = globalSettings;
 326  1
         return this;
 327  
     }
 328  
 
 329  
     public File getToolchainsFile()
 330  
     {
 331  10
         return toolchains;
 332  
     }
 333  
     
 334  
     public InvocationRequest setToolchainsFile( File toolchains )
 335  
     {
 336  1
         this.toolchains = toolchains;
 337  1
         return this;
 338  
     }
 339  
     
 340  
     public String getGlobalChecksumPolicy()
 341  
     {
 342  17
         return globalChecksumPolicy;
 343  
     }
 344  
 
 345  
     public InvocationRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
 346  
     {
 347  2
         this.globalChecksumPolicy = globalChecksumPolicy;
 348  2
         return this;
 349  
     }
 350  
 
 351  
     public String getPomFileName()
 352  
     {
 353  15
         return pomFilename;
 354  
     }
 355  
 
 356  
     public InvocationRequest setPomFileName( String pomFilename )
 357  
     {
 358  2
         this.pomFilename = pomFilename;
 359  2
         return this;
 360  
     }
 361  
 
 362  
     public List<String> getProfiles()
 363  
     {
 364  9
         return profiles;
 365  
     }
 366  
 
 367  
     public InvocationRequest setProfiles( List<String> profiles )
 368  
     {
 369  1
         this.profiles = profiles;
 370  1
         return this;
 371  
     }
 372  
 
 373  
     public boolean isNonPluginUpdates()
 374  
     {
 375  17
         return nonPluginUpdates;
 376  
     }
 377  
 
 378  
     public InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates )
 379  
     {
 380  0
         this.nonPluginUpdates = nonPluginUpdates;
 381  0
         return this;
 382  
     }
 383  
 
 384  
     public InvocationRequest addShellEnvironment( String name, String value )
 385  
     {
 386  0
         if ( this.shellEnvironmentInherited )
 387  
         {
 388  0
             this.shellEnvironments = new HashMap<String, String>();
 389  
         }
 390  0
         this.shellEnvironments.put( name, value );
 391  0
         return this;
 392  
     }
 393  
 
 394  
     public Map<String, String> getShellEnvironments()
 395  
     {
 396  9
         return shellEnvironments == null ? Collections.<String, String>emptyMap(): shellEnvironments;
 397  
     }
 398  
 
 399  
     public String getMavenOpts()
 400  
     {
 401  9
         return mavenOpts;
 402  
     }
 403  
 
 404  
     public InvocationRequest setMavenOpts( String mavenOpts )
 405  
     {
 406  0
         this.mavenOpts = mavenOpts;
 407  0
         return this;
 408  
     }
 409  
     
 410  
     public boolean isActivatedReactor()
 411  
     {
 412  20
         return activatedReactor;
 413  
     }
 414  
 
 415  
     public String[] getActivatedReactorIncludes()
 416  
     {
 417  2
         return activatedReactorIncludes;
 418  
     }
 419  
 
 420  
     public String[] getActivatedReactorExcludes()
 421  
     {
 422  2
         return activatedReactorExcludes;
 423  
     }
 424  
 
 425  
     /**
 426  
      * @see org.apache.maven.shared.invoker.InvocationRequest#isShowVersion()
 427  
      */
 428  
     public boolean isShowVersion()
 429  
     {
 430  17
         return this.showVersion;
 431  
     }
 432  
 
 433  
     /**
 434  
      * @see org.apache.maven.shared.invoker.InvocationRequest#setShowVersion(boolean)
 435  
      */
 436  
     public InvocationRequest setShowVersion( boolean showVersion )
 437  
     {
 438  0
         this.showVersion = showVersion;
 439  0
         return this;
 440  
     }
 441  
     
 442  
     /**
 443  
      * {@inheritDoc}
 444  
      */
 445  
     public String getThreads()
 446  
     {
 447  10
         return threads;
 448  
     }
 449  
     
 450  
     /**
 451  
      * {@inheritDoc}
 452  
      */
 453  
     public InvocationRequest setThreads( String threads )
 454  
     {
 455  1
         this.threads = threads;
 456  1
         return this;
 457  
     }
 458  
 
 459  
     /**
 460  
      * {@inheritDoc}
 461  
      */
 462  
     public List<String> getProjects()
 463  
     {
 464  20
         return projects;
 465  
     }
 466  
 
 467  
     /**
 468  
      * {@inheritDoc}
 469  
      */
 470  
     public InvocationRequest setProjects( List<String> projects )
 471  
     {
 472  3
         this.projects = projects;
 473  3
         return this;
 474  
     }
 475  
 
 476  
     /**
 477  
      * {@inheritDoc}
 478  
      */
 479  
     public boolean isAlsoMake()
 480  
     {
 481  3
         return alsoMake;
 482  
     }
 483  
 
 484  
     /**
 485  
      * {@inheritDoc}
 486  
      */
 487  
     public InvocationRequest setAlsoMake( boolean alsoMake )
 488  
     {
 489  3
         this.alsoMake = alsoMake;
 490  3
         return this;
 491  
     }
 492  
 
 493  
     /**
 494  
      * {@inheritDoc}
 495  
      */
 496  
     public boolean isAlsoMakeDependents()
 497  
     {
 498  3
         return alsoMakeDependents;
 499  
     }
 500  
 
 501  
     /**
 502  
      * {@inheritDoc}
 503  
      */
 504  
     public InvocationRequest setAlsoMakeDependents( boolean alsoMakeDependents )
 505  
     {
 506  3
         this.alsoMakeDependents = alsoMakeDependents;
 507  3
         return this;
 508  
     }
 509  
 
 510  
     /**
 511  
      * {@inheritDoc}
 512  
      */
 513  
     public String getResumeFrom()
 514  
     {
 515  21
         return resumeFrom;
 516  
     }
 517  
 
 518  
     /**
 519  
      * {@inheritDoc}
 520  
      */
 521  
     public InvocationRequest setResumeFrom( String resumeFrom )
 522  
     {
 523  1
         this.resumeFrom = resumeFrom;
 524  1
         return this;
 525  
     }
 526  
     
 527  
 }