Search in sources :

Example 6 with MavenArtifactKey

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;
}
Also used : MavenArtifactKey(org.eclipse.che.maven.data.MavenArtifactKey) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact)

Example 7 with MavenArtifactKey

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());
}
Also used : MavenArtifactKey(org.eclipse.che.maven.data.MavenArtifactKey) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Test(org.testng.annotations.Test)

Example 8 with MavenArtifactKey

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());
}
Also used : MavenArtifactKey(org.eclipse.che.maven.data.MavenArtifactKey) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Test(org.testng.annotations.Test)

Aggregations

MavenArtifactKey (org.eclipse.che.maven.data.MavenArtifactKey)8 MavenArtifact (org.eclipse.che.maven.data.MavenArtifact)6 Test (org.testng.annotations.Test)4 IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)2 File (java.io.File)1 MavenServerWrapper (org.eclipse.che.plugin.maven.server.MavenServerWrapper)1 Path (org.eclipse.core.runtime.Path)1 IAccessRule (org.eclipse.jdt.core.IAccessRule)1 IClassFile (org.eclipse.jdt.core.IClassFile)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1