All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.maveniverse.maven.toolbox.plugin.mp.TreeFindMojo Maven / Gradle / Ivy

The newest version!
/*
 * 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.ResolutionRoot;
import eu.maveniverse.maven.toolbox.shared.ResolutionScope;
import eu.maveniverse.maven.toolbox.shared.Result;
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando;
import java.util.List;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.artifact.Artifact;

/**
 * Collects paths to matched artifact, if exists.
 */
@Mojo(name = "tree-find", threadSafe = true)
public class TreeFindMojo extends MPMojoSupport {
    /**
     * The resolution scope to display, accepted values are "runtime", "compile", "test", etc.
     */
    @Parameter(property = "scope", defaultValue = "runtime", required = true)
    private String scope;

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

    /**
     * Set it {@code true} for verbose tree.
     */
    @Parameter(property = "verboseTree", defaultValue = "false", required = true)
    private boolean verboseTree;

    @Override
    protected Result>> doExecute() throws Exception {
        ToolboxCommando toolboxCommando = getToolboxCommando();
        ResolutionRoot root = projectAsResolutionRoot();
        getOutput().doTell("Paths found in project {}", root.getArtifact());
        return toolboxCommando.treeFind(
                ResolutionScope.parse(scope),
                root,
                verboseTree,
                toolboxCommando.parseArtifactMatcherSpec(artifactMatcherSpec));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy