Package eu.maveniverse.domtrip.maven
Class PomEditor.Plugins
- java.lang.Object
-
- eu.maveniverse.domtrip.maven.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.ElementaddPlugin(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.booleandeleteManagedPlugin(Coordinates coordinates)Removes a managed plugin fromproject/build/pluginManagement/plugins/plugin[].booleandeletePlugin(Coordinates coordinates)Removes a plugin fromproject/build/plugins/plugin[].booleandeletePluginVersion(Coordinates coordinates)Removes a plugin version element fromproject/build/plugins/plugin[].booleanupdateManagedPlugin(boolean upsert, Coordinates coordinates)Updates or inserts a managed plugin inproject/build/pluginManagement/plugins/plugin[].booleanupdatePlugin(boolean upsert, Coordinates coordinates)Updates or inserts a plugin inproject/build/plugins/plugin[].
-
-
-
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.DomTripExceptionAdds a plugin element with the specified coordinates.- Parameters:
pluginsElement- the plugins container elementgroupId- the plugin groupIdartifactId- the plugin artifactIdversion- 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 fromproject/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.DomTripExceptionUpdates or inserts a plugin inproject/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
upsertis 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 existcoordinates- 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 fromproject/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 fromproject/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.DomTripExceptionUpdates or inserts a managed plugin inproject/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
upsertis 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 existcoordinates- 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
-
-