Class AntBuildWriterUtil
java.lang.Object
org.apache.maven.plugin.ant.AntBuildWriterUtil
Utility class for the
AntBuildWriter class.- Version:
- $Id: AntBuildWriterUtil.java 1645084 2014-12-12 22:28:31Z khmarbaise $
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddWrapAttribute(org.codehaus.plexus.util.xml.XMLWriter writer, String tag, String name, String value, int indent) Convenience method to wrap long element tags for a given attribute.static StringgetMavenCompilerPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return theoptionNamevalue defined in a project for the "maven-compiler-plugin" plugin.static MapgetMavenCompilerPluginOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return the map ofoptionNamevalue defined in a project for the "maven-compiler-plugin" plugin.static Map[]getMavenCompilerPluginOptions(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return an array of map ofoptionNamevalue defined in a project for the "maven-compiler-plugin" plugin.static StringgetMavenEarPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return theoptionNamevalue defined in a project for the "maven-ear-plugin" plugin.static StringgetMavenJarPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return theoptionNamevalue defined in a project for the "maven-jar-plugin" plugin.static StringgetMavenJavadocPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return theoptionNamevalue defined in a project for the "maven-javadoc-plugin" plugin.static MapgetMavenJavadocPluginOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return a map ofoptionNamevalue defined in a project for the "maven-javadoc-plugin" plugin.static Map[]getMavenJavadocPluginOptions(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return an array of map ofoptionNamevalue defined in a project for the "maven-javadoc-plugin" plugin.private static StringgetMavenPluginBasicOption(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) Return the value for the optionoptionNamedefined in a project with the givenartifactIdplugin.private static MapgetMavenPluginConfigurationsImpl(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) Return a Map for the optionoptionNamedefined in a project with the givenartifactIdplugin.private static MapgetMavenPluginOption(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) Return a Map for the optionoptionNamedefined in a project with the givenartifactIdplugin.private static Map[]getMavenPluginOptions(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) Return an array of Map for the optionoptionNamedefined in a project with the givenartifactIdplugin.static StringgetMavenSurefirePluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return theoptionNamevalue defined in a project for the "maven-surefire-plugin" plugin.static MapgetMavenSurefirePluginOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return the map ofoptionNamevalue defined in a project for the "maven-surefire-plugin" plugin.static Map[]getMavenSurefirePluginOptions(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return an array of map ofoptionNamevalue defined in a project for the "maven-surefire-plugin" plugin.static StringgetMavenWarPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) Return theoptionNamevalue defined in a project for the "maven-war-plugin" plugin.(package private) static StringgetSingularForm(String pluralForm) Gets the singular form of the specified (English) plural form.private static StringgetTextContent(Node node) Gets the text content of the specified node.static booleanisBundlePackaging(org.apache.maven.project.MavenProject mavenProject) static booleanisEarPackaging(org.apache.maven.project.MavenProject mavenProject) static booleanisEjbPackaging(org.apache.maven.project.MavenProject mavenProject) private static booleanisElementContent(Node node) Checks whether the specified node has element content or consists only of character data.static booleanisJarPackaging(org.apache.maven.project.MavenProject mavenProject) private static booleanCheck if a givennodeis a list of nodes or not.static booleanisMavenPluginPackaging(org.apache.maven.project.MavenProject mavenProject) static booleanisPomPackaging(org.apache.maven.project.MavenProject mavenProject) static booleanisWarPackaging(org.apache.maven.project.MavenProject mavenProject) static ListremoveEmptyCompileSourceRoots(List compileSourceRoots) (package private) static StringtoRelative(File basedir, String path) Relativizes the specified path against the given base directory (if possible).static voidwriteAntTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, String moduleSubPath, String tasks) Convenience method to write XML ant taskstatic voidwriteAntVersionHeader(org.codehaus.plexus.util.xml.XMLWriter writer) Write comment for the Ant supported versionprivate static voidwriteCopyLib(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, String outputDir) Write copy tasks in an outputDir for EAR and WAR targets for project depencies withoutprovidedortestas scopestatic voidwriteEarTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper) Convenience method to write XML Ant ear taskstatic voidwriteHeader(org.codehaus.plexus.util.xml.XMLWriter writer) Write comments in the Ant build file headerstatic voidwriteIncludesExcludes(org.codehaus.plexus.util.xml.XMLWriter writer, List includes, List excludes) Convenience method to write<include/>and<exclude/>static voidwriteJarTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project) Convenience method to write XML Ant jar taskstatic voidwriteJavadocTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper wrapper) Convenience method to write XML Ant javadoc taskstatic voidwriteWarTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper) Convenience method to write XML Ant war task
-
Constructor Details
-
AntBuildWriterUtil
public AntBuildWriterUtil()
-
-
Method Details
-
removeEmptyCompileSourceRoots
-
writeIncludesExcludes
-
writeHeader
public static void writeHeader(org.codehaus.plexus.util.xml.XMLWriter writer) Write comments in the Ant build file header- Parameters:
writer-XMLWriter
-
writeAntVersionHeader
public static void writeAntVersionHeader(org.codehaus.plexus.util.xml.XMLWriter writer) Write comment for the Ant supported version- Parameters:
writer- the writer
-
writeAntTask
-
writeJavadocTask
public static void writeJavadocTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper wrapper) throws IOException Convenience method to write XML Ant javadoc task- Parameters:
writer- not nullproject- not nullwrapper- not null- Throws:
IOException- if any
-
writeJarTask
public static void writeJarTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project) throws IOException Convenience method to write XML Ant jar task- Parameters:
writer- not nullproject- not null- Throws:
IOException- if any
-
writeEarTask
public static void writeEarTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper) throws IOException Convenience method to write XML Ant ear task- Parameters:
writer- not nullproject- not nullartifactResolverWrapper- not null- Throws:
IOException- if any
-
writeWarTask
public static void writeWarTask(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper) throws IOException Convenience method to write XML Ant war task- Parameters:
writer- not nullproject- not nullartifactResolverWrapper- not null- Throws:
IOException- if any
-
addWrapAttribute
public static void addWrapAttribute(org.codehaus.plexus.util.xml.XMLWriter writer, String tag, String name, String value, int indent) Convenience method to wrap long element tags for a given attribute.- Parameters:
writer- not nulltag- not nullname- not nullvalue- not nullindent- positive value
-
isPomPackaging
public static boolean isPomPackaging(org.apache.maven.project.MavenProject mavenProject) - Parameters:
mavenProject- not null- Returns:
- true if project packaging equals
pom
-
isJarPackaging
public static boolean isJarPackaging(org.apache.maven.project.MavenProject mavenProject) - Parameters:
mavenProject-MavenProject- Returns:
- true if project packaging equals one of several packaging types
including
jar,maven-plugin,ejb, orbundle
-
isBundlePackaging
public static boolean isBundlePackaging(org.apache.maven.project.MavenProject mavenProject) - Parameters:
mavenProject-MavenProject- Returns:
- true if project packaging equals
bundle
-
isEjbPackaging
public static boolean isEjbPackaging(org.apache.maven.project.MavenProject mavenProject) - Parameters:
mavenProject-MavenProject- Returns:
- true if project packaging equals
ejb
-
isMavenPluginPackaging
public static boolean isMavenPluginPackaging(org.apache.maven.project.MavenProject mavenProject) - Parameters:
mavenProject-MavenProject- Returns:
- true if project packaging equals
maven-plugin
-
isEarPackaging
public static boolean isEarPackaging(org.apache.maven.project.MavenProject mavenProject) - Parameters:
mavenProject-MavenProject- Returns:
- true if project packaging equals
ear
-
isWarPackaging
public static boolean isWarPackaging(org.apache.maven.project.MavenProject mavenProject) - Parameters:
mavenProject-MavenProject- Returns:
- true if project packaging equals
war
-
getMavenCompilerPluginBasicOption
public static String getMavenCompilerPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return theoptionNamevalue defined in a project for the "maven-compiler-plugin" plugin.- Parameters:
project-MavenProjectnot null.optionName- the option name wanteddefaultValue- a default value- Returns:
- the value for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenCompilerPluginOption
public static Map getMavenCompilerPluginOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return the map ofoptionNamevalue defined in a project for the "maven-compiler-plugin" plugin.- Parameters:
project-MavenProjectnot null.optionName- the option name wanteddefaultValue- a default value- Returns:
- the map for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenCompilerPluginOptions
public static Map[] getMavenCompilerPluginOptions(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return an array of map ofoptionNamevalue defined in a project for the "maven-compiler-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the array of option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenSurefirePluginBasicOption
public static String getMavenSurefirePluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return theoptionNamevalue defined in a project for the "maven-surefire-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the value for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenSurefirePluginOption
public static Map getMavenSurefirePluginOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return the map ofoptionNamevalue defined in a project for the "maven-surefire-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the map for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenSurefirePluginOptions
public static Map[] getMavenSurefirePluginOptions(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return an array of map ofoptionNamevalue defined in a project for the "maven-surefire-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the array of option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenJavadocPluginBasicOption
public static String getMavenJavadocPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return theoptionNamevalue defined in a project for the "maven-javadoc-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the value for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenJavadocPluginOption
public static Map getMavenJavadocPluginOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return a map ofoptionNamevalue defined in a project for the "maven-javadoc-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the map for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenJavadocPluginOptions
public static Map[] getMavenJavadocPluginOptions(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return an array of map ofoptionNamevalue defined in a project for the "maven-javadoc-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- an array of option name. Could be null if not found.
- Throws:
IOException- if any
-
getMavenJarPluginBasicOption
public static String getMavenJarPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return theoptionNamevalue defined in a project for the "maven-jar-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the value for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenEarPluginBasicOption
public static String getMavenEarPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return theoptionNamevalue defined in a project for the "maven-ear-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the value for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenWarPluginBasicOption
public static String getMavenWarPluginBasicOption(org.apache.maven.project.MavenProject project, String optionName, String defaultValue) throws IOException Return theoptionNamevalue defined in a project for the "maven-war-plugin" plugin.- Parameters:
project- not nulloptionName- the option name wanteddefaultValue- a default value- Returns:
- the value for the option name or the default value. Could be null if not found.
- Throws:
IOException- if any
-
getMavenPluginBasicOption
private static String getMavenPluginBasicOption(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) throws IOException Return the value for the optionoptionNamedefined in a project with the givenartifactIdplugin.
Example:Configuration Result <option>value</option>
value
- Parameters:
project- not nullpluginArtifactId- not nulloptionName- anXpathexpression from the plugin<configuration/>defaultValue- could be null- Returns:
- the value for the option name or null if not found
- Throws:
IOException- if any
-
getMavenPluginOption
private static Map getMavenPluginOption(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) throws IOException Return a Map for the optionoptionNamedefined in a project with the givenartifactIdplugin.
Example:Configuration Result <option> <param1>value1</param1> <param2>value2</param2> </option>
{param1=value1, param2=value2}- Parameters:
project- not nullpluginArtifactId- not nulloptionName- anXpathexpression from the plugin<configuration/>defaultValue- could be null- Returns:
- the value for the option name or null if not found
- Throws:
IOException- if any
-
getMavenPluginOptions
private static Map[] getMavenPluginOptions(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) throws IOException Return an array of Map for the optionoptionNamedefined in a project with the givenartifactIdplugin.
Example:Configuration Result <options> <option> <param1>value1</param1> <param2>value2</param2> </option> <option> <param1>value1</param1> <param2>value2</param2> </option> </options>
[{option=[{param1=value1, param2=value2}]}, {option=[{param1=value1, param2=value2}]- Parameters:
project- not nullpluginArtifactId- not nulloptionName- anXpathexpression from the plugin<configuration/>defaultValue- could be null- Returns:
- the value for the option name or null if not found
- Throws:
IOException- if any
-
getMavenPluginConfigurationsImpl
private static Map getMavenPluginConfigurationsImpl(org.apache.maven.project.MavenProject project, String pluginArtifactId, String optionName, String defaultValue) throws IOException Return a Map for the optionoptionNamedefined in a project with the givenartifactIdplugin.
Example:Configuration Result <option>value</option>
{option=value}<option> <param1>value1</param1> <param2>value2</param2> </option>
{option={param1=value1, param2=value2}}<options> <option> <param1>value1</param1> <param2>value2</param2> </option> <option> <param1>value1</param1> <param2>value2</param2> </option> </options>
{options=[{option=[{param1=value1, param2=value2}]}, {option=[{param1=value1, param2=value2}]}]- Parameters:
project- not nullpluginArtifactId- not nulloptionName- anXpathexpression from the plugin<configuration/>defaultValue- could be null- Returns:
- a map with the options found
- Throws:
IOException- if any
-
writeCopyLib
private static void writeCopyLib(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, String outputDir) Write copy tasks in an outputDir for EAR and WAR targets for project depencies withoutprovidedortestas scope- Parameters:
writer- not nullproject- not nullartifactResolverWrapper- not nulloutputDir- not null
-
isList
Check if a givennodeis a list of nodes or not.
For instance, the nodeoptionsis a list ofoptionin the following case:<options> <option> <param1>value1</param1> <param2>value2</param2> </option> <option> <param1>value1</param1> <param2>value2</param2> </option> </options>
- Parameters:
node- a given node, may benull.- Returns:
- true if the node is a list, false otherwise.
-
isElementContent
Checks whether the specified node has element content or consists only of character data.- Parameters:
node- The node to test, may benull.- Returns:
trueif any child node is an element,falseotherwise.
-
getTextContent
-
getSingularForm
Gets the singular form of the specified (English) plural form. For example:properties -> property branches -> branch reports -> report
- Parameters:
pluralForm- The plural form for which to derive the singular form, may benull.- Returns:
- The corresponding singular form or an empty string if the input string was not recognized as a plural form.
-
toRelative
Relativizes the specified path against the given base directory (if possible). If the specified path is a subdirectory of the base directory, the base directory prefix will be chopped off. If the specified path is equal to the base directory, the path "." is returned. Otherwise, the path is returned as is. Examples:
The returned path will always use the forward slash ('/') as the file separator regardless of the current platform. Also, the result path will have a trailing slash if the input path has a trailing file separator.basedir path result /home /home/dir dir /home /home/dir/ dir/ /home /home . /home /home/ ./ /home dir dir - Parameters:
basedir- The base directory to relativize the path against, must not benull.path- The path to relativize, must not benull.- Returns:
- The relativized path, never
null.
-