Просто создайте Pair
тип и использование что как Ваше значение.
у меня есть пример одного в моем C# подробно исходный код . Воспроизведенный здесь для простоты:
using System;
using System.Collections.Generic;
public sealed class Pair
: IEquatable>
{
private readonly TFirst first;
private readonly TSecond second;
public Pair(TFirst first, TSecond second)
{
this.first = first;
this.second = second;
}
public TFirst First
{
get { return first; }
}
public TSecond Second
{
get { return second; }
}
public bool Equals(Pair other)
{
if (other == null)
{
return false;
}
return EqualityComparer.Default.Equals(this.First, other.First) &&
EqualityComparer.Default.Equals(this.Second, other.Second);
}
public override bool Equals(object o)
{
return Equals(o as Pair);
}
public override int GetHashCode()
{
return EqualityComparer.Default.GetHashCode(first) * 37 +
EqualityComparer.Default.GetHashCode(second);
}
}
Ваш плагин должен создать артефакт, используя ArtifactFactory и groupId, artifactId и версию артефакта для начальной загрузки, затем передайте этот артефакт в ArtifactResolver для обработки обнаружения / загрузки.
Сопоставителю необходим доступ к локальному репозиторию и удаленным репозиториям. Хорошая новость заключается в том, что все это компоненты сплетения, которые вы можете объявить как зависимости в вашем Mojo и подключить их к Plexus.
В другом ответе я показал, как это сделать. В вашем случае вам нужна урезанная версия с немного другими параметрами для чтения groupId, artifactId и версии. В плагине ниже различные компоненты объявлены как компоненты сплетения, а свойства - для объявления groupId, artifactId, версии и типа упаковки.
package name.seller.rich.maven.plugins.bootstrap;
import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* Obtain the artifact defined by the groupId, artifactId, and version
* from the remote repository.
*
* @goal bootstrap
*/
public class BootstrapAppMojo extends AbstractMojo {
/**
* Used to look up Artifacts in the remote repository.
*
* @parameter expression=
* "${component.org.apache.maven.artifact.factory.ArtifactFactory}"
* @required
* @readonly
*/
protected ArtifactFactory factory;
/**
* Used to look up Artifacts in the remote repository.
*
* @parameter expression=
* "${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
* @required
* @readonly
*/
protected ArtifactResolver artifactResolver;
/**
* List of Remote Repositories used by the resolver
*
* @parameter expression="${project.remoteArtifactRepositories}"
* @readonly
* @required
*/
protected List remoteRepositories;
/**
* Location of the local repository.
*
* @parameter expression="${localRepository}"
* @readonly
* @required
*/
protected ArtifactRepository localRepository;
/**
* The target pom's artifactId
*
* @parameter expression="${bootstrapArtifactId}"
* @required
*/
private String bootstrapArtifactId;
/**
* The target pom's groupId
*
* @parameter expression="${bootstrapGroupId}"
* @required
*/
private String bootstrapGroupId;
/**
* The target pom's type
*
* @parameter expression="${bootstrapType}"
* @required
*/
private String bootstrapType;
/**
* The target pom's version
*
* @parameter expression="${bootstrapVersion}"
* @required
*/
private String bootstrapVersion;
public void execute() throws MojoExecutionException, MojoFailureException {
try {
Artifact pomArtifact = this.factory.createArtifact(
bootstrapGroupId, bootstrapArtifactId, bootstrapVersion,
"", bootstrapType);
artifactResolver.resolve(pomArtifact, this.remoteRepositories,
this.localRepository);
} catch (ArtifactResolutionException e) {
getLog().error("can't resolve parent pom", e);
} catch (ArtifactNotFoundException e) {
getLog().error("can't resolve parent pom", e);
}
}
}
Это пример pom, настроенного для использования плагина (и скачать pom аспектjrt 1.6.4) :
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>name.seller.rich</groupId>
<artifactId>bootstrap-test</artifactId>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>name.seller.rich</groupId>
<artifactId>maven-bootstrap-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bootstrap</goal>
</goals>
<configuration>
<bootstrapGroupId>org.aspectj</bootstrapGroupId>
<bootstrapArtifactId>aspectjrt</bootstrapArtifactId>
<bootstrapVersion>1.6.4</bootstrapVersion>
<bootstrapType>pom</bootstrapType>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>