in src/main/java/org/apache/sling/feature/maven/mojos/apis/ApisUtil.java [324:411]
public static Map<ArtifactId, String> buildJavadocClasspath(
final Log log,
final RepositorySystem repositorySystem,
final MavenSession mavenSession,
final ArtifactId artifactId)
throws MojoExecutionException {
final Map<ArtifactId, String> javadocClasspath = new HashMap<>();
log.debug("Retrieving " + artifactId + " and related dependencies...");
org.apache.maven.artifact.Artifact toBeResolvedArtifact = repositorySystem.createArtifactWithClassifier(
artifactId.getGroupId(),
artifactId.getArtifactId(),
artifactId.getVersion(),
artifactId.getType(),
artifactId.getClassifier());
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setArtifact(toBeResolvedArtifact)
.setServers(mavenSession.getRequest().getServers())
.setMirrors(mavenSession.getRequest().getMirrors())
.setProxies(mavenSession.getRequest().getProxies())
.setLocalRepository(mavenSession.getLocalRepository())
.setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories())
.setForceUpdate(false)
.setResolveRoot(true)
.setResolveTransitively(true)
.setCollectionFilter(new ArtifactFilter() {
// artifact filter
@Override
public boolean include(org.apache.maven.artifact.Artifact artifact) {
if (org.apache.maven.artifact.Artifact.SCOPE_TEST.equals(artifact.getScope())) {
return false;
}
return true;
}
});
ArtifactResolutionResult result = repositorySystem.resolve(request);
// we only log if debug is enabled
if (!result.isSuccess() && log.isDebugEnabled()) {
if (result.hasCircularDependencyExceptions()) {
log.warn("Cyclic dependency errors detected:");
reportWarningMessages(log, result.getCircularDependencyExceptions());
}
if (result.hasErrorArtifactExceptions()) {
log.warn("Resolution errors detected:");
reportWarningMessages(log, result.getErrorArtifactExceptions());
}
if (result.hasMetadataResolutionExceptions()) {
log.warn("Metadata resolution errors detected:");
reportWarningMessages(log, result.getMetadataResolutionExceptions());
}
if (result.hasMissingArtifacts()) {
log.warn("Missing artifacts detected:");
for (org.apache.maven.artifact.Artifact missingArtifact : result.getMissingArtifacts()) {
log.warn(" - " + missingArtifact.getId());
}
}
if (result.hasExceptions()) {
log.warn("Generic errors detected:");
for (Exception exception : result.getExceptions()) {
log.warn(" - " + exception.getMessage());
}
}
}
for (org.apache.maven.artifact.Artifact resolvedArtifact : result.getArtifacts()) {
if (resolvedArtifact.getFile() != null) {
log.debug("Adding to javadoc classpath " + resolvedArtifact);
javadocClasspath.put(
new ArtifactId(
resolvedArtifact.getGroupId(),
resolvedArtifact.getArtifactId(),
resolvedArtifact.getVersion(),
resolvedArtifact.getClassifier(),
resolvedArtifact.getType()),
resolvedArtifact.getFile().getAbsolutePath());
} else {
log.debug("Ignoring for javadoc classpath " + resolvedArtifact);
}
}
return javadocClasspath;
}