Skip to content

Commit

Permalink
Adjust resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Mar 24, 2024
1 parent b8b34dc commit 8e64f4f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2023-2024 Maveniverse Org.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*/
package eu.maveniverse.maven.toolbox.plugin.mp;

import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport;
import eu.maveniverse.maven.toolbox.shared.Output;
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando;
import java.util.stream.Collectors;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.graph.Dependency;

/**
* Resolves selected dependencies.
*/
@Mojo(name = "resolve", requiresProject = false, threadSafe = true)
public class ResolveMojo extends MPMojoSupport {
/**
* The dependency matcher spec.
*/
@Parameter(property = "depSpec", required = true)
private String depSpec;

/**
* Resolve sources JAR as well (derive coordinates from GAV).
*/
@Parameter(property = "sources", defaultValue = "false")
private boolean sources;

/**
* Resolve javadoc JAR as well (derive coordinates from GAV).
*/
@Parameter(property = "javadoc", defaultValue = "false")
private boolean javadoc;

/**
* Resolve GnuPG signature as well (derive coordinates from GAV).
*/
@Parameter(property = "signature", defaultValue = "false")
private boolean signature;

@Override
protected boolean doExecute(Output output, ToolboxCommando toolboxCommando) throws Exception {
return toolboxCommando.resolve(
projectAsResolutionRoot().getDependencies().stream()
.filter(toolboxCommando.parseDependencyMatcherSpec(depSpec))
.map(Dependency::getArtifact)
.collect(Collectors.toList()),
sources,
javadoc,
signature,
output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport;
import eu.maveniverse.maven.toolbox.shared.Output;
import eu.maveniverse.maven.toolbox.shared.ResolutionRoot;
import eu.maveniverse.maven.toolbox.shared.ResolutionScope;
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando;
import java.util.Collections;
import java.util.stream.Collectors;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
* Resolves transitively given project.
* Resolves transitively selected dependencies.
*/
@Mojo(name = "resolve-transitive", requiresProject = false, threadSafe = true)
public class ResolveTransitiveMojo extends MPMojoSupport {
Expand All @@ -26,20 +27,41 @@ public class ResolveTransitiveMojo extends MPMojoSupport {
@Parameter(property = "scope", defaultValue = "runtime", required = true)
private String scope;

/**
* The dependency matcher spec.
*/
@Parameter(property = "depSpec", required = true)
private String depSpec;

/**
* Resolve sources JAR as well (derive coordinates from GAV).
*/
@Parameter(property = "sources", defaultValue = "false")
private boolean sources;

/**
* Resolve javadoc JAR as well (derive coordinates from GAV).
*/
@Parameter(property = "javadoc", defaultValue = "false")
private boolean javadoc;

/**
* Resolve GnuPG signature as well (derive coordinates from GAV).
*/
@Parameter(property = "signature", defaultValue = "false")
private boolean signature;

@Override
protected boolean doExecute(Output output, ToolboxCommando toolboxCommando) throws Exception {
ResolutionRoot project = projectAsResolutionRoot();
return toolboxCommando.resolveTransitive(
ResolutionScope.parse(scope),
Collections.singleton(projectAsResolutionRoot()),
projectAsResolutionRoot().getDependencies().stream()
.filter(toolboxCommando.parseDependencyMatcherSpec(depSpec))
.map(d -> ResolutionRoot.ofLoaded(d.getArtifact())
.withManagedDependencies(project.getManagedDependencies())
.build())
.collect(Collectors.toList()),
sources,
javadoc,
signature,
Expand Down

0 comments on commit 8e64f4f

Please sign in to comment.