Class PomEditor.Plugins

java.lang.Object
eu.maveniverse.domtrip.maven.PomEditor.Plugins
Enclosing class:
PomEditor

public class PomEditor.Plugins extends Object
Since:
0.1
  • Constructor Details

    • Plugins

      public Plugins()
  • Method Details

    • addPlugin

      public eu.maveniverse.domtrip.Element addPlugin(eu.maveniverse.domtrip.Element pluginsElement, String groupId, String artifactId, String version) throws eu.maveniverse.domtrip.DomTripException
      Adds a plugin element with the specified coordinates.
      Parameters:
      pluginsElement - the plugins container element
      groupId - the plugin groupId
      artifactId - the plugin artifactId
      version - the plugin version (can be null)
      Returns:
      the newly created plugin element
      Throws:
      eu.maveniverse.domtrip.DomTripException - if the plugin cannot be added
    • deleteManagedPlugin

      public boolean deleteManagedPlugin(Coordinates coordinates) throws eu.maveniverse.domtrip.DomTripException
      Removes a managed plugin from project/build/pluginManagement/plugins/plugin[].

      Example:

      PomEditor editor = new PomEditor(document);
      Coordinates compilerPlugin = Coordinates.of("org.apache.maven.plugins", "maven-compiler-plugin", "3.11.0");
      editor.deleteManagedPlugin(compilerPlugin);
      
      Parameters:
      coordinates - the artifact to remove (matched by GA)
      Returns:
      true if the plugin was removed, false if it didn't exist
      Throws:
      eu.maveniverse.domtrip.DomTripException
      Since:
      0.3.0
    • updatePlugin

      public boolean updatePlugin(boolean upsert, Coordinates coordinates) throws eu.maveniverse.domtrip.DomTripException
      Updates or inserts a plugin in project/build/plugins/plugin[].

      If the plugin exists (matched by GA), its version is updated. If the version is a property reference (${...}), the property value is updated instead. If the plugin has no version element, the managed plugin is updated instead. If upsert is true and the plugin doesn't exist, it will be created.

      Example:

      PomEditor editor = new PomEditor(document);
      Coordinates compilerPlugin = Coordinates.of("org.apache.maven.plugins", "maven-compiler-plugin", "3.11.0");
      editor.updatePlugin(true, compilerPlugin);
      
      Parameters:
      upsert - whether to create the plugin if it doesn't exist
      coordinates - the artifact coordinates
      Returns:
      true if the plugin was updated or created, false otherwise
      Throws:
      eu.maveniverse.domtrip.DomTripException - if an error occurs during editing
      Since:
      0.3.0
    • deletePlugin

      public boolean deletePlugin(Coordinates coordinates) throws eu.maveniverse.domtrip.DomTripException
      Removes a plugin from project/build/plugins/plugin[].

      Example:

      PomEditor editor = new PomEditor(document);
      Coordinates compilerPlugin = Coordinates.of("org.apache.maven.plugins", "maven-compiler-plugin", "3.11.0");
      editor.deletePlugin(compilerPlugin);
      
      Parameters:
      coordinates - the artifact to remove (matched by GA)
      Returns:
      true if the plugin was removed, false if it didn't exist
      Throws:
      eu.maveniverse.domtrip.DomTripException
      Since:
      0.3.0
    • deletePluginVersion

      public boolean deletePluginVersion(Coordinates coordinates) throws eu.maveniverse.domtrip.DomTripException
      Removes a plugin version element from project/build/plugins/plugin[]. This is usually combined with adding plugin management for same plugin.

      Example:

      PomEditor editor = new PomEditor(document);
      Coordinates compilerPlugin = Coordinates.of("org.apache.maven.plugins", "maven-compiler-plugin", "3.11.0");
      editor.deletePluginVersion(compilerPlugin);
      editor.updateManagedPlugin(true, compilerPlugin);
      
      Parameters:
      coordinates - the artifact to remove (matched by GA)
      Returns:
      true if the plugin version was removed, false if it didn't exist
      Throws:
      eu.maveniverse.domtrip.DomTripException
      Since:
      0.3.1
    • updateManagedPlugin

      public boolean updateManagedPlugin(boolean upsert, Coordinates coordinates) throws eu.maveniverse.domtrip.DomTripException
      Updates or inserts a managed plugin in project/build/pluginManagement/plugins/plugin[].

      If the plugin exists (matched by GA), its version is updated. If the version is a property reference (${...}), the property value is updated instead. If upsert is true and the plugin doesn't exist, it will be created.

      Example:

      PomEditor editor = new PomEditor(document);
      Coordinates compilerPlugin = Coordinates.of("org.apache.maven.plugins", "maven-compiler-plugin", "3.11.0");
      editor.updateManagedPlugin(true, compilerPlugin);
      
      Parameters:
      upsert - whether to create the plugin if it doesn't exist
      coordinates - the artifact coordinates
      Returns:
      true if the plugin was updated or created, false otherwise
      Throws:
      eu.maveniverse.domtrip.DomTripException - if an error occurs during editing
      Since:
      0.3.0