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
Fields Modifier and Type Field Description static java.lang.String
ANTLIB
The path to The XML file containing the definition of the Maven tasks.private java.lang.String
customTaskPrefix
The xml tag prefix to use for the built in Ant tasks.static java.lang.String
DEFAULT_ANT_TARGET_NAME
The default target name.static java.lang.String
DEFAULT_MAVEN_PROJECT_HELPER_REFID
The refid used to store the Maven project object in the Ant build.static java.lang.String
DEFAULT_MAVEN_PROJECT_REF_REFID
The refid used to store an object of typeMavenAntRunProject
containing the Maven project object in the Ant build.static java.lang.String
DEFAULT_MAVEN_PROJECT_REFID
The refid used to store the Maven project object in the Ant build.private boolean
exportAntProperties
Specifies whether the Ant properties should be propagated to the Maven properties.private boolean
failOnError
Specifies whether a failure in the Ant build leads to a failure of the Maven build.protected org.apache.maven.artifact.repository.ArtifactRepository
localRepository
The local Maven repositorystatic java.lang.String
MAVEN_REFID_PREFIX
The prefix of all refid used by the plugin.private org.apache.maven.project.MavenProject
mavenProject
The Maven project objectprivate java.util.List<org.apache.maven.artifact.Artifact>
pluginArtifacts
The plugin dependencies.private org.apache.maven.project.MavenProjectHelper
projectHelper
The Maven project helper objectprivate java.lang.String
propertyPrefix
String to prepend to project and dependency property names.private org.apache.maven.execution.MavenSession
session
The Maven session objectprivate boolean
skip
Specifies whether the Antrun execution should be skipped.private java.io.File
sourceRoot
Deprecated.Use thebuild-helper-maven-plugin
to bind source directories.private org.codehaus.plexus.configuration.PlexusConfiguration
target
The XML for the Ant target.static java.lang.String
TASK_URI
The URI which defines the built in Ant tasksprivate org.codehaus.plexus.configuration.PlexusConfiguration
tasks
Deprecated.Usetarget
instead.private java.io.File
testSourceRoot
Deprecated.Use thebuild-helper-maven-plugin
to bind test source directories.static java.lang.String
UTF_8
The default encoding to use for the generated Ant build.private java.lang.String
versionsPropertyName
The name of a property containing the list of all dependency versions.
-
Constructor Summary
Constructors Constructor Description AntRunMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addAntProjectReferences(org.apache.maven.project.MavenProject mavenProject, org.apache.tools.ant.Project antProject)
private void
checkDeprecatedParameterUsage(java.lang.Object parameter, java.lang.String name, java.lang.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 java.lang.String
findFragment(org.apache.tools.ant.BuildException buildException)
private org.apache.tools.ant.DefaultLogger
getConfiguredBuildLogger()
private org.apache.tools.ant.types.Path
getPathFromArtifacts(java.util.Collection<org.apache.maven.artifact.Artifact> artifacts, org.apache.tools.ant.Project antProject)
void
initMavenTasks(org.apache.tools.ant.Project antProject)
private java.io.File
writeTargetToProjectFile(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 anant
task.- 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 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:
- 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 mavenProject
The Maven project object
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession session
The Maven session object
-
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelper
The Maven project helper object
-
pluginArtifacts
@Parameter(property="plugin.artifacts", required=true, readonly=true) private java.util.List<org.apache.maven.artifact.Artifact> pluginArtifacts
The plugin dependencies.
-
localRepository
@Parameter(property="localRepository", readonly=true) protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
The local Maven repository
-
propertyPrefix
@Parameter(defaultValue="") private java.lang.String propertyPrefix
String to prepend to project and dependency property names.- Since:
- 1.4
-
customTaskPrefix
@Parameter(defaultValue="") private java.lang.String customTaskPrefix
The xml tag prefix to use for the built in Ant tasks. This prefix needs to be prepended to each task referenced in the antrun target config. For example, a prefix of "mvn" means that the attachartifact task is referenced by "<mvn:attachartifact>" The default value of an empty string means that no prefix is used for the tasks.- 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.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 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-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 @Parameter(property="testSourceRoot") private java.io.File 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 skip
Specifies whether the Antrun execution should be skipped.- Since:
- 1.7
-
exportAntProperties
@Parameter(defaultValue="false") private boolean exportAntProperties
Specifies whether the Ant properties should be propagated to the Maven properties.- 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
-
-
Method Detail
-
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(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
-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
private java.io.File writeTargetToProjectFile(java.lang.String targetName) throws java.io.IOException
Write the Ant target and surrounding tags to a temporary file- Throws:
java.io.IOException
- problem with write to file
-
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
-
-