use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ClasspathManager method downloadSources.
private boolean downloadSources(IPackageFragmentRoot fragmentRoot) throws JavaModelException {
fragmentRoot.getAdapter(MavenArtifactKey.class);
IClasspathEntry classpathEntry = fragmentRoot.getResolvedClasspathEntry();
MavenArtifactKey artifactKey = getArtifactKey(classpathEntry);
if (artifactKey != null) {
MavenServerWrapper mavenServer = wrapperManager.getMavenServer(MavenWrapperManager.ServerType.DOWNLOAD);
try {
mavenServer.customize(projectManager.copyWorkspaceCache(), terminal, notifier, false, false);
MavenArtifactKey sourceKey = new MavenArtifactKey(artifactKey.getGroupId(), artifactKey.getArtifactId(), artifactKey.getVersion(), artifactKey.getPackaging(), SOURCES);
MavenArtifact mavenArtifact = mavenServer.resolveArtifact(sourceKey, Collections.emptyList());
if (mavenArtifact.isResolved()) {
updateClasspath(projectManager.findMavenProject(fragmentRoot.getJavaProject().getProject()));
}
return mavenArtifact.isResolved();
} finally {
wrapperManager.release(mavenServer);
}
}
return false;
}
use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ProjectResolverTest method testResolveNotExistingArtifactSource.
@Test
public void testResolveNotExistingArtifactSource() throws Exception {
MavenArtifactKey artifactKey = new MavenArtifactKey("junit", "junit", "3.56", "jar", "sources");
MavenArtifact artifact = mavenServer.resolveArtifact(artifactKey, Collections.emptyList());
assertNotNull(artifact);
assertFalse(artifact.isResolved());
}
use of org.eclipse.che.maven.data.MavenArtifactKey in project che by eclipse.
the class ProjectResolverTest method testResolveArtifactSource.
@Test
public void testResolveArtifactSource() throws Exception {
MavenArtifactKey artifactKey = new MavenArtifactKey("junit", "junit", "4.11", "jar", "sources");
MavenArtifact artifact = mavenServer.resolveArtifact(artifactKey, Collections.emptyList());
assertNotNull(artifact);
assertTrue(artifact.isResolved());
}
Aggregations