Class AntBuildWriter

java.lang.Object
org.apache.maven.plugin.ant.AntBuildWriter

public class AntBuildWriter extends Object
Write Ant build files from Maven Project for Ant 1.6.2 or above:
  • build.xml
  • maven-build.xml
  • maven-build.properties
Version:
$Id: AntBuildWriter.java 1645084 2014-12-12 22:28:31Z khmarbaise $
  • Field Details

    • DEFAULT_INDENTATION_SIZE

      protected static final int DEFAULT_INDENTATION_SIZE
      The default line indenter
      See Also:
    • DEFAULT_BUILD_FILENAME

      protected static final String DEFAULT_BUILD_FILENAME
      The default build file name (build.xml)
      See Also:
    • DEFAULT_MAVEN_BUILD_FILENAME

      protected static final String DEFAULT_MAVEN_BUILD_FILENAME
      The default generated build file name
      See Also:
    • DEFAULT_MAVEN_PROPERTIES_FILENAME

      protected static final String DEFAULT_MAVEN_PROPERTIES_FILENAME
      The default build properties file name
      See Also:
    • project

      private final org.apache.maven.project.MavenProject project
    • artifactResolverWrapper

      private final ArtifactResolverWrapper artifactResolverWrapper
    • localRepository

      private final File localRepository
    • settings

      private final org.apache.maven.settings.Settings settings
    • overwrite

      private final boolean overwrite
    • executionProperties

      private final Properties executionProperties
  • Constructor Details

    • AntBuildWriter

      public AntBuildWriter(org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, org.apache.maven.settings.Settings settings, boolean overwrite, Properties executionProperties)
      Parameters:
      project - MavenProject
      artifactResolverWrapper - ArtifactResolverWrapper
      settings - Settings
      overwrite - true/false to overwrite or not.
      executionProperties - Properties
  • Method Details

    • writeBuildXmls

      protected void writeBuildXmls() throws IOException
      Generate Ant build XML files
      Throws:
      IOException - In case of an error.
    • writeBuildProperties

      protected void writeBuildProperties() throws IOException
      Generate maven-build.properties only for a non-POM project
      Throws:
      IOException - In case of an failure IOException
      See Also:
    • writeGeneratedBuildXml

      private void writeGeneratedBuildXml() throws IOException
      Generate an maven-build.xml
      Throws:
      IOException
      See Also:
    • writeBuildXml

      private void writeBuildXml() throws IOException
      Generate an generic build.xml if not already exist
      Throws:
      IOException
      See Also:
    • writeProperties

      private void writeProperties(org.codehaus.plexus.util.xml.XMLWriter writer)
      Write properties in the writer only for a non-POM project.
      Parameters:
      writer -
    • getLocalRepositoryPath

      private String getLocalRepositoryPath()
      Check if the local repository is in the default location: ${user.home}/.m2/repository. If that is the case then return the path with the system property "user.home" in it. If not then just return the absolute path to the local repository.
    • writeBuildPathDefinition

      private void writeBuildPathDefinition(org.codehaus.plexus.util.xml.XMLWriter writer)
      Write path definition in the writer only for a non-POM project.
      Parameters:
      writer -
    • writeBuildPathDefinition

      private void writeBuildPathDefinition(org.codehaus.plexus.util.xml.XMLWriter writer, String id, List artifacts)
    • getUninterpolatedSystemPath

      private String getUninterpolatedSystemPath(org.apache.maven.artifact.Artifact artifact)
    • writeCleanTarget

      private void writeCleanTarget(org.codehaus.plexus.util.xml.XMLWriter writer)
      Write clean target in the writer depending the packaging of the project.
      Parameters:
      writer - the writer
    • writeCompileTarget

      private void writeCompileTarget(org.codehaus.plexus.util.xml.XMLWriter writer, List compileSourceRoots) throws IOException
      Write compile target in the writer depending the packaging of the project.
      Parameters:
      writer -
      compileSourceRoots -
      Throws:
      IOException - if any
    • writeCompileTestsTarget

      private void writeCompileTestsTarget(org.codehaus.plexus.util.xml.XMLWriter writer, List testCompileSourceRoots) throws IOException
      Write compile-test target in the writer depending the packaging of the project.
      Parameters:
      writer -
      testCompileSourceRoots -
      Throws:
      IOException - if any
    • writeTestTargets

      private void writeTestTargets(org.codehaus.plexus.util.xml.XMLWriter writer, List testCompileSourceRoots) throws IOException
      Write test target in the writer depending the packaging of the project.
      Parameters:
      writer -
      testCompileSourceRoots -
      Throws:
      IOException
    • writePomParts

      private void writePomParts(org.codehaus.plexus.util.xml.XMLWriter writer)
      Parameters:
      writer - XMLWriter
    • getTestIncludes

      private List getTestIncludes() throws IOException
      Gets the include patterns for the unit tests.
      Returns:
      A list of strings with include patterns, might be empty but never null.
      Throws:
      IOException
    • getTestExcludes

      private List getTestExcludes() throws IOException
      Gets the exclude patterns for the unit tests.
      Returns:
      A list of strings with exclude patterns, might be empty but never null.
      Throws:
      IOException
    • writeTestFilesets

      private void writeTestFilesets(org.codehaus.plexus.util.xml.XMLWriter writer, List testCompileSourceRoots, List includes, List excludes)
      Write the <fileset> elements for the test compile source roots.
      Parameters:
      writer -
      testCompileSourceRoots -
      includes -
      excludes -
    • writeJavadocTarget

      private void writeJavadocTarget(org.codehaus.plexus.util.xml.XMLWriter writer) throws IOException
      Write javadoc target in the writer depending the packaging of the project.
      Parameters:
      writer -
      Throws:
      IOException - if any
    • writePackageTarget

      private void writePackageTarget(org.codehaus.plexus.util.xml.XMLWriter writer) throws IOException
      Write package target in the writer depending the packaging of the project.
      Parameters:
      writer -
      Throws:
      IOException - if any
    • writeCompileTasks

      private void writeCompileTasks(org.codehaus.plexus.util.xml.XMLWriter writer, String outputDirectory, List compileSourceRoots, List resources, String additionalClassesDirectory, boolean isTest) throws IOException
      Throws:
      IOException
    • writeGetDepsTarget

      private void writeGetDepsTarget(org.codehaus.plexus.util.xml.XMLWriter writer)
      Write get-deps target in the writer only for a non-POM project
      Parameters:
      writer -
    • getProjectRepoDirectory

      static String getProjectRepoDirectory(String repoUrl, String projectDir)
      Gets the relative path to a repository that is rooted in the project. The returned path (if any) will always use the forward slash ('/') as the directory separator. For example, the path "target/it-repo" will be returned for a repository constructed from the URL "file://${basedir}/target/it-repo".
      Parameters:
      repoUrl - The URL to the repository, must not be null.
      projectDir - The absolute path to the base directory of the project, must not be null
      Returns:
      The path to the repository (relative to the project base directory) or null if the repository is not rooted in the project.
    • addProperty

      private static void addProperty(Properties properties, String name, String value)
      Put a property in properties defined by a name and a value
      Parameters:
      properties - not null
      name -
      value - not null
    • getCommaSeparatedList

      private static String getCommaSeparatedList(Map[] includes, String key)
      Parameters:
      includes - an array of includes or exludes map
      key - a key wanted in the map, like include or exclude
      Returns:
      a String with comma-separated value of a key in each map
    • getSelectorList

      private static List getSelectorList(Map[] options)
      Flattens the specified file selector options into a simple string list. For instance, the input

       [ {include="*Test.java"}, {include="*TestCase.java"} ]
       

      is converted to

       [ "*Test.java", "*TestCase.java" ]
       
      Parameters:
      options - The file selector options to flatten, may be null.
      Returns:
      The string list, might be empty but never null.