Package com.sap.cds.maven.plugin.util
Class PomUtils
java.lang.Object
com.sap.cds.maven.plugin.util.PomUtils
A utility class to manipulate pom.xml files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addCdsCommand
(Document doc, String cmd) Adds a CDS command line to the execution of the cds goal.static boolean
Adds a dependency to given pom.xml DOM if it doesn't exist yet.static boolean
Adds a module to given pom.xml DOM if it doesn't exist yet.static boolean
addPluginExecution
(Document doc, String groupId, String artifactId, String id, String goal, String configXML) Adds a new execution block to the given plugin.static boolean
removePluginExecution
(Document doc, String groupId, String artifactId, String goal) Removes a execution block to the given plugin.
-
Method Details
-
addDependency
public static boolean addDependency(Document doc, String groupId, String artifactId, String version, String scope) throws org.apache.maven.plugin.MojoExecutionException Adds a dependency to given pom.xml DOM if it doesn't exist yet.- Parameters:
doc
- the pom.xml DOMgroupId
- the dependency's groupIdartifactId
- the dependency's artifactIdversion
- the dependency's versionscope
- the dependency's scope- Returns:
true
if dependency was added- Throws:
org.apache.maven.plugin.MojoExecutionException
- if document manipulation failed
-
addModule
public static boolean addModule(Document doc, String module) throws org.apache.maven.plugin.MojoExecutionException Adds a module to given pom.xml DOM if it doesn't exist yet.- Parameters:
doc
- the pom.xmlDocument
nodemodule
- the module to add- Returns:
true
if module was added- Throws:
org.apache.maven.plugin.MojoExecutionException
- if document manipulation failed
-
addPluginExecution
public static boolean addPluginExecution(Document doc, String groupId, String artifactId, String id, String goal, String configXML) throws org.apache.maven.plugin.MojoExecutionException Adds a new execution block to the given plugin.- Parameters:
doc
- the pom.xmlDocument
nodegroupId
- the plugin's groupIdartifactId
- the plugin's artifactIdid
- the execution identifier, needs to be unique within the executions blockgoal
- the plugin's goalconfigXML
- the execution configuration as XML fragment- Returns:
true
if plugin execution was added- Throws:
org.apache.maven.plugin.MojoExecutionException
- if document manipulation failed
-
removePluginExecution
public static boolean removePluginExecution(Document doc, String groupId, String artifactId, String goal) throws org.apache.maven.plugin.MojoExecutionException Removes a execution block to the given plugin.- Parameters:
doc
- the pom.xmlDocument
nodegroupId
- the plugin's groupIdartifactId
- the plugin's artifactIdgoal
- the plugin's goal- Returns:
true
if plugin execution was removed- Throws:
org.apache.maven.plugin.MojoExecutionException
- if document manipulation failed
-
addCdsCommand
public static boolean addCdsCommand(Document doc, String cmd) throws org.apache.maven.plugin.MojoExecutionException Adds a CDS command line to the execution of the cds goal.- Parameters:
doc
- the pom.xmlDocument
nodecmd
- the CDS command line to add- Returns:
true
if command was added- Throws:
org.apache.maven.plugin.MojoExecutionException
- if document manipulation failed
-