in core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/ResolveOneDependencyMojo.java [117:169]
public void execute() throws MojoExecutionException {
Artifact projectArtifact = project.getArtifact();
if (projectArtifact == null) {
projectArtifact = artifactFactory.createProjectArtifact(
project.getGroupId(), project.getArtifactId(), project.getVersion());
}
Set depArtifacts = new HashSet();
Artifact artifact =
artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
depArtifacts.add(artifact);
ScopeArtifactFilter scopeFilter = new ScopeArtifactFilter(scope);
ArtifactResolutionResult result;
try {
result = resolver.resolveTransitively(
depArtifacts,
projectArtifact,
project.getManagedVersionMap(),
session.getLocalRepository(),
project.getRemoteArtifactRepositories(),
metadataSource,
scopeFilter);
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException("RESOLVE-ONE-DEPENDENCY ArtifactResolutionException exception ", e);
} catch (ArtifactNotFoundException e) {
throw new MojoExecutionException("RESOLVE-ONE-DEPENDENCY ArtifactNotFoundException exception ", e);
}
if (result == null) {
getLog().info("RESOLVE-ONE-DEPENDENCY null result");
} else {
Set resolvedArtifacts = result.getArtifacts();
/*
* Assume that the user of this is not interested in transitive deps and such, just report the one.
*/
for (Object resolvedArtifact : resolvedArtifacts) {
Artifact a = (Artifact) resolvedArtifact;
if (a.equals(artifact)) {
File file = a.getFile();
if (file == null) {
getLog().info(" RESOLVE-ONE-DEPENDENCY " + a.toString() + " $ NO-FILE");
} else {
getLog().info(" RESOLVE-ONE-DEPENDENCY " + a.toString() + " $ " + file.getAbsolutePath());
}
return;
}
}
getLog().info(" RESOLVE-ONE-DEPENDENCY " + artifact.toString() + " $ NOT-RESOLVED");
}
}