Class PomUtils

java.lang.Object
com.sap.cds.maven.plugin.util.PomUtils

public class PomUtils extends Object
A utility class to manipulate pom.xml files.
  • 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 DOM
      groupId - the dependency's groupId
      artifactId - the dependency's artifactId
      version - the dependency's version
      scope - 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.xml Document node
      module - 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.xml Document node
      groupId - the plugin's groupId
      artifactId - the plugin's artifactId
      id - the execution identifier, needs to be unique within the executions block
      goal - the plugin's goal
      configXML - 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.xml Document node
      groupId - the plugin's groupId
      artifactId - the plugin's artifactId
      goal - 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.xml Document node
      cmd - the CDS command line to add
      Returns:
      true if command was added
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if document manipulation failed