Class PomEditor.Extensions

  • Enclosing class:
    PomEditor

    public class PomEditor.Extensions
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Extensions()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      eu.maveniverse.domtrip.Element addExtension​(eu.maveniverse.domtrip.Element extensionsElement, java.lang.String groupId, java.lang.String artifactId, java.lang.String version)
      Adds a extension element with the specified coordinates.
      boolean deleteExtension​(Coordinates coordinates)
      Removes an extension from project/build/extensions/extension[].
      boolean updateExtension​(boolean upsert, Coordinates coordinates)
      Updates or inserts an extension in project/build/extensions/extension[].
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Extensions

        public Extensions()
    • Method Detail

      • addExtension

        public eu.maveniverse.domtrip.Element addExtension​(eu.maveniverse.domtrip.Element extensionsElement,
                                                           java.lang.String groupId,
                                                           java.lang.String artifactId,
                                                           java.lang.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