Package org.apache.maven.plugin.ant
Class AntBuildWriter
- java.lang.Object
-
- org.apache.maven.plugin.ant.AntBuildWriter
-
public class AntBuildWriter extends java.lang.ObjectWrite Ant build files fromMaven Projectfor 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 Summary
Fields Modifier and Type Field Description private ArtifactResolverWrapperartifactResolverWrapperprotected static java.lang.StringDEFAULT_BUILD_FILENAMEThe default build file name (build.xml)protected static intDEFAULT_INDENTATION_SIZEThe default line indenterprotected static java.lang.StringDEFAULT_MAVEN_BUILD_FILENAMEThe default generated build file nameprotected static java.lang.StringDEFAULT_MAVEN_PROPERTIES_FILENAMEThe default build properties file nameprivate java.util.PropertiesexecutionPropertiesprivate java.io.FilelocalRepositoryprivate booleanoverwriteprivate org.apache.maven.project.MavenProjectprojectprivate org.apache.maven.settings.Settingssettings
-
Constructor Summary
Constructors Constructor Description AntBuildWriter(org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, org.apache.maven.settings.Settings settings, boolean overwrite, java.util.Properties executionProperties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddProperty(java.util.Properties properties, java.lang.String name, java.lang.String value)Put a property in properties defined by a name and a valueprivate static java.lang.StringgetCommaSeparatedList(java.util.Map[] includes, java.lang.String key)private java.lang.StringgetLocalRepositoryPath()Check if the local repository is in the default location:${user.home}/.m2/repository.(package private) static java.lang.StringgetProjectRepoDirectory(java.lang.String repoUrl, java.lang.String projectDir)Gets the relative path to a repository that is rooted in the project.private static java.util.ListgetSelectorList(java.util.Map[] options)Flattens the specified file selector options into a simple string list.private java.util.ListgetTestExcludes()Gets the exclude patterns for the unit tests.private java.util.ListgetTestIncludes()Gets the include patterns for the unit tests.private java.lang.StringgetUninterpolatedSystemPath(org.apache.maven.artifact.Artifact artifact)private voidwriteBuildPathDefinition(org.codehaus.plexus.util.xml.XMLWriter writer)Write path definition in the writer only for a non-POM project.private voidwriteBuildPathDefinition(org.codehaus.plexus.util.xml.XMLWriter writer, java.lang.String id, java.util.List artifacts)protected voidwriteBuildProperties()Generatemaven-build.propertiesonly for a non-POM projectprivate voidwriteBuildXml()Generate an genericbuild.xmlif not already existprotected voidwriteBuildXmls()Generate Ant build XML filesprivate voidwriteCleanTarget(org.codehaus.plexus.util.xml.XMLWriter writer)Write clean target in the writer depending the packaging of the project.private voidwriteCompileTarget(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List compileSourceRoots)Write compile target in the writer depending the packaging of the project.private voidwriteCompileTasks(org.codehaus.plexus.util.xml.XMLWriter writer, java.lang.String outputDirectory, java.util.List compileSourceRoots, java.util.List resources, java.lang.String additionalClassesDirectory, boolean isTest)private voidwriteCompileTestsTarget(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List testCompileSourceRoots)Write compile-test target in the writer depending the packaging of the project.private voidwriteGeneratedBuildXml()Generate anmaven-build.xmlprivate voidwriteGetDepsTarget(org.codehaus.plexus.util.xml.XMLWriter writer)Write get-deps target in the writer only for a non-POM projectprivate voidwriteJavadocTarget(org.codehaus.plexus.util.xml.XMLWriter writer)Write javadoc target in the writer depending the packaging of the project.private voidwritePackageTarget(org.codehaus.plexus.util.xml.XMLWriter writer)Write package target in the writer depending the packaging of the project.private voidwritePomParts(org.codehaus.plexus.util.xml.XMLWriter writer)private voidwriteProperties(org.codehaus.plexus.util.xml.XMLWriter writer)Write properties in the writer only for a non-POM project.private voidwriteTestFilesets(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List testCompileSourceRoots, java.util.List includes, java.util.List excludes)Write the<fileset>elements for the test compile source roots.private voidwriteTestTargets(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List testCompileSourceRoots)Write test target in the writer depending the packaging of the project.
-
-
-
Field Detail
-
DEFAULT_INDENTATION_SIZE
protected static final int DEFAULT_INDENTATION_SIZE
The default line indenter- See Also:
- Constant Field Values
-
DEFAULT_BUILD_FILENAME
protected static final java.lang.String DEFAULT_BUILD_FILENAME
The default build file name (build.xml)- See Also:
- Constant Field Values
-
DEFAULT_MAVEN_BUILD_FILENAME
protected static final java.lang.String DEFAULT_MAVEN_BUILD_FILENAME
The default generated build file name- See Also:
- Constant Field Values
-
DEFAULT_MAVEN_PROPERTIES_FILENAME
protected static final java.lang.String DEFAULT_MAVEN_PROPERTIES_FILENAME
The default build properties file name- See Also:
- Constant Field Values
-
project
private final org.apache.maven.project.MavenProject project
-
artifactResolverWrapper
private final ArtifactResolverWrapper artifactResolverWrapper
-
localRepository
private final java.io.File localRepository
-
settings
private final org.apache.maven.settings.Settings settings
-
overwrite
private final boolean overwrite
-
executionProperties
private final java.util.Properties executionProperties
-
-
Constructor Detail
-
AntBuildWriter
public AntBuildWriter(org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, org.apache.maven.settings.Settings settings, boolean overwrite, java.util.Properties executionProperties)- Parameters:
project-MavenProjectartifactResolverWrapper-ArtifactResolverWrappersettings-Settingsoverwrite- true/false to overwrite or not.executionProperties-Properties
-
-
Method Detail
-
writeBuildXmls
protected void writeBuildXmls() throws java.io.IOExceptionGenerate Ant build XML files- Throws:
java.io.IOException- In case of an error.
-
writeBuildProperties
protected void writeBuildProperties() throws java.io.IOExceptionGeneratemaven-build.propertiesonly for a non-POM project- Throws:
java.io.IOException- In case of an failureIOException- See Also:
DEFAULT_MAVEN_PROPERTIES_FILENAME
-
writeGeneratedBuildXml
private void writeGeneratedBuildXml() throws java.io.IOExceptionGenerate anmaven-build.xml- Throws:
java.io.IOException- See Also:
DEFAULT_MAVEN_BUILD_FILENAME
-
writeBuildXml
private void writeBuildXml() throws java.io.IOExceptionGenerate an genericbuild.xmlif not already exist- Throws:
java.io.IOException- See Also:
DEFAULT_BUILD_FILENAME
-
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 java.lang.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, java.lang.String id, java.util.List artifacts)
-
getUninterpolatedSystemPath
private java.lang.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, java.util.List compileSourceRoots) throws java.io.IOExceptionWrite compile target in the writer depending the packaging of the project.- Parameters:
writer-compileSourceRoots-- Throws:
java.io.IOException- if any
-
writeCompileTestsTarget
private void writeCompileTestsTarget(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List testCompileSourceRoots) throws java.io.IOExceptionWrite compile-test target in the writer depending the packaging of the project.- Parameters:
writer-testCompileSourceRoots-- Throws:
java.io.IOException- if any
-
writeTestTargets
private void writeTestTargets(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List testCompileSourceRoots) throws java.io.IOExceptionWrite test target in the writer depending the packaging of the project.- Parameters:
writer-testCompileSourceRoots-- Throws:
java.io.IOException
-
writePomParts
private void writePomParts(org.codehaus.plexus.util.xml.XMLWriter writer)
- Parameters:
writer-XMLWriter
-
getTestIncludes
private java.util.List getTestIncludes() throws java.io.IOExceptionGets the include patterns for the unit tests.- Returns:
- A list of strings with include patterns, might be empty but never
null. - Throws:
java.io.IOException
-
getTestExcludes
private java.util.List getTestExcludes() throws java.io.IOExceptionGets the exclude patterns for the unit tests.- Returns:
- A list of strings with exclude patterns, might be empty but never
null. - Throws:
java.io.IOException
-
writeTestFilesets
private void writeTestFilesets(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List testCompileSourceRoots, java.util.List includes, java.util.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 java.io.IOExceptionWrite javadoc target in the writer depending the packaging of the project.- Parameters:
writer-- Throws:
java.io.IOException- if any
-
writePackageTarget
private void writePackageTarget(org.codehaus.plexus.util.xml.XMLWriter writer) throws java.io.IOExceptionWrite package target in the writer depending the packaging of the project.- Parameters:
writer-- Throws:
java.io.IOException- if any
-
writeCompileTasks
private void writeCompileTasks(org.codehaus.plexus.util.xml.XMLWriter writer, java.lang.String outputDirectory, java.util.List compileSourceRoots, java.util.List resources, java.lang.String additionalClassesDirectory, boolean isTest) throws java.io.IOException- Throws:
java.io.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 java.lang.String getProjectRepoDirectory(java.lang.String repoUrl, java.lang.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 benull.projectDir- The absolute path to the base directory of the project, must not benull- Returns:
- The path to the repository (relative to the project base directory) or
nullif the repository is not rooted in the project.
-
addProperty
private static void addProperty(java.util.Properties properties, java.lang.String name, java.lang.String value)Put a property in properties defined by a name and a value- Parameters:
properties- not nullname-value- not null
-
getCommaSeparatedList
private static java.lang.String getCommaSeparatedList(java.util.Map[] includes, java.lang.String key)- Parameters:
includes- an array of includes or exludes mapkey- a key wanted in the map, likeincludeorexclude- Returns:
- a String with comma-separated value of a key in each map
-
getSelectorList
private static java.util.List getSelectorList(java.util.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 benull.- Returns:
- The string list, might be empty but never
null.
-
-