Package org.apache.maven.plugin.ant
Class AntBuildWriter
java.lang.Object
org.apache.maven.plugin.ant.AntBuildWriter
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final ArtifactResolverWrapper
protected static final String
The default build file name (build.xml)protected static final int
The default line indenterprotected static final String
The default generated build file nameprotected static final String
The default build properties file nameprivate final Properties
private final File
private final boolean
private final org.apache.maven.project.MavenProject
private final org.apache.maven.settings.Settings
-
Constructor Summary
ConstructorsConstructorDescriptionAntBuildWriter
(org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, org.apache.maven.settings.Settings settings, boolean overwrite, Properties executionProperties) -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
addProperty
(Properties properties, String name, String value) Put a property in properties defined by a name and a valueprivate static String
getCommaSeparatedList
(Map[] includes, String key) private String
Check if the local repository is in the default location:${user.home}/.m2/repository
.(package private) static String
getProjectRepoDirectory
(String repoUrl, String projectDir) Gets the relative path to a repository that is rooted in the project.private static List
getSelectorList
(Map[] options) Flattens the specified file selector options into a simple string list.private List
Gets the exclude patterns for the unit tests.private List
Gets the include patterns for the unit tests.private String
getUninterpolatedSystemPath
(org.apache.maven.artifact.Artifact artifact) private void
writeBuildPathDefinition
(org.codehaus.plexus.util.xml.XMLWriter writer) Write path definition in the writer only for a non-POM project.private void
writeBuildPathDefinition
(org.codehaus.plexus.util.xml.XMLWriter writer, String id, List artifacts) protected void
Generatemaven-build.properties
only for a non-POM projectprivate void
Generate an genericbuild.xml
if not already existprotected void
Generate Ant build XML filesprivate void
writeCleanTarget
(org.codehaus.plexus.util.xml.XMLWriter writer) Write clean target in the writer depending the packaging of the project.private void
writeCompileTarget
(org.codehaus.plexus.util.xml.XMLWriter writer, List compileSourceRoots) Write compile target in the writer depending the packaging of the project.private void
writeCompileTasks
(org.codehaus.plexus.util.xml.XMLWriter writer, String outputDirectory, List compileSourceRoots, List resources, String additionalClassesDirectory, boolean isTest) private void
writeCompileTestsTarget
(org.codehaus.plexus.util.xml.XMLWriter writer, List testCompileSourceRoots) Write compile-test target in the writer depending the packaging of the project.private void
Generate anmaven-build.xml
private void
writeGetDepsTarget
(org.codehaus.plexus.util.xml.XMLWriter writer) Write get-deps target in the writer only for a non-POM projectprivate void
writeJavadocTarget
(org.codehaus.plexus.util.xml.XMLWriter writer) Write javadoc target in the writer depending the packaging of the project.private void
writePackageTarget
(org.codehaus.plexus.util.xml.XMLWriter writer) Write package target in the writer depending the packaging of the project.private void
writePomParts
(org.codehaus.plexus.util.xml.XMLWriter writer) private void
writeProperties
(org.codehaus.plexus.util.xml.XMLWriter writer) Write properties in the writer only for a non-POM project.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.private void
writeTestTargets
(org.codehaus.plexus.util.xml.XMLWriter writer, List testCompileSourceRoots) Write test target in the writer depending the packaging of the project.
-
Field Details
-
DEFAULT_INDENTATION_SIZE
protected static final int DEFAULT_INDENTATION_SIZEThe default line indenter- See Also:
-
DEFAULT_BUILD_FILENAME
The default build file name (build.xml)- See Also:
-
DEFAULT_MAVEN_BUILD_FILENAME
The default generated build file name- See Also:
-
DEFAULT_MAVEN_PROPERTIES_FILENAME
The default build properties file name- See Also:
-
project
private final org.apache.maven.project.MavenProject project -
artifactResolverWrapper
-
localRepository
-
settings
private final org.apache.maven.settings.Settings settings -
overwrite
private final boolean overwrite -
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
Generate Ant build XML files- Throws:
IOException
- In case of an error.
-
writeBuildProperties
Generatemaven-build.properties
only for a non-POM project- Throws:
IOException
- In case of an failureIOException
- See Also:
-
writeGeneratedBuildXml
Generate anmaven-build.xml
- Throws:
IOException
- See Also:
-
writeBuildXml
Generate an genericbuild.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
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
-
getUninterpolatedSystemPath
-
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
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
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
Write javadoc target in the writer depending the packaging of the project.- Parameters:
writer
-- Throws:
IOException
- if any
-
writePackageTarget
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
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
null
if the repository is not rooted in the project.
-
addProperty
Put a property in properties defined by a name and a value- Parameters:
properties
- not nullname
-value
- not null
-
getCommaSeparatedList
- Parameters:
includes
- an array of includes or exludes mapkey
- a key wanted in the map, likeinclude
orexclude
- Returns:
- a String with comma-separated value of a key in each map
-
getSelectorList
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
.
-