Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * You may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.codehaus.gmavenplus.mojo;
 
 
The base tools mojo, which all tool mojos extend. Note that it references the plugin classloader to pull in dependencies Groovy didn't include (for things like Ant for AntBuilder, Ivy for

Author(s):
Keegan Witt
Since:
1.1
Grab:
and Jansi for Groovysh).
 
 public abstract class AbstractToolsMojo extends AbstractGroovyMojo {

    
Maven ProjectHelper to use in properties.

Since:
1.3
Component:
Readonly:
 
     protected MavenProjectHelper projectHelper;

    
Properties to make available in scripts as variables using the property name. By default will include
project
A org.apache.maven.project.Project object of the current Maven project.
session
A org.apache.maven.execution.MavenSession object of the current Maven session.
pluginArtifacts
A list of org.apache.maven.artifact.Artifact objects of this plugin's artifacts.
mojoExecution
A org.apache.maven.plugin.MojoExecution object of this plugin's mojo execution.
log
A org.apache.maven.plugin.logging.Log object of Maven's log.
ant
A groovy.util.AntBuilder object.
These can be overridden.

Since:
1.0-beta-3
Parameter:
 
     protected Properties properties = new Properties();

    
Whether to allow System.exit() to be used.

Since:
1.2
Parameter:
default-value="false"
 
     protected boolean allowSystemExits;

    
Whether to bind each property to a separate variable (otherwise binds properties to a single 'properties' variable).

Since:
1.2
Parameter:
default-value="true"
 
     protected boolean bindPropertiesToSeparateVariables;

    
Initializes the properties field.
 
     protected void initializeProperties() {
         if ( != null && !.containsKey("project")) {
             .put("project");
         }
         if ( != null && !.containsKey("session")) {
             .put("session");
         }
         if ( != null && !.containsKey("pluginArtifacts")) {
             .put("pluginArtifacts");
        }
        if ( != null && !.containsKey("mojoExecution")) {
            .put("mojoExecution");
        }
        if (!.containsKey("log")) {
            .put("log"getLog());
        }
        if ( != null && !.containsKey("projectHelper")) {
            .put("projectHelper");
        }
        if (!.containsKey("ant")) {
            try {
                Object antBuilder = ReflectionUtils.invokeConstructor(ReflectionUtils.findConstructor(.getClass("groovy.util.AntBuilder")));
                .put("ant"antBuilder);
            } catch (InvocationTargetException e) {
                logUnableToInitializeAntBuilder(e);
            } catch (IllegalAccessException e) {
                logUnableToInitializeAntBuilder(e);
            } catch (InstantiationException e) {
                logUnableToInitializeAntBuilder(e);
            } catch (ClassNotFoundException e) {
                logUnableToInitializeAntBuilder(e);
            }
        }
    }

    
Logs errors that caused the 'ant' object to not be populated.

Parameters:
e the exception causing the failure
    protected void logUnableToInitializeAntBuilder(final Throwable e) {
        getLog().error("Unable to initialize 'ant' with a new AntBuilder object.  Is Groovy a dependency?  If you are using Groovy >= 2.3.0-rc-1, remember to include groovy-ant as a dependency."e);
    }
New to GrepCode? Check out our FAQ X