Package org.apache.maven.plugin.antrun
Class AntRunMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.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 <tasks/> parameter. It is encouraged to move the actual tasks to a separate build.xml file and call that file with an <ant/> task.- Version:
- $Id: AntRunMojo.java 1645339 2014-12-13 17:56:59Z khmarbaise $
-
-
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.StringantTargetNameThe name used for the Ant targetprivate java.lang.StringcustomTaskPrefixThe xml tag prefix to use for the built in Ant tasks.static 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_REFIDThe refid used to store the Maven project object in the Ant build.static java.lang.StringDEPENDENCY_PREFIXDeprecated.This should only be used for generating the old property format.private booleanexportAntPropertiesSpecifies whether the Ant properties should be propagated 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 repositoryprivate java.util.List<org.apache.maven.artifact.Artifact>pluginArtifactsThe plugin dependencies.private org.apache.maven.project.MavenProjectprojectThe Maven project objectprivate org.apache.maven.project.MavenProjectHelperprojectHelperThe Maven project helper objectprivate java.lang.StringpropertyPrefixString to prepend to project and dependency property names.private booleanskipSpecifies whether the Antrun execution should be skipped.private java.io.FilesourceRootDeprecated.Use the build-helper-maven-plugin to bind source directoriesprivate 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.Use target insteadprivate java.io.FiletestSourceRootDeprecated.Use the build-helper-maven-plugin to bind test source directoriesstatic 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()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.StringcheckTargetName(org.codehaus.plexus.configuration.PlexusConfiguration antTargetConfig)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)static java.lang.StringgetDependencyArtifactPropertyName(org.apache.maven.artifact.Artifact artifact)Deprecated.The dependency conflict ID should be used as the property name.org.apache.maven.project.MavenProjectgetMavenProject()Get the current Maven projectorg.apache.tools.ant.types.PathgetPathFromArtifacts(java.util.Collection<org.apache.maven.artifact.Artifact> artifacts, org.apache.tools.ant.Project antProject)voidinitMavenTasks(org.apache.tools.ant.Project antProject)voidstringReplace(java.lang.StringBuilder text, java.lang.String match, java.lang.String with)Replace text in a StringBuilder.private java.io.FilewriteTargetToProjectFile()Write the Ant target and surrounding tags to a temporary file
-
-
-
Field Detail
-
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.- 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
-
antTargetName
private java.lang.String antTargetName
The name used for the Ant target
-
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
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject projectThe Maven project 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> 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
@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
@Parameter private org.codehaus.plexus.configuration.PlexusConfiguration tasks
Deprecated.Use target insteadThe 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
@Parameter(property="sourceRoot") private java.io.File sourceRoot
Deprecated.Use the build-helper-maven-plugin to bind source directoriesThis folder is added to the list of those folders containing source to be compiled. Use this if your Ant script generates source code.
-
testSourceRoot
@Parameter(property="testSourceRoot") private java.io.File testSourceRoot
Deprecated.Use the build-helper-maven-plugin to bind test source directoriesThis 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 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
-
DEPENDENCY_PREFIX
public static final java.lang.String DEPENDENCY_PREFIX
Deprecated.This should only be used for generating the old property format.Prefix for legacy property format.- See Also:
- Constant Field Values
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getPathFromArtifacts
public 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
-
getDependencyArtifactPropertyName
public static java.lang.String getDependencyArtifactPropertyName(org.apache.maven.artifact.Artifact artifact)
Deprecated.The dependency conflict ID should be used as the property name.Returns a property name for a dependency artifact. The name is in the format maven.dependency.groupId.artifactId[.classifier].type.path- Parameters:
artifact-Artifact- Returns:
- property name
-
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)
- Parameters:
antProject-Project
-
writeTargetToProjectFile
private java.io.File writeTargetToProjectFile() throws java.io.IOException, org.codehaus.plexus.configuration.PlexusConfigurationExceptionWrite the Ant target and surrounding tags to a temporary file- Throws:
org.codehaus.plexus.configuration.PlexusConfigurationExceptionjava.io.IOException
-
stringReplace
public void stringReplace(java.lang.StringBuilder text, java.lang.String match, java.lang.String with)Replace text in a StringBuilder. If the match text is not found, the StringBuilder is returned unchanged.- Parameters:
text- The string buffer containing the textmatch- The string to match and removewith- The string to insert
-
checkTargetName
public java.lang.String checkTargetName(org.codehaus.plexus.configuration.PlexusConfiguration antTargetConfig) throws org.codehaus.plexus.configuration.PlexusConfigurationException- Parameters:
antTargetConfig-PlexusConfiguration- Returns:
- The target name.
- Throws:
org.codehaus.plexus.configuration.PlexusConfigurationException- in case of not existing attribute.
-
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
-
-