use of org.apache.sling.ide.osgi.MavenSourceReference in project sling by apache.
the class MavenSourceReferenceResolver method resolve.
@Override
public IRuntimeClasspathEntry resolve(SourceReference reference) throws CoreException {
if (reference == null || reference.getType() != SourceReference.Type.MAVEN) {
return null;
}
MavenSourceReference sr = (MavenSourceReference) reference;
List<ArtifactRepository> repos = MavenPlugin.getMaven().getArtifactRepositories();
Artifact jarArtifact = MavenPlugin.getMaven().resolve(sr.getGroupId(), sr.getArtifactId(), sr.getVersion(), "jar", "", repos, new NullProgressMonitor());
Artifact sourcesArtifact = MavenPlugin.getMaven().resolve(sr.getGroupId(), sr.getArtifactId(), sr.getVersion(), "jar", "sources", repos, new NullProgressMonitor());
IPath jarPath = Path.fromOSString(jarArtifact.getFile().getAbsolutePath());
IPath sourcePath = Path.fromOSString(sourcesArtifact.getFile().getAbsolutePath());
IRuntimeClasspathEntry mavenEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(jarPath);
mavenEntry.setSourceAttachmentPath(sourcePath);
return mavenEntry;
}
Aggregations