org.kuali.maven.mojo
Class AntMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.kuali.maven.mojo.AntMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

public class AntMojo
extends org.apache.maven.plugin.AbstractMojo

Maven Ant Mojo. Allows Maven to invoke a target inside an Ant build file. The build file can be located on the file system, the ant-maven-plugin classpath, or any resource URL that Spring 3.0 can understand.

By default, this mojo makes the following available to Ant build files as both properties and references:

maven.compile.classpath=The classpath Maven is using for compilation
maven.runtime.classpath=The classpath Maven is using at runtime
maven.test.classpath=The classpath Maven is using for testing
maven.plugin.classpath=The classpath for the ant-maven-plugin

These are available as Ant references:

maven.project=MavenProject
maven.project.helper=MavenProjectHelper
maven.local.repository=ArtifactRepository


Field Summary
static String ANTLIB
          The path to The XML file containing the definition of the Maven tasks.
static String DEFAULT_ANT_TARGET_NAME
          The default target name.
static String DEFAULT_MAVEN_LOCAL_REPOSITORY_REFID
          The refid used to store the Maven local repository object in the Ant build.
static String DEFAULT_MAVEN_PROJECT_HELPER_REFID
          The refid used to store the Maven project helper object in the Ant build.
static String DEFAULT_MAVEN_PROJECT_REFID
          The refid used to store the Maven project object in the Ant build.
protected  org.apache.maven.artifact.repository.ArtifactRepository localRepository
          The local Maven repository
static String TASK_URI
          The URI which defines the built in Ant tasks
static String UTF_8
          The default encoding to use for the generated Ant build.
static String XML_HEADER
           
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AntMojo()
           
 
Method Summary
protected  String attr(String name, String value)
          Return XML for an attribute
protected  File createBuildWrapper(File localBuildFile)
          Write the ant target and surrounding tags to a temporary file
 void execute()
           
protected  String findFragment(org.apache.tools.ant.BuildException buildException)
           
 String getAntFilename()
           
 org.apache.tools.ant.Project getAntProject(File localBuildFile)
          Create a wrapper build file that calls into the build file they supplied us with.
protected  AntTaskPojo getAntTaskPojo()
          Aggregate some of the Maven configuration into a pojo
 String getCustomTaskPrefix()
           
protected  String getDefaultXML(AntTaskPojo atp)
          Default XML that wraps the build file they supplied us with
 String getFile()
           
 String getInheritAll()
           
 String getInheritRefs()
           
 org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()
           
 org.apache.maven.project.MavenProject getMavenProject()
          Get the current Maven project
protected  Map<String,?> getMavenRefs(org.apache.maven.project.MavenProject mavenProject)
          Collect Maven model objects, the currently executing project, the project helper, and the local repository
 String getOutput()
           
 List<org.apache.maven.artifact.Artifact> getPluginArtifacts()
           
 org.apache.maven.project.MavenProject getProject()
           
 org.apache.maven.project.MavenProjectHelper getProjectHelper()
           
protected  String getProjectOpen()
          XML for the Ant project tag
 String getPropertyPrefix()
           
protected  String getRelativeFilename(File basedir, File file)
           
 String getRelativeLocalFilename()
           
 String getTarget()
           
 File getWorkingDir()
           
protected  String getXML(AntTaskPojo atp)
          Convert an AntTaskPojo into XML http://ant.apache.org/manual/Tasks/ant.html
protected  File handleAntfile()
          Copy the build file to a local temp directory and preserve some information about the filename
protected  void handleBuildException(org.apache.tools.ant.BuildException e)
          There was an Ant build exception
 void initMavenTasks(org.apache.tools.ant.Project antProject)
           
 boolean isExportAntProperties()
           
 boolean isFailOnError()
           
protected  boolean isSkip()
          Determine if mojo execution should be skipped
 void setCustomTaskPrefix(String customTaskPrefix)
           
 void setExportAntProperties(boolean exportAntProperties)
           
 void setFailOnError(boolean failOnError)
           
 void setFile(String file)
           
 void setInheritAll(String inheritAll)
           
 void setInheritRefs(String inheritRefs)
           
 void setOutput(String output)
           
 void setPropertyPrefix(String propertyPrefix)
           
 void setSkip(boolean skip)
           
 void setTarget(String target)
           
 void setWorkingDir(File workingDir)
           
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAVEN_PROJECT_REFID

public static final String DEFAULT_MAVEN_PROJECT_REFID
The refid used to store the Maven project object in the Ant build.

See Also:
Constant Field Values

DEFAULT_MAVEN_PROJECT_HELPER_REFID

public static final String DEFAULT_MAVEN_PROJECT_HELPER_REFID
The refid used to store the Maven project helper object in the Ant build.

See Also:
Constant Field Values

DEFAULT_MAVEN_LOCAL_REPOSITORY_REFID

public static final String DEFAULT_MAVEN_LOCAL_REPOSITORY_REFID
The refid used to store the Maven local repository object in the Ant build.

See Also:
Constant Field Values

DEFAULT_ANT_TARGET_NAME

public static final String DEFAULT_ANT_TARGET_NAME
The default target name.

See Also:
Constant Field Values

UTF_8

public static final String UTF_8
The default encoding to use for the generated Ant build.

See Also:
Constant Field Values

XML_HEADER

public static final String XML_HEADER
See Also:
Constant Field Values

ANTLIB

public static final String ANTLIB
The path to The XML file containing the definition of the Maven tasks.

See Also:
Constant Field Values

TASK_URI

public static final String TASK_URI
The URI which defines the built in Ant tasks

See Also:
Constant Field Values

localRepository

protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
The local Maven repository

Constructor Detail

AntMojo

public AntMojo()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

isSkip

protected boolean isSkip()
Determine if mojo execution should be skipped


getAntProject

public org.apache.tools.ant.Project getAntProject(File localBuildFile)
                                           throws IOException
Create a wrapper build file that calls into the build file they supplied us with. Initialize an Ant project from the wrapper file.

Throws:
IOException

getMavenRefs

protected Map<String,?> getMavenRefs(org.apache.maven.project.MavenProject mavenProject)
Collect Maven model objects, the currently executing project, the project helper, and the local repository


handleBuildException

protected void handleBuildException(org.apache.tools.ant.BuildException e)
                             throws org.apache.maven.plugin.MojoExecutionException
There was an Ant build exception

Throws:
org.apache.maven.plugin.MojoExecutionException

getMavenProject

public org.apache.maven.project.MavenProject getMavenProject()
Get the current Maven project

Returns:
current Maven project

initMavenTasks

public void initMavenTasks(org.apache.tools.ant.Project antProject)

getDefaultXML

protected String getDefaultXML(AntTaskPojo atp)
                        throws IOException
Default XML that wraps the build file they supplied us with

Throws:
IOException

createBuildWrapper

protected File createBuildWrapper(File localBuildFile)
                           throws IOException
Write the ant target and surrounding tags to a temporary file

Throws:
IOException

handleAntfile

protected File handleAntfile()
                      throws IOException
Copy the build file to a local temp directory and preserve some information about the filename

Throws:
IOException

getRelativeFilename

protected String getRelativeFilename(File basedir,
                                     File file)

getAntTaskPojo

protected AntTaskPojo getAntTaskPojo()
Aggregate some of the Maven configuration into a pojo


getProjectOpen

protected String getProjectOpen()
XML for the Ant project tag


findFragment

protected String findFragment(org.apache.tools.ant.BuildException buildException)
Parameters:
buildException - not null
Returns:
the fragment XML part where the buildException occurs.

getXML

protected String getXML(AntTaskPojo atp)
Convert an AntTaskPojo into XML http://ant.apache.org/manual/Tasks/ant.html


attr

protected String attr(String name,
                      String value)
Return XML for an attribute


getPropertyPrefix

public String getPropertyPrefix()

setPropertyPrefix

public void setPropertyPrefix(String propertyPrefix)

getCustomTaskPrefix

public String getCustomTaskPrefix()

setCustomTaskPrefix

public void setCustomTaskPrefix(String customTaskPrefix)

isExportAntProperties

public boolean isExportAntProperties()

setExportAntProperties

public void setExportAntProperties(boolean exportAntProperties)

isFailOnError

public boolean isFailOnError()

setFailOnError

public void setFailOnError(boolean failOnError)

getFile

public String getFile()

setFile

public void setFile(String file)

getTarget

public String getTarget()

setTarget

public void setTarget(String target)

getOutput

public String getOutput()

setOutput

public void setOutput(String output)

getInheritAll

public String getInheritAll()

setInheritAll

public void setInheritAll(String inheritAll)

getInheritRefs

public String getInheritRefs()

setInheritRefs

public void setInheritRefs(String inheritRefs)

getProject

public org.apache.maven.project.MavenProject getProject()

getProjectHelper

public org.apache.maven.project.MavenProjectHelper getProjectHelper()

getPluginArtifacts

public List<org.apache.maven.artifact.Artifact> getPluginArtifacts()

getLocalRepository

public org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()

getAntFilename

public String getAntFilename()

getRelativeLocalFilename

public String getRelativeLocalFilename()

setSkip

public void setSkip(boolean skip)

getWorkingDir

public File getWorkingDir()

setWorkingDir

public void setWorkingDir(File workingDir)


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.