Class PomEditor.Plugins

  • Enclosing class:
    PomEditor

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

      Constructors 
      Constructor Description
      Plugins()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      eu.maveniverse.domtrip.Element addPlugin​(eu.maveniverse.domtrip.Element pluginsElement, java.lang.String groupId, java.lang.String artifactId, java.lang.String version)
      Adds a plugin element with the specified coordinates.
      boolean deleteManagedPlugin​(Coordinates coordinates)
      Removes a managed plugin from project/build/pluginManagement/plugins/plugin[].
      boolean deletePlugin​(Coordinates coordinates)
      Removes a plugin from project/build/plugins/plugin[].
      boolean deletePluginVersion​(Coordinates coordinates)
      Removes a plugin version element from project/build/plugins/plugin[].
      boolean updateManagedPlugin​(boolean upsert, Coordinates coordinates)
      Updates or inserts a managed plugin in project/build/pluginManagement/plugins/plugin[].
      boolean updatePlugin​(boolean upsert, Coordinates coordinates)
      Updates or inserts a plugin in project/build/plugins/plugin[].
      • Methods inherited from class java.lang.Object

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

      • Plugins

        public Plugins()
    • Method Detail

      • addPlugin

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