Class PomEditor.Extensions

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

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

    • Extensions

      public Extensions()
  • Method Details

    • addExtension

      public eu.maveniverse.domtrip.Element addExtension(eu.maveniverse.domtrip.Element extensionsElement, String groupId, String artifactId, String version) throws eu.maveniverse.domtrip.DomTripException
      Adds a extension element with the specified coordinates.
      Parameters:
      extensionsElement - the extensions container element
      groupId - the extension groupId
      artifactId - the extension artifactId
      version - the extension version
      Returns:
      the newly created extension element
      Throws:
      eu.maveniverse.domtrip.DomTripException - if the plugin cannot be added
    • updateExtension

      public boolean updateExtension(boolean upsert, Coordinates coordinates) throws eu.maveniverse.domtrip.DomTripException
      Updates or inserts an extension in project/build/extensions/extension[].

      If the extension 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 myExtension = Coordinates.of("org.apache.maven.extensions", "some-extension", "1.11.0");
      editor.updateExtension(true, myExtension);
      
      Parameters:
      upsert - whether to create the extension if it doesn't exist
      coordinates - the artifact coordinates
      Returns:
      true if the extension was updated or created, false otherwise
      Throws:
      eu.maveniverse.domtrip.DomTripException - if an error occurs during editing
      Since:
      0.3.1
    • deleteExtension

      public boolean deleteExtension(Coordinates coordinates) throws eu.maveniverse.domtrip.DomTripException
      Removes an extension from project/build/extensions/extension[].

      Example:

      PomEditor editor = new PomEditor(document);
      Coordinates myExtension = Coordinates.of("org.apache.maven.extension", "my-extension", "1.11.0");
      editor.deleteExtension(myExtension);
      
      Parameters:
      coordinates - the artifact to remove (matched by GA)
      Returns:
      true if the extension was removed, false if it didn't exist
      Throws:
      eu.maveniverse.domtrip.DomTripException
      Since:
      0.3.1