Package org.apache.maven.plugins.antrun
Class AntRunMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.antrun.AntRunMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="run", threadSafe=true, requiresDependencyResolution=TEST) public class AntRunMojo extends org.apache.maven.plugin.AbstractMojoMaven AntRun Mojo.
This plugin provides the capability of calling Ant tasks from a POM by running the nested Ant tasks inside the <target/> parameter. It is encouraged to move the actual tasks to a separate build.xml file and call that file with an <ant/> task.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringANTLIBThe path to The XML file containing the definition of the Maven tasks.private java.lang.StringcustomTaskPrefixDeprecated.only here for backwards compatibilitystatic java.lang.StringDEFAULT_ANT_TARGET_NAMEThe default target name.static java.lang.StringDEFAULT_MAVEN_PROJECT_HELPER_REFIDThe refid used to store the Maven project object in the Ant build.static java.lang.StringDEFAULT_MAVEN_PROJECT_REF_REFIDThe refid used to store an object of typeMavenAntRunProjectcontaining the Maven project object in the Ant build.static java.lang.StringDEFAULT_MAVEN_PROJECT_REFIDThe refid used to store the Maven project object in the Ant build.private booleanexportAntPropertiesSpecifies whether the Ant properties should propagate to the Maven properties.private booleanfailOnErrorSpecifies whether a failure in the Ant build leads to a failure of the Maven build.protected org.apache.maven.artifact.repository.ArtifactRepositorylocalRepositoryThe local Maven repositorystatic java.lang.StringMAVEN_REFID_PREFIXThe prefix of all refid used by the plugin.private org.apache.maven.project.MavenProjectmavenProjectThe Maven project objectprivate java.util.List<org.apache.maven.artifact.Artifact>pluginArtifactsThe plugin dependencies.private org.apache.maven.project.MavenProjectHelperprojectHelperThe Maven project helper objectprivate java.lang.StringpropertyPrefixString to prepend to project and dependency property names.private org.apache.maven.execution.MavenSessionsessionThe Maven session objectprivate booleanskipSpecifies whether the Antrun execution should be skipped.private java.io.FilesourceRootDeprecated.Use thebuild-helper-maven-pluginto bind source directories.private org.codehaus.plexus.configuration.PlexusConfigurationtargetThe XML for the Ant target.static java.lang.StringTASK_URIThe URI which defines the built in Ant tasksprivate org.codehaus.plexus.configuration.PlexusConfigurationtasksDeprecated.Usetargetinstead.private java.io.FiletestSourceRootDeprecated.Use thebuild-helper-maven-pluginto bind test source directories.static java.lang.StringUTF_8The default encoding to use for the generated Ant build.private java.lang.StringversionsPropertyNameThe name of a property containing the list of all dependency versions.
-
Constructor Summary
Constructors Constructor Description AntRunMojo(org.apache.maven.project.MavenProjectHelper projectHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddAntProjectReferences(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject)private voidcheckDeprecatedParameterUsage(java.lang.Object parameter, java.lang.String name, java.lang.String replacement)voidcopyProperties(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject)Copy properties from the Maven project to the Ant project.voidcopyProperties(org.apache.tools.ant.Project antProject, org.apache.maven.project.MavenProject mavenProject)Copy properties from the Ant project to the Maven project.voidexecute()private java.lang.StringfindFragment(org.apache.tools.ant.BuildException buildException)private org.apache.tools.ant.DefaultLoggergetConfiguredBuildLogger()private org.apache.tools.ant.types.PathgetPathFromArtifacts(java.util.Collection<org.apache.maven.artifact.Artifact> artifacts, org.apache.tools.ant.Project antProject)private java.lang.StringgetTaskPrefix()voidinitMavenTasks(org.apache.tools.ant.Project antProject)private java.io.FilewriteTargetToProjectFile(java.lang.String targetName)Write the Ant target and surrounding tags to a temporary file
-
-
-
Field Detail
-
MAVEN_REFID_PREFIX
public static final java.lang.String MAVEN_REFID_PREFIX
The prefix of all refid used by the plugin.- See Also:
- Constant Field Values
-
DEFAULT_MAVEN_PROJECT_REFID
public static final java.lang.String DEFAULT_MAVEN_PROJECT_REFID
The refid used to store the Maven project object in the Ant build. If this reference is retrieved in a custom task, note that this will be a clone of the Maven project, and not the project itself, when the task is called through ananttask.- See Also:
- Constant Field Values
-
DEFAULT_MAVEN_PROJECT_REF_REFID
public static final java.lang.String DEFAULT_MAVEN_PROJECT_REF_REFID
The refid used to store an object of typeMavenAntRunProjectcontaining the Maven project object in the Ant build. This is useful when a custom task needs to change the Maven project, because, unlikeDEFAULT_MAVEN_PROJECT_REFID, this makes sure to reference the same instance of the Maven project in all cases.- See Also:
- Constant Field Values
-
DEFAULT_MAVEN_PROJECT_HELPER_REFID
public static final java.lang.String DEFAULT_MAVEN_PROJECT_HELPER_REFID
The refid used to store the Maven project object in the Ant build.- See Also:
- Constant Field Values
-
DEFAULT_ANT_TARGET_NAME
public static final java.lang.String DEFAULT_ANT_TARGET_NAME
The default target name.- See Also:
- Constant Field Values
-
UTF_8
public static final java.lang.String UTF_8
The default encoding to use for the generated Ant build.- See Also:
- Constant Field Values
-
ANTLIB
public static final java.lang.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 java.lang.String TASK_URI
The URI which defines the built in Ant tasks- See Also:
- Constant Field Values
-
mavenProject
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject mavenProjectThe Maven project object
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession sessionThe Maven session object
-
pluginArtifacts
@Parameter(property="plugin.artifacts", required=true, readonly=true) private java.util.List<org.apache.maven.artifact.Artifact> pluginArtifactsThe plugin dependencies.
-
localRepository
@Parameter(property="localRepository", readonly=true) protected org.apache.maven.artifact.repository.ArtifactRepository localRepositoryThe local Maven repository
-
propertyPrefix
@Parameter(defaultValue="") private java.lang.String propertyPrefix
String to prepend to project and dependency property names.- Since:
- 1.4
-
customTaskPrefix
@Deprecated @Parameter private java.lang.String customTaskPrefix
Deprecated.only here for backwards compatibilityMaven will look in the target-tag for the namespace ofhttp://maven.apache.org/ANTRUNorantlib:org.apache.maven.ant.tasks<configuration> <target xmlns:mvn="http://maven.apache.org/ANTRUN"> <mvn:attachartifact/> <mvn:dependencyfilesets/> </target> </configuration>- Since:
- 1.5
-
versionsPropertyName
@Parameter(defaultValue="maven.project.dependencies.versions") private java.lang.String versionsPropertyName
The name of a property containing the list of all dependency versions. This is used for the removing the versions from the filenames.
-
tasks
@Deprecated @Parameter private org.codehaus.plexus.configuration.PlexusConfiguration tasks
Deprecated.Usetargetinstead. For version 3.0.0, this parameter is only defined to break the build if you use it!The XML for the Ant task. You can add anything you can add between <target> and </target> in a build.xml.
-
target
@Parameter private org.codehaus.plexus.configuration.PlexusConfiguration target
The XML for the Ant target. You can add anything you can add between <target> and </target> in a build.xml.- Since:
- 1.5
-
sourceRoot
@Deprecated @Parameter(property="sourceRoot") private java.io.File sourceRoot
Deprecated.Use thebuild-helper-maven-pluginto bind source directories. In version 3.0.0, this parameter is only defined to break the build if you use it!This folder is added to the list of those folders containing source to be compiled. Use this if your Ant script generates source code.
-
testSourceRoot
@Deprecated @Parameter(property="testSourceRoot") private java.io.File testSourceRoot
Deprecated.Use thebuild-helper-maven-pluginto bind test source directories. For version 3.0.0, this parameter is only defined to break the build if you use it!This folder is added to the list of those folders containing source to be compiled for testing. Use this if your Ant script generates test source code.
-
skip
@Parameter(property="maven.antrun.skip", defaultValue="false") private boolean skipSpecifies whether the Antrun execution should be skipped.- Since:
- 1.7
-
exportAntProperties
@Parameter(defaultValue="false") private boolean exportAntProperties
Specifies whether the Ant properties should propagate to the Maven properties. This only works when the ant task is inline in pom.xml, not when it's loaded from an external ant build.xml file.- Since:
- 1.7
-
failOnError
@Parameter(defaultValue="true") private boolean failOnError
Specifies whether a failure in the Ant build leads to a failure of the Maven build. If this value isfalse, the Maven build will proceed even if the Ant build fails. If it istrue, then the Maven build fails if the Ant build fails.- Since:
- 1.7
-
projectHelper
private org.apache.maven.project.MavenProjectHelper projectHelper
The Maven project helper object
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
checkDeprecatedParameterUsage
private void checkDeprecatedParameterUsage(java.lang.Object parameter, java.lang.String name, java.lang.String replacement) throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
getConfiguredBuildLogger
private org.apache.tools.ant.DefaultLogger getConfiguredBuildLogger()
-
addAntProjectReferences
private void addAntProjectReferences(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject) throws org.apache.maven.artifact.DependencyResolutionRequiredException- Throws:
org.apache.maven.artifact.DependencyResolutionRequiredException
-
getPathFromArtifacts
private org.apache.tools.ant.types.Path getPathFromArtifacts(java.util.Collection<org.apache.maven.artifact.Artifact> artifacts, org.apache.tools.ant.Project antProject) throws org.apache.maven.artifact.DependencyResolutionRequiredException- Parameters:
artifacts-Artifactcollection.antProject-Project- Returns:
Path- Throws:
org.apache.maven.artifact.DependencyResolutionRequiredException- In case of a failure.
-
copyProperties
public void copyProperties(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject)Copy properties from the Maven project to the Ant project.- Parameters:
mavenProject-MavenProjectantProject-Project
-
copyProperties
public void copyProperties(org.apache.tools.ant.Project antProject, org.apache.maven.project.MavenProject mavenProject)Copy properties from the Ant project to the Maven project.- Parameters:
antProject- not nullmavenProject- not null- Since:
- 1.7
-
initMavenTasks
public void initMavenTasks(org.apache.tools.ant.Project antProject)
- Parameters:
antProject-Project
-
writeTargetToProjectFile
private java.io.File writeTargetToProjectFile(java.lang.String targetName) throws java.io.IOExceptionWrite the Ant target and surrounding tags to a temporary file- Throws:
java.io.IOException- problem with write to file
-
getTaskPrefix
private java.lang.String getTaskPrefix()
-
findFragment
private java.lang.String findFragment(org.apache.tools.ant.BuildException buildException)
- Parameters:
buildException- not null- Returns:
- the fragment XML part where the buildException occurs.
- Since:
- 1.7
-
-