-
Notifications
You must be signed in to change notification settings - Fork 3
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
8 changed files
with
153 additions
and
27 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
maven-plugin/src/main/java/eu/maveniverse/maven/toolbox/plugin/ClasspathMojo.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,29 @@ | ||
/* | ||
* 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; | ||
|
||
import eu.maveniverse.maven.toolbox.shared.ResolutionScope; | ||
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
|
||
@Mojo(name = "classpath", threadSafe = true) | ||
public class ClasspathMojo extends ProjectMojoSupport { | ||
/** | ||
* The resolution scope to display, accepted values are "runtime", "compile", "test", etc. | ||
*/ | ||
@Parameter(property = "scope", defaultValue = "runtime", required = true) | ||
private String scope; | ||
|
||
@Override | ||
protected void doExecute(ToolboxCommando toolboxCommando) throws MojoExecutionException, MojoFailureException { | ||
toolboxCommando.classpath(ResolutionScope.parse(scope), projectAsResolutionRoot(), output); | ||
} | ||
} |
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
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
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
49 changes: 49 additions & 0 deletions
49
maven-plugin/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavClasspathMojo.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,49 @@ | ||
/* | ||
* 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.gav; | ||
|
||
import eu.maveniverse.maven.toolbox.shared.ResolutionScope; | ||
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.eclipse.aether.resolution.ArtifactDescriptorException; | ||
|
||
@Mojo(name = "gav-classpath", requiresProject = false, threadSafe = true) | ||
public class GavClasspathMojo extends GavMojoSupport { | ||
/** | ||
* The artifact coordinates in the format {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>} | ||
* to display tree for. | ||
*/ | ||
@Parameter(property = "gav", required = true) | ||
private String gav; | ||
|
||
/** | ||
* The resolution scope to display, accepted values are "runtime", "compile", "test", etc. | ||
*/ | ||
@Parameter(property = "scope", defaultValue = "runtime", required = true) | ||
private String scope; | ||
|
||
/** | ||
* Apply BOMs, if needed. | ||
*/ | ||
@Parameter(property = "boms", defaultValue = "") | ||
private java.util.List<String> boms; | ||
|
||
@Override | ||
protected void doExecute(ToolboxCommando toolboxCommando) throws MojoExecutionException, MojoFailureException { | ||
try { | ||
toolboxCommando.classpath(ResolutionScope.parse(scope), toolboxCommando.loadGav(gav, boms), output); | ||
} catch (RuntimeException e) { | ||
throw new MojoExecutionException(e); | ||
} catch (ArtifactDescriptorException e) { | ||
throw new MojoFailureException(e); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
maven-plugin/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavDumpMojo.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,19 @@ | ||
/* | ||
* 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.gav; | ||
|
||
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
|
||
@Mojo(name = "gav-dump", requiresProject = false, threadSafe = true) | ||
public class GavDumpMojo extends GavMojoSupport { | ||
@Override | ||
protected void doExecute(ToolboxCommando toolboxCommando) { | ||
toolboxCommando.dump(logger.isDebugEnabled(), output); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
maven-plugin/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavMojoSupport.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,41 @@ | ||
/* | ||
* 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.gav; | ||
|
||
import eu.maveniverse.maven.mima.context.Context; | ||
import eu.maveniverse.maven.mima.context.ContextOverrides; | ||
import eu.maveniverse.maven.mima.context.Runtime; | ||
import eu.maveniverse.maven.mima.context.Runtimes; | ||
import eu.maveniverse.maven.toolbox.shared.Output; | ||
import eu.maveniverse.maven.toolbox.shared.Slf4jOutput; | ||
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; | ||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public abstract class GavMojoSupport extends AbstractMojo { | ||
protected final Logger logger = LoggerFactory.getLogger(getClass()); | ||
protected final Output output = new Slf4jOutput(logger); | ||
|
||
@Parameter(property = "verbose", defaultValue = "false", required = true) | ||
protected boolean verbose; | ||
|
||
@Override | ||
public final void execute() throws MojoExecutionException, MojoFailureException { | ||
Runtime runtime = Runtimes.INSTANCE.getRuntime(); | ||
try (Context context = runtime.create(ContextOverrides.create().build())) { | ||
doExecute(ToolboxCommando.create(runtime, context)); | ||
} | ||
} | ||
|
||
protected abstract void doExecute(ToolboxCommando toolboxCommando) | ||
throws MojoExecutionException, MojoFailureException; | ||
} |
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