-
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.
That are usable for example in ITs
- Loading branch information
Showing
8 changed files
with
238 additions
and
11 deletions.
There are no files selected for viewing
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
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
53 changes: 53 additions & 0 deletions
53
toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavArtifactPathMojo.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,53 @@ | ||
/* | ||
* 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.plugin.GavMojoSupport; | ||
import eu.maveniverse.maven.toolbox.shared.Result; | ||
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; | ||
import java.nio.file.Path; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.eclipse.aether.artifact.DefaultArtifact; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
import picocli.CommandLine; | ||
|
||
/** | ||
* Prints Maven Artifact path in local repository. | ||
*/ | ||
@CommandLine.Command(name = "artifact-path", description = "Prints path of Maven Artifacts in local repository") | ||
@Mojo(name = "gav-artifact-path", requiresProject = false, threadSafe = true) | ||
public class GavArtifactPathMojo extends GavMojoSupport { | ||
/** | ||
* The GAV of artifact. | ||
*/ | ||
@CommandLine.Parameters(index = "0", description = "The Artifact coordinates", arity = "1") | ||
@Parameter(property = "gav", required = true) | ||
private String gav; | ||
|
||
/** | ||
* The optional remote repository spec string. It is expected to be in form of {@code id::url}, but we are really | ||
* interested in repository ID only. | ||
*/ | ||
@CommandLine.Option( | ||
names = {"--repository"}, | ||
description = | ||
"The optional remote repository spec string. It is expected to be in form of {@code id::url}, but we are really interested in repository ID only.") | ||
@Parameter(property = "repository") | ||
private String repository; | ||
|
||
@Override | ||
protected Result<Path> doExecute() throws Exception { | ||
ToolboxCommando toolboxCommando = getToolboxCommando(); | ||
RemoteRepository rr = null; | ||
if (repository != null) { | ||
rr = toolboxCommando.parseRemoteRepository(repository); | ||
} | ||
return toolboxCommando.artifactPath(new DefaultArtifact(gav), rr); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...box/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavLocalRepositoryPathMojo.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,26 @@ | ||
/* | ||
* 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.plugin.GavMojoSupport; | ||
import eu.maveniverse.maven.toolbox.shared.Result; | ||
import java.nio.file.Path; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import picocli.CommandLine; | ||
|
||
/** | ||
* Prints Maven Local Repository path. | ||
*/ | ||
@CommandLine.Command(name = "local-repository-path", description = "Prints path of Maven Local Repository") | ||
@Mojo(name = "gav-local-repository-path", requiresProject = false, threadSafe = true) | ||
public class GavLocalRepositoryPathMojo extends GavMojoSupport { | ||
@Override | ||
protected Result<Path> doExecute() throws Exception { | ||
return getToolboxCommando().localRepository(); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavMetadataPathMojo.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,86 @@ | ||
/* | ||
* 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.plugin.GavMojoSupport; | ||
import eu.maveniverse.maven.toolbox.shared.Result; | ||
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; | ||
import java.nio.file.Path; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.eclipse.aether.metadata.DefaultMetadata; | ||
import org.eclipse.aether.metadata.Metadata; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
import picocli.CommandLine; | ||
|
||
/** | ||
* Prints Maven Metadata path in local repository. | ||
*/ | ||
@CommandLine.Command(name = "metadata-path", description = "Prints path of Maven Metadata in local repository") | ||
@Mojo(name = "gav-metadata-path", requiresProject = false, threadSafe = true) | ||
public class GavMetadataPathMojo extends GavMojoSupport { | ||
/** | ||
* The metadata coordinates in form of {@code [G]:[A]:[V]:[type]}. Absence of {@code A} implies absence of {@code V} | ||
* as well (in other words, it can be {@code G}, {@code G:A} or {@code G:A:V}). The absence of {@code type} implies | ||
* it is "maven-metadata.xml". The simplest spec string is {@code :::}. | ||
* <p> | ||
* Examples: | ||
* <ul> | ||
* <li>{@code :::} is root metadata named "maven-metadata.xml"</li> | ||
* <li>{@code :::my-metadata.xml} is root metadata named "my-metadata.xml"</li> | ||
* <li>{@code G:::} equals to {@code G:::maven-metadata.xml}</li> | ||
* <li>{@code G:A::} equals to {@code G:A::maven-metadata.xml}</li> | ||
* </ul> | ||
*/ | ||
@CommandLine.Parameters(index = "0", description = "The Metadata coordinates", arity = "1") | ||
@Parameter(property = "gav", required = true) | ||
private String gav; | ||
|
||
/** | ||
* The optional remote repository spec string. It is expected to be in form of {@code id::url}, but we are really | ||
* interested in repository ID only. | ||
*/ | ||
@CommandLine.Option( | ||
names = {"--repository"}, | ||
description = | ||
"The optional remote repository spec string. It is expected to be in form of {@code id::url}, but we are really interested in repository ID only.") | ||
@Parameter(property = "repository") | ||
private String repository; | ||
|
||
@Override | ||
protected Result<Path> doExecute() throws Exception { | ||
ToolboxCommando toolboxCommando = getToolboxCommando(); | ||
RemoteRepository rr = null; | ||
if (repository != null) { | ||
rr = toolboxCommando.parseRemoteRepository(repository); | ||
} | ||
|
||
String groupId = null; | ||
String artifactId = null; | ||
String version = null; | ||
String type = "maven-metadata.xml"; | ||
String[] elems = gav.split(":", 0); | ||
if (elems.length > 0) { | ||
groupId = elems[0]; | ||
} | ||
if (elems.length > 1) { | ||
artifactId = elems[1]; | ||
} | ||
if (elems.length > 2) { | ||
version = elems[2]; | ||
} | ||
if (elems.length > 3) { | ||
type = elems[3]; | ||
} | ||
if (elems.length > 4) { | ||
throw new IllegalArgumentException("Invalid gav: " + gav); | ||
} | ||
return toolboxCommando.metadataPath( | ||
new DefaultMetadata(groupId, artifactId, version, type, Metadata.Nature.RELEASE_OR_SNAPSHOT), rr); | ||
} | ||
} |
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