-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/PluginTreeFindMojo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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.MPPluginMojoSupport; | ||
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 org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
|
||
/** | ||
* Collects paths to matched artifact from plugins, if exists. | ||
*/ | ||
@Mojo(name = "plugin-tree-find", threadSafe = true) | ||
public class PluginTreeFindMojo extends MPPluginMojoSupport { | ||
/** | ||
* 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 boolean doExecute(Output output, ToolboxCommando toolboxCommando) throws Exception { | ||
ResolutionRoot root = pluginAsResolutionRoot(toolboxCommando, false); | ||
if (root != null) { | ||
return toolboxCommando.treeFind( | ||
ResolutionScope.parse(scope), | ||
root, | ||
verboseTree, | ||
toolboxCommando.parseArtifactMatcherSpec(artifactMatcherSpec), | ||
output); | ||
} else { | ||
boolean result = true; | ||
for (ResolutionRoot resolutionRoot : allPluginsAsResolutionRoots(toolboxCommando)) { | ||
result = result | ||
&& toolboxCommando.treeFind( | ||
ResolutionScope.parse(scope), | ||
resolutionRoot, | ||
verboseTree, | ||
toolboxCommando.parseArtifactMatcherSpec(artifactMatcherSpec), | ||
output); | ||
output.normal(""); | ||
} | ||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters