Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ public static void deletePlugin(Element project, Artifact a) {
}
}

public static void deletePluginVersion(Element project, Artifact a) {
if (project != null) {
Element plugins = project.getChild("plugins", project.getNamespace());
if (plugins != null) {
for (Element plugin : plugins.getChildren("plugin", plugins.getNamespace())) {
if (equalsGA(a, plugin)) {
Element version = plugin.getChild("version", plugin.getNamespace());
JDomUtils.removeChildAndItsCommentFromContent(plugin, version);
}
}
}
}
}

public static void updateManagedDependency(Element project, Artifact a, boolean upsert) {
if (project != null) {
Element dependencyManagement = project.getChild("dependencyManagement", project.getNamespace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static Function<Artifact, Consumer<TransformationContext>> deletePlugin()
};
}

public static Function<Artifact, Consumer<TransformationContext>> deletePluginVersion() {
return a -> context -> {
JDomPomEditor.deletePluginVersion(context.getDocument().getRootElement(), a);
};
}

public static Function<Artifact, Consumer<TransformationContext>> updateManagedDependency(boolean upsert) {
return a -> context ->
JDomPomEditor.updateManagedDependency(context.getDocument().getRootElement(), a, upsert);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import eu.maveniverse.maven.toolbox.shared.ResolutionRoot;
import eu.maveniverse.maven.toolbox.shared.Result;
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando;
import eu.maveniverse.maven.toolbox.shared.internal.jdom.JDomPomTransformer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -105,6 +107,17 @@ protected Result<Boolean> doExecute() throws Exception {
ToolboxCommando.Op.UPSERT,
pluginsUpdates::stream);
}
for (MavenProject project : mavenSession.getProjects()) {
try (ToolboxCommando.EditSession editSession =
toolboxCommando.createEditSession(project.getFile().toPath())) {
toolboxCommando.doEdit(
editSession,
pluginsUpdates.stream()
.map(a -> JDomPomTransformer.deletePluginVersion()
.apply(a))
.collect(Collectors.toList()));
}
}
}
}
return Result.success(true);
Expand Down
Loading