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 StringThe path to The XML file containing the definition of the Maven tasks.private StringDeprecated.only here for backwards compatibilitystatic final StringThe default target name.static final StringThe refid used to store the Maven project object in the Ant build.static final StringThe refid used to store an object of typeMavenAntRunProjectcontaining the Maven project object in the Ant build.static final StringThe refid used to store the Maven project object in the Ant build.private booleanSpecifies whether the Ant properties should be propagated to the Maven properties.private booleanSpecifies whether a failure in the Ant build leads to a failure of the Maven build.protected org.apache.maven.artifact.repository.ArtifactRepositoryThe local Maven repositorystatic final StringThe prefix of all refid used by the plugin.private org.apache.maven.project.MavenProjectThe Maven project objectprivate List<org.apache.maven.artifact.Artifact>The plugin dependencies.private org.apache.maven.project.MavenProjectHelperThe Maven project helper objectprivate StringString to prepend to project and dependency property names.private org.apache.maven.execution.MavenSessionThe Maven session objectprivate booleanSpecifies whether the Antrun execution should be skipped.private FileDeprecated.Use thebuild-helper-maven-pluginto bind source directories.private org.codehaus.plexus.configuration.PlexusConfigurationThe XML for the Ant target.static final StringThe URI which defines the built in Ant tasksprivate org.codehaus.plexus.configuration.PlexusConfigurationDeprecated.Usetargetinstead.private FileDeprecated.Use thebuild-helper-maven-pluginto bind test source directories.static final StringThe default encoding to use for the generated Ant build.private StringThe 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 voidaddAntProjectReferences(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject) private voidcheckDeprecatedParameterUsage(Object parameter, String name, 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 StringfindFragment(org.apache.tools.ant.BuildException buildException) private org.apache.tools.ant.DefaultLoggerprivate org.apache.tools.ant.types.PathgetPathFromArtifacts(Collection<org.apache.maven.artifact.Artifact> artifacts, org.apache.tools.ant.Project antProject) private StringvoidinitMavenTasks(org.apache.tools.ant.Project antProject) private FilewriteTargetToProjectFile(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 ananttask.- See Also:
-
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:
-
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/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
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.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 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-pluginto 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-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 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.MojoExecutionExceptionorg.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-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
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
-