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.AbstractMojo
Maven 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
FieldsModifier and TypeFieldDescriptionstatic final String
The path to The XML file containing the definition of the Maven tasks.private String
Deprecated.only here for backwards compatibilitystatic final String
The default target name.static final String
The refid used to store the Maven project object in the Ant build.static final String
The refid used to store an object of typeMavenAntRunProject
containing the Maven project object in the Ant build.static final String
The refid used to store the Maven project object in the Ant build.private boolean
Specifies whether the Ant properties should be propagated to the Maven properties.private boolean
Specifies whether a failure in the Ant build leads to a failure of the Maven build.protected org.apache.maven.artifact.repository.ArtifactRepository
The local Maven repositorystatic final String
The prefix of all refid used by the plugin.private org.apache.maven.project.MavenProject
The Maven project objectprivate List<org.apache.maven.artifact.Artifact>
The plugin dependencies.private org.apache.maven.project.MavenProjectHelper
The Maven project helper objectprivate String
String to prepend to project and dependency property names.private org.apache.maven.execution.MavenSession
The Maven session objectprivate boolean
Specifies whether the Antrun execution should be skipped.private File
Deprecated.Use thebuild-helper-maven-plugin
to bind source directories.private org.codehaus.plexus.configuration.PlexusConfiguration
The XML for the Ant target.static final String
The URI which defines the built in Ant tasksprivate org.codehaus.plexus.configuration.PlexusConfiguration
Deprecated.Usetarget
instead.private File
Deprecated.Use thebuild-helper-maven-plugin
to bind test source directories.static final String
The default encoding to use for the generated Ant build.private String
The name of a property containing the list of all dependency versions.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addAntProjectReferences
(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject) private void
checkDeprecatedParameterUsage
(Object parameter, String name, String replacement) void
copyProperties
(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject) Copy properties from the Maven project to the Ant project.void
copyProperties
(org.apache.tools.ant.Project antProject, org.apache.maven.project.MavenProject mavenProject) Copy properties from the Ant project to the Maven project.void
execute()
private String
findFragment
(org.apache.tools.ant.BuildException buildException) private org.apache.tools.ant.DefaultLogger
private org.apache.tools.ant.types.Path
getPathFromArtifacts
(Collection<org.apache.maven.artifact.Artifact> artifacts, org.apache.tools.ant.Project antProject) private String
void
initMavenTasks
(org.apache.tools.ant.Project antProject) private File
writeTargetToProjectFile
(String targetName) Write the Ant target and surrounding tags to a temporary fileMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
MAVEN_REFID_PREFIX
The prefix of all refid used by the plugin.- See Also:
-
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 anant
task.- See Also:
-
DEFAULT_MAVEN_PROJECT_REF_REFID
The refid used to store an object of typeMavenAntRunProject
containing 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:
-
DEFAULT_MAVEN_PROJECT_HELPER_REFID
The refid used to store the Maven project object in the Ant build.- See Also:
-
DEFAULT_ANT_TARGET_NAME
The default target name.- See Also:
-
UTF_8
The default encoding to use for the generated Ant build.- See Also:
-
ANTLIB
The path to The XML file containing the definition of the Maven tasks.- See Also:
-
TASK_URI
The URI which defines the built in Ant tasks- See Also:
-
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 -
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelperThe Maven project helper object -
pluginArtifacts
@Parameter(property="plugin.artifacts", required=true, readonly=true) private 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
String to prepend to project and dependency property names.- Since:
- 1.4
-
customTaskPrefix
Deprecated.only here for backwards compatibilityMaven will look in the target-tag for the namespace ofhttp://maven.apache.org/ANTRUN
orantlib:org.apache.maven.ant.tasks
<configuration> <target xmlns:mvn="http://maven.apache.org/ANTRUN"> <mvn:attachartifact/> <mvn:dependencyfilesets/> </target> </configuration>
- Since:
- 1.5
-
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.Usetarget
instead. 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 targetThe 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.Use thebuild-helper-maven-plugin
to bind 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. Use this if your Ant script generates source code. -
testSourceRoot
Deprecated.Use thebuild-helper-maven-plugin
to 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 exportAntPropertiesSpecifies whether the Ant properties should be propagated to the Maven properties.- Since:
- 1.7
-
failOnError
@Parameter(defaultValue="true") private boolean failOnErrorSpecifies 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
-
-
Constructor Details
-
AntRunMojo
public AntRunMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
checkDeprecatedParameterUsage
private void checkDeprecatedParameterUsage(Object parameter, String name, 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(Collection<org.apache.maven.artifact.Artifact> artifacts, org.apache.tools.ant.Project antProject) throws org.apache.maven.artifact.DependencyResolutionRequiredException - Parameters:
artifacts
-Artifact
collection.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
-MavenProject
antProject
-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
Write the Ant target and surrounding tags to a temporary file- Throws:
IOException
- problem with write to file
-
getTaskPrefix
-
findFragment
- Parameters:
buildException
- not null- Returns:
- the fragment XML part where the buildException occurs.
- Since:
- 1.7
-