本文整理汇总了Java中org.apache.maven.artifact.resolver.ArtifactResolutionRequest类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactResolutionRequest类的具体用法?Java ArtifactResolutionRequest怎么用?Java ArtifactResolutionRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactResolutionRequest类属于org.apache.maven.artifact.resolver包,在下文中一共展示了ArtifactResolutionRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadSourcesDependency
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
private void loadSourcesDependency(JavaProjectBuilder javaDocBuilder, Artifact sourcesArtifact) {
// create request
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(sourcesArtifact);
// resolve deps
ArtifactResolutionResult result = repositorySystem.resolve(request);
// load source file into javadoc builder
result.getArtifacts().forEach(artifact -> {
try {
JarFile jarFile = new JarFile(artifact.getFile());
for (Enumeration entries = jarFile.entries(); entries.hasMoreElements(); ) {
JarEntry entry = (JarEntry) entries.nextElement();
String name = entry.getName();
if (name.endsWith(".java") && !name.endsWith("/package-info.java")) {
javaDocBuilder.addSource(new URL("jar:" + artifact.getFile().toURI().toURL().toString() + "!/" + name));
}
}
} catch (Exception e) {
getLog().warn("Unable to load jar source " + artifact + " : " + e.getMessage());
}
});
}
开发者ID:jboz,项目名称:living-documentation,代码行数:25,代码来源:AbstractGlossaryMojo.java
示例2: resolveArtifactTransitively
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
private Set<Artifact> resolveArtifactTransitively( final Artifact artifact ) {
final ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( artifact ).setResolveRoot( true ).setResolveTransitively( true )
.setRemoteRepositories( this.remoteArtifactRepositories ).setLocalRepository( this.localRepository );
if( this.excludeOptionalDependencies ){
request.setCollectionFilter( OptionalArtifactFilter.INSTANCE );
}
final ArtifactResolutionResult result = this.resolver.resolve( request );
if( !result.isSuccess() ){
for( Artifact missing : result.getMissingArtifacts() ){
getLog().error( String.format( "Could not resolve artifact: [%s]", missing ) );
}
if( result.hasExceptions() && getLog().isDebugEnabled() ){
for( Exception exception : result.getExceptions() ){
getLog().debug( exception );
}
}
}
final Set<Artifact> dependencies = result.getArtifacts();
return dependencies;
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:21,代码来源:AbstractFitNesseMojo.java
示例3: testOneDependencyOneArtifact
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testOneDependencyOneArtifact() throws MojoExecutionException {
Artifact g1a1 = helper.createArtifact( "g1", "a1" );
List<Artifact> artifacts = asList( helper.fitnesseArtifact, g1a1 );
helper.plugin.addDependency( createDependecy( "g1", "a1" ) );
helper.mojo.pluginDescriptor.setArtifacts( artifacts );
when( helper.artifactResolver.resolve( any( ArtifactResolutionRequest.class ) ) ).thenReturn( helper.createArtifactResolutionResult( helper.fitnesseArtifact ) )
.thenReturn( helper.createArtifactResolutionResult( g1a1 ) );
assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
assertEquals( USING_PLUGIN_CONFIG, helper.logStream.toString() );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( helper.fitnesseArtifact ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a1 ) );
helper.classRealmAssertions( 2 );
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:21,代码来源:CalcWikiFormatClasspathTest.java
示例4: testOneDependencyTwoArtifacts
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testOneDependencyTwoArtifacts() throws MojoExecutionException {
Artifact g1a1 = helper.createArtifact( "g1", "a1" );
Artifact g1a2 = helper.createArtifact( "g1", "a2" );
List<Artifact> artifacts = asList( helper.fitnesseArtifact, g1a1 );
helper.plugin.addDependency( createDependecy( "g1", "a1" ) );
helper.mojo.pluginDescriptor.setArtifacts( artifacts );
when( helper.artifactResolver.resolve( any( ArtifactResolutionRequest.class ) ) ).thenReturn( helper.createArtifactResolutionResult( helper.fitnesseArtifact ) )
.thenReturn( helper.createArtifactResolutionResult( asList( g1a1, g1a2 ) ) );
assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
assertEquals( USING_PLUGIN_CONFIG, helper.logStream.toString() );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( helper.fitnesseArtifact ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a1 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a2 ) );
helper.classRealmAssertions( 3 );
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:23,代码来源:CalcWikiFormatClasspathTest.java
示例5: testTwoDependenciesTwoArtifacts
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testTwoDependenciesTwoArtifacts() throws MojoExecutionException {
Artifact g1a1 = helper.createArtifact( "g1", "a1" );
Artifact g2a1 = helper.createArtifact( "g2", "a1" );
List<Artifact> artifacts = asList( helper.fitnesseArtifact, g1a1, g2a1 );
helper.plugin.addDependency( createDependecy( "g1", "a1" ) );
helper.plugin.addDependency( createDependecy( "g2", "a1" ) );
helper.mojo.pluginDescriptor.setArtifacts( artifacts );
when( helper.artifactResolver.resolve( any( ArtifactResolutionRequest.class ) ) ).thenReturn( helper.createArtifactResolutionResult( helper.fitnesseArtifact ) )
.thenReturn( helper.createArtifactResolutionResult( g1a1 ) ).thenReturn( helper.createArtifactResolutionResult( g2a1 ) );
assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
assertEquals( USING_PLUGIN_CONFIG, helper.logStream.toString() );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( helper.fitnesseArtifact ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a1 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g2a1 ) );
helper.classRealmAssertions( 3 );
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:24,代码来源:CalcWikiFormatClasspathTest.java
示例6: addDependency
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
private void addDependency( String groupId, String artifactId, String scope, boolean optional ) {
final Artifact artifact = createArtifact( groupId, artifactId );
artifact.setOptional( optional );
artifact.setScope( scope );
if( !optional ){
this.mojo.project.getArtifacts().add( artifact );
}
this.mojo.project.getDependencies().add( createDependecy( groupId, artifactId, scope ) );
this.mojo.project.getDependencyArtifacts().add( artifact );
final ResolutionRequestForArtifact requestMatcher = new ResolutionRequestForArtifact( artifact );
when( this.artifactResolver.resolve( argThat( requestMatcher ) ) ).thenAnswer( new Answer<ArtifactResolutionResult>() {
@Override
public ArtifactResolutionResult answer( InvocationOnMock invocation ) throws Throwable {
ArtifactResolutionRequest request = (ArtifactResolutionRequest) invocation.getArguments()[0];
if( requestMatcher.matches( request ) ){
return createArtifactResolutionResult( artifact, request.getCollectionFilter() );
}
// Should never happen?
return null;
}
} );
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:23,代码来源:FitNesseMojoTestHelper.java
示例7: resolve
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
public Set<Artifact> resolve(String groupId, String artifactId, String version, final String exclusion)
throws MojoExecutionException {
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setResolveTransitively(true)
.setResolveRoot(true)
.setArtifact(system.createArtifact(groupId, artifactId, version, "jar"))
.setLocalRepository(this.localRepo)
.setRemoteRepositories(remoteRepos).setCollectionFilter(new ArtifactFilter() {
@Override
public boolean include(Artifact artifact) {
if (exclusion != null &&
(artifact.getGroupId() + ":" + artifact.getArtifactId()).equals(exclusion)) {
return false;
}
return artifact.getScope() == null || artifact.getScope().equals("compile") || artifact.getScope().equals("runtime");
}
});
ArtifactResolutionResult result = system.resolve(request);
// TODO error handling
return result.getArtifacts();
}
开发者ID:torquebox,项目名称:jruby9-maven-plugins,代码行数:24,代码来源:ArtifactHelper.java
示例8: getPluginTransitiveDependencies
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
/**
* Read transitive dependencies of given plugin and store them in map.
*
* @param plugin
* plugin to read
* @param map
* map, where founded transitive dependencies will be stored
* @param repoSystem
* repository system
* @param localRepository
* local repository
* @param remoteRepos
* list of remote repositories
*/
private static void getPluginTransitiveDependencies(final Plugin plugin,
final Map<Artifact, Collection<Artifact>> map, final RepositorySystem repoSystem,
final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepos) {
List<Dependency> pluginDependencies = plugin.getDependencies();
for (Dependency dep : pluginDependencies) {
Artifact artifact = repoSystem.createDependencyArtifact(dep);
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setResolveTransitively(true);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(remoteRepos);
ArtifactResolutionResult result = repoSystem.resolve(request);
Set<Artifact> pluginDependencyDependencies = result.getArtifacts();
map.put(artifact, pluginDependencyDependencies);
}
}
开发者ID:opendaylight,项目名称:yangtools,代码行数:34,代码来源:Util.java
示例9: getPomArtifacts
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
/**
* Create Artifact objects for all pom files corresponding to the artifacts that you send in.
*
* @param artifacts
* Set of artifacts to obtain pom's for
*
* @return Artifacts for all the pom files
*/
private Set<Artifact> getPomArtifacts(Set<Artifact> artifacts)
throws MojoExecutionException {
Set<Artifact> poms = new HashSet<>();
for (Artifact artifact : artifacts) {
if (shouldSkipArtifact(artifact)) {
continue;
}
ArtifactResolutionRequest rreq = getArtifactResolutionRequestForPom(artifact);
ArtifactResolutionResult result = repositorySystem.resolve(rreq);
if (result.isSuccess()) {
poms.add(rreq.getArtifact());
} else {
getLog().warn("No pom for " + artifact.getId());
}
}
return poms;
}
开发者ID:s4u,项目名称:pgpverify-maven-plugin,代码行数:30,代码来源:PGPVerifyMojo.java
示例10: resolveAscArtifact
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
/**
* Retrieves the PGP signature file that corresponds to the given Maven artifact.
*
* @param artifact
* The artifact for which a signature file is desired.
* @return Either a Maven artifact for the signature file, or {@code null} if the signature
* file could not be retrieved.
*
* @throws MojoExecutionException
* If the signature could not be retrieved and the Mojo has been configured to fail
* on a missing signature.
*/
private Artifact resolveAscArtifact(Artifact artifact) throws MojoExecutionException {
Artifact ascArtifact = null;
if (!shouldSkipArtifact(artifact)) {
final ArtifactResolutionRequest ascReq = getArtifactResolutionRequestForAsc(artifact);
final ArtifactResolutionResult ascResult = repositorySystem.resolve(ascReq);
if (ascResult.isSuccess()) {
ascArtifact = ascReq.getArtifact();
getLog().debug(ascArtifact.toString() + " " + ascArtifact.getFile());
} else {
if (failNoSignature) {
getLog().error("No signature for " + artifact.getId());
throw new MojoExecutionException("No signature for " + artifact.getId());
} else {
getLog().warn("No signature for " + artifact.getId());
}
}
}
return ascArtifact;
}
开发者ID:s4u,项目名称:pgpverify-maven-plugin,代码行数:36,代码来源:PGPVerifyMojo.java
示例11: getArtifactResolutionRequestForAsc
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
/**
* Create ArtifactResolutionRequest for asc file corresponding to artifact.
*
* @param artifact artifact
* @return new ArtifactResolutionRequest
*/
private ArtifactResolutionRequest getArtifactResolutionRequestForAsc(Artifact artifact) {
Artifact aAsc = repositorySystem.createArtifactWithClassifier(
artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
artifact.getType(), artifact.getClassifier());
ArtifactResolutionRequest rreq = new ArtifactResolutionRequest();
aAsc.setArtifactHandler(new AscArtifactHandler(aAsc));
rreq.setArtifact(aAsc);
rreq.setResolveTransitively(false);
rreq.setLocalRepository(localRepository);
rreq.setRemoteRepositories(pomRemoteRepositories);
return rreq;
}
开发者ID:s4u,项目名称:pgpverify-maven-plugin,代码行数:23,代码来源:PGPVerifyMojo.java
示例12: collect
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers )
{
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setLocalRepository( localRepository );
request.setRemoteRepositories( remoteRepositories );
injectSession( request );
return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners,
conflictResolvers );
}
开发者ID:gems-uff,项目名称:oceano,代码行数:15,代码来源:DefaultLegacyArtifactCollector.java
示例13: testSimple
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testSimple() throws MojoFailureException {
JApiCmpMojo mojo = new JApiCmpMojo();
Version oldVersion = createVersion("groupId", "artifactId", "0.1.0");
Version newVersion = createVersion("groupId", "artifactId", "0.1.1");
PluginParameters pluginParameters = new PluginParameters(null, newVersion, oldVersion, new Parameter(), null, Optional.of(Paths.get(System.getProperty("user.dir"), "target", "simple").toFile()), Optional.<String>absent(), true, null, null, null, null);
ArtifactResolver artifactResolver = mock(ArtifactResolver.class);
ArtifactResolutionResult artifactResolutionResult = mock(ArtifactResolutionResult.class);
Set<Artifact> artifactSet = new HashSet<>();
Artifact resolvedArtifact = mock(Artifact.class);
artifactSet.add(resolvedArtifact);
when(resolvedArtifact.getFile()).thenReturn(Paths.get(System.getProperty("user.dir"), "target", "guava-18.0.jar").toFile());
when(artifactResolutionResult.getArtifacts()).thenReturn(artifactSet);
when(artifactResolver.resolve(Matchers.<ArtifactResolutionRequest>anyObject())).thenReturn(artifactResolutionResult);
ArtifactFactory artifactFactory = mock(ArtifactFactory.class);
when(artifactFactory.createArtifactWithClassifier(eq("groupId"), eq("artifactId"), eq("0.1.1"), anyString(), anyString())).thenReturn(mock(Artifact.class));
MavenParameters mavenParameters = new MavenParameters(new ArrayList<ArtifactRepository>(), artifactFactory, mock(ArtifactRepository.class), artifactResolver, mock(MavenProject.class), mock(MojoExecution.class), "0.0.1", mock(ArtifactMetadataSource.class));
mojo.executeWithParameters(pluginParameters, mavenParameters);
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", "japicmp.diff")), is(true));
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", "japicmp.xml")), is(true));
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", "japicmp.html")), is(true));
}
开发者ID:siom79,项目名称:japicmp,代码行数:23,代码来源:JApiCmpMojoTest.java
示例14: testIgnoreMissingVersions
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testIgnoreMissingVersions() throws MojoFailureException, IOException {
JApiCmpMojo mojo = new JApiCmpMojo();
Version oldVersion = createVersion("groupId", "artifactId", "0.1.0");
Version newVersion = createVersion("groupId", "artifactId", "0.1.1");
Parameter parameterParam = new Parameter();
parameterParam.setIgnoreMissingNewVersion("true");
parameterParam.setIgnoreMissingOldVersion("true");
PluginParameters pluginParameters = new PluginParameters(null, newVersion, oldVersion, parameterParam, null, Optional.of(Paths.get(System.getProperty("user.dir"), "target", "simple").toFile()), Optional.<String>absent(), true, null, null, null, null);
ArtifactResolver artifactResolver = mock(ArtifactResolver.class);
ArtifactResolutionResult artifactResolutionResult = mock(ArtifactResolutionResult.class);
Set<Artifact> artifactSet = new HashSet<>();
when(artifactResolutionResult.getArtifacts()).thenReturn(artifactSet);
when(artifactResolver.resolve(Matchers.<ArtifactResolutionRequest>anyObject())).thenReturn(artifactResolutionResult);
ArtifactFactory artifactFactory = mock(ArtifactFactory.class);
when(artifactFactory.createArtifactWithClassifier(eq("groupId"), eq("artifactId"), eq("0.1.1"), anyString(), anyString())).thenReturn(mock(Artifact.class));
MojoExecution mojoExecution = mock(MojoExecution.class);
String executionId = "ignoreMissingVersions";
when(mojoExecution.getExecutionId()).thenReturn(executionId);
MavenParameters mavenParameters = new MavenParameters(new ArrayList<ArtifactRepository>(), artifactFactory, mock(ArtifactRepository.class), artifactResolver, mock(MavenProject.class), mojoExecution, "0.0.1", mock(ArtifactMetadataSource.class));
mojo.executeWithParameters(pluginParameters, mavenParameters);
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", executionId + ".diff")), is(false));
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", executionId + ".xml")), is(false));
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", executionId + ".html")), is(false));
}
开发者ID:siom79,项目名称:japicmp,代码行数:26,代码来源:JApiCmpMojoTest.java
示例15: resolve
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
public Set<Artifact> resolve(MavenProject project, Artifact artifact) throws MavenExecutionException {
Set<Artifact> artifacts = new HashSet<>();
ArtifactResolutionRequest artifactResolutionRequest = new ArtifactResolutionRequest();
artifactResolutionRequest.setResolveTransitively(true);
artifactResolutionRequest.setRemoteRepositories(project.getRemoteArtifactRepositories());
artifactResolutionRequest.setLocalRepository(project.getProjectBuildingRequest().getLocalRepository());
artifactResolutionRequest.setArtifact(artifact);
ArtifactResolutionResult artifactResolutionResult = mavenRepoSystem.resolve(artifactResolutionRequest);
artifactResolutionResult.getArtifacts().stream()
.peek(d -> { if (Flag.verbose()) logger.info("RESOLVED '{}' FROM '{}'", d, artifact); })
.filter(d -> "jar".equals(d.getType()))
.filter(d -> "compile".equals(d.getScope()) || "provided".equals(d.getScope()) || "runtime".equals(d.getScope()))
.forEach(d -> artifacts.add(d));
return artifacts;
}
开发者ID:commsen,项目名称:EM,代码行数:16,代码来源:Dependencies.java
示例16: resolve
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
/**
*
* @param sources
* @param remoteRepositories - these instances need to be properly mirrored and proxied. Either by creating via EmbedderFactory.createRemoteRepository()
* or by using instances from MavenProject
* @param localRepository
* @throws ArtifactResolutionException
* @throws ArtifactNotFoundException
*/
public void resolve(Artifact sources, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException {
setUpLegacySupport();
ArtifactResolutionRequest req = new ArtifactResolutionRequest();
req.setLocalRepository(localRepository);
req.setRemoteRepositories(remoteRepositories);
req.setArtifact(sources);
req.setOffline(isOffline());
ArtifactResolutionResult result = repositorySystem.resolve(req);
normalizePath(sources);
// XXX check result for exceptions and throw them now?
for (Exception ex : result.getExceptions()) {
LOG.log(Level.FINE, null, ex);
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:MavenEmbedder.java
示例17: testMultiDependenciesManyArtifactsEach
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testMultiDependenciesManyArtifactsEach() throws MojoExecutionException {
Artifact g1a1 = helper.createArtifact( "g1", "a1" );
Artifact g1a2 = helper.createArtifact( "g1", "a2" );
Artifact g1a3 = helper.createArtifact( "g1", "a3" );
Artifact g2a1 = helper.createArtifact( "g2", "a1" );
Artifact g3a1 = helper.createArtifact( "g3", "a1" );
Artifact g3a2 = helper.createArtifact( "g3", "a2" );
Artifact g3a3 = helper.createArtifact( "g3", "a3" );
Artifact g3a4 = helper.createArtifact( "g3", "a4" );
Artifact g3a5 = helper.createArtifact( "g3", "a5" );
List<Artifact> artifacts = asList( helper.fitnesseArtifact, g1a1, g2a1, g3a3 );
helper.plugin.addDependency( createDependecy( "g1", "a1" ) );
helper.plugin.addDependency( createDependecy( "g2", "a1" ) );
helper.plugin.addDependency( createDependecy( "g3", "a3" ) );
helper.mojo.pluginDescriptor.setArtifacts( artifacts );
when( helper.artifactResolver.resolve( any( ArtifactResolutionRequest.class ) ) ).thenReturn( helper.createArtifactResolutionResult( helper.fitnesseArtifact ) )
.thenReturn( helper.createArtifactResolutionResult( asList( g1a1, g1a2, g1a3 ) ) ).thenReturn( helper.createArtifactResolutionResult( asList( g2a1 ) ) )
.thenReturn( helper.createArtifactResolutionResult( asList( g3a1, g3a2, g3a3, g3a4, g3a5 ) ) );
assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
assertEquals( USING_PLUGIN_CONFIG, helper.logStream.toString() );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( helper.fitnesseArtifact ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a1 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a2 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a3 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g2a1 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a1 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a2 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a3 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a4 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a5 ) );
helper.classRealmAssertions( 10 );
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:40,代码来源:CalcWikiFormatClasspathTest.java
示例18: testWithoutDependecyAddedToPluginArtifactsAreNotResolved
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testWithoutDependecyAddedToPluginArtifactsAreNotResolved() throws MojoExecutionException {
Artifact g1a1 = helper.createArtifact( "g1", "a1" );
Artifact g1a2 = helper.createArtifact( "g1", "a2" );
Artifact g1a3 = helper.createArtifact( "g1", "a3" );
Artifact g2a1 = helper.createArtifact( "g2", "a1" );
Artifact g3a1 = helper.createArtifact( "g3", "a1" );
Artifact g3a2 = helper.createArtifact( "g3", "a2" );
Artifact g3a3 = helper.createArtifact( "g3", "a3" );
Artifact g3a4 = helper.createArtifact( "g3", "a4" );
Artifact g3a5 = helper.createArtifact( "g3", "a5" );
List<Artifact> artifacts = asList( helper.fitnesseArtifact, g1a1, g2a1, g3a3 );
helper.plugin.addDependency( createDependecy( "g1", "a1" ) );
helper.plugin.addDependency( createDependecy( "g2", "a1" ) );
// g3 is not added as a dependency
helper.mojo.pluginDescriptor.setArtifacts( artifacts );
when( helper.artifactResolver.resolve( any( ArtifactResolutionRequest.class ) ) ).thenReturn( helper.createArtifactResolutionResult( helper.fitnesseArtifact ) )
.thenReturn( helper.createArtifactResolutionResult( asList( g1a1, g1a2, g1a3 ) ) ).thenReturn( helper.createArtifactResolutionResult( asList( g2a1 ) ) )
.thenReturn( helper.createArtifactResolutionResult( asList( g3a1, g3a2, g3a3, g3a4, g3a5 ) ) );
assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
assertEquals( USING_PLUGIN_CONFIG, helper.logStream.toString() );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( helper.fitnesseArtifact ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a1 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a2 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a3 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g2a1 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a1 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a2 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a3 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a4 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a5 ) );
helper.classRealmAssertions( 5 );
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:41,代码来源:CalcWikiFormatClasspathTest.java
示例19: testMissingArtifacts
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
@Test
public void testMissingArtifacts() throws MojoExecutionException {
Artifact g1a1 = helper.createArtifact( "g1", "a1" );
Artifact g1a2 = helper.createArtifact( "g1", "a2" );
Artifact g1a3 = helper.createArtifact( "g1", "a3" );
Artifact g2a1 = helper.createArtifact( "g2", "a1" );
Artifact g3a1 = helper.createArtifact( "g3", "a1" );
Artifact g3a2 = helper.createArtifact( "g3", "a2" );
Artifact g3a3 = helper.createArtifact( "g3", "a3" );
Artifact g3a4 = helper.createArtifact( "g3", "a4" );
Artifact g3a5 = helper.createArtifact( "g3", "a5" );
List<Artifact> artifacts = asList( helper.fitnesseArtifact, g1a1, g2a1, g3a3 );
helper.plugin.addDependency( createDependecy( "g1", "a1" ) );
helper.plugin.addDependency( createDependecy( "g2", "a1" ) );
helper.plugin.addDependency( createDependecy( "g3", "a3" ) );
helper.mojo.pluginDescriptor.setArtifacts( artifacts );
when( helper.artifactResolver.resolve( any( ArtifactResolutionRequest.class ) ) ).thenReturn( helper.createArtifactResolutionResult( helper.fitnesseArtifact ) )
.thenReturn( helper.createArtifactResolutionResult( asList( g1a1, g1a3 ), asList( g1a2 ) ) ).thenReturn( helper.createArtifactResolutionResult( asList( g2a1 ) ) )
.thenReturn( helper.createArtifactResolutionResult( asList( g3a1, g3a3, g3a4 ), asList( g3a2, g3a5 ) ) );
assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
assertEquals( format( USING_PLUGIN_CONFIG + "[ERROR] Could not resolve artifact: [g1:a2:jar:1.0.0:compile]%n" + "[ERROR] Could not resolve artifact: [g3:a2:jar:1.0.0:compile]%n"
+ "[ERROR] Could not resolve artifact: [g3:a5:jar:1.0.0:compile]%n" ), helper.logStream.toString() );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( helper.fitnesseArtifact ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a1 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a2 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g1a3 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g2a1 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a1 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a2 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a3 ) );
verify( helper.mojo.fitNesseHelper, times( 1 ) ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a4 ) );
verify( helper.mojo.fitNesseHelper, never() ).formatAndAppendClasspathArtifact( any( StringBuilder.class ), eq( g3a5 ) );
helper.classRealmAssertions( 7 );
}
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:41,代码来源:CalcWikiFormatClasspathTest.java
示例20: resolveDependency
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; //导入依赖的package包/类
private void resolveDependency(Dependency dep,
TreeSet<File> includes,
File workingDir,
Set<Artifact> resolvedArtifacts) throws MojoFailureException, MojoExecutionException {
Artifact artifact = repositorySystem.createDependencyArtifact(dep);
// Avoid resolving stuff we already have resolved.
if (resolvedArtifacts.contains(artifact)) {
return;
}
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setLocalRepository(localRepository);
request.setRemoteRepositories(remoteRepositories);
request.setManagedVersionMap(project.getManagedVersionMap());
request.setResolveTransitively(false);
request.setArtifact(artifact);
ArtifactResolutionResult result = artifactResolver.resolve(request);
boolean found = false;
for (Artifact resolved : result.getArtifacts()) {
if (artifact.equals(resolved)) {
resolvedArtifacts.add(resolved);
addDependencyInclude(workingDir, includes, resolved);
found = true;
break;
}
}
if (!found) {
throw new MojoFailureException("Unable to resolve providence dependency: " +
artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" +
artifact.getVersion() + ":" + artifact.getClassifier());
}
}
开发者ID:morimekta,项目名称:providence,代码行数:36,代码来源:BaseGenerateSourcesMojo.java
注:本文中的org.apache.maven.artifact.resolver.ArtifactResolutionRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论