-
Notifications
You must be signed in to change notification settings - Fork 5
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
76 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
maven-plugin/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavListMojo.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,32 @@ | ||
/* | ||
* 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 java.io.IOException; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
|
||
@Mojo(name = "gav-list", requiresProject = false, threadSafe = true) | ||
public class GavListMojo extends GavSearchMojoSupport { | ||
/** | ||
* The "gavoid" part to list. | ||
*/ | ||
@Parameter(property = "gavoid", required = true) | ||
private String gavoid; | ||
|
||
@Override | ||
protected void doExecute(ToolboxCommando toolboxCommando) throws MojoExecutionException { | ||
try { | ||
toolboxCommando.list(getRemoteRepository(toolboxCommando), gavoid, output); | ||
} catch (IOException e) { | ||
throw new MojoExecutionException(e); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
maven-plugin/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavSearchMojoSupport.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,44 @@ | ||
/* | ||
* 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.Parameter; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
|
||
public abstract class GavSearchMojoSupport extends GavMojoSupport { | ||
/** | ||
* A repository ID. Maybe a "well known" one, or if all repository data given, a new one. | ||
*/ | ||
@Parameter(property = "repositoryId", defaultValue = "central") | ||
protected String repositoryId; | ||
|
||
/** | ||
* The base URI of the remote repository. | ||
*/ | ||
@Parameter(property = "repositoryBaseUri") | ||
protected String repositoryBaseUri; | ||
|
||
/** | ||
* The vendor of the remote repository. | ||
*/ | ||
@Parameter(property = "repositoryVendor") | ||
private String repositoryVendor; | ||
|
||
protected RemoteRepository getRemoteRepository(ToolboxCommando toolboxCommando) { | ||
RemoteRepository remoteRepository = | ||
toolboxCommando.getKnownRemoteRepositories().get(repositoryId); | ||
if (remoteRepository != null) { | ||
return remoteRepository; | ||
} | ||
if (repositoryBaseUri == null && repositoryVendor == null) { | ||
throw new IllegalArgumentException("for new remote repository one must specify all information"); | ||
} | ||
return new RemoteRepository.Builder(repositoryId, repositoryVendor, repositoryBaseUri).build(); | ||
} | ||
} |