Class 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 <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 $
    Author:
    Kenney Westerhof, Vincent Siveton
    • Field Detail

      • DEFAULT_MAVEN_PROJECT_REFID

        public static final 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 String DEFAULT_MAVEN_PROJECT_HELPER_REFID
        The refid used to store the Maven project object in the Ant build.
        See Also:
        Constant Field Values
      • ANTLIB

        public static final String ANTLIB
        The path to The XML file containing the definition of the Maven tasks.
        See Also:
        Constant Field Values
      • localRepository

        @Parameter(property="localRepository",
                   readonly=true)
        protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
        The local Maven repository
      • DEPENDENCY_PREFIX

        public static final 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
    • Constructor Detail

      • AntRunMojo

        public AntRunMojo()
    • 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​(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 null
        mavenProject - not null
        Since:
        1.7
      • getDependencyArtifactPropertyName

        public static 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
      • stringReplace

        public void stringReplace​(StringBuilder text,
                                  String match,
                                  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 text
        match - The string to match and remove
        with - The string to insert
      • checkTargetName

        public 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.