Search in sources :

Example 1 with MavenServerWrapper

use of org.eclipse.che.plugin.maven.server.MavenServerWrapper in project che by eclipse.

the class MavenProjectManager method resolveMavenProject.

public void resolveMavenProject(IProject project, MavenProject mavenProject) {
    MavenServerWrapper mavenServer = wrapperManager.getMavenServer(MavenWrapperManager.ServerType.RESOLVE);
    try {
        mavenNotifier.setText("Resolving project: " + mavenProject.getName());
        mavenServer.customize(copyWorkspaceCache(), terminal, mavenNotifier, false, true);
        MavenProjectModifications modifications = mavenProject.resolve(project, mavenServer, serverManager);
        dispatcher.projectResolved(mavenProject, modifications);
    } finally {
        wrapperManager.release(mavenServer);
    }
}
Also used : MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) MavenProjectModifications(org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications)

Example 2 with MavenServerWrapper

use of org.eclipse.che.plugin.maven.server.MavenServerWrapper in project che by eclipse.

the class MavenServerManagerTest method testLaunchMavenServer.

@Test
public void testLaunchMavenServer() throws Exception {
    MavenServerWrapper server = manager.createMavenServer();
    assertThat(server).isNotNull();
}
Also used : MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) Test(org.testng.annotations.Test)

Example 3 with MavenServerWrapper

use of org.eclipse.che.plugin.maven.server.MavenServerWrapper in project che by eclipse.

the class MavenServerService method getEffectivePom.

/**
     * Returns maven effective pom file.
     *
     * @param projectPath
     *         path to the opened pom file
     * @return content of the effective pom
     * @throws ServerException
     *         when getting mount point has a problem
     * @throws NotFoundException
     *         when current pom file isn't exist
     * @throws ForbiddenException
     *         when response code is 403
     */
@GET
@Path("effective/pom")
@Produces(TEXT_XML)
public String getEffectivePom(@QueryParam("projectpath") String projectPath) throws ServerException, NotFoundException, ForbiddenException {
    RegisteredProject project = projectRegistry.getProject(projectPath);
    if (project == null) {
        throw new NotFoundException("Project " + projectPath + " doesn't exist");
    }
    MavenServerWrapper mavenServer = wrapperManager.getMavenServer(MavenWrapperManager.ServerType.DOWNLOAD);
    try {
        mavenServer.customize(projectManager.copyWorkspaceCache(), terminal, notifier, false, false);
        VirtualFileEntry pomFile = project.getBaseFolder().getChild("pom.xml");
        if (pomFile == null) {
            throw new NotFoundException("pom.xml doesn't exist");
        }
        return mavenServer.getEffectivePom(pomFile.getVirtualFile().toIoFile(), Collections.emptyList(), Collections.emptyList());
    } finally {
        wrapperManager.release(mavenServer);
    }
}
Also used : MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) NotFoundException(org.eclipse.che.api.core.NotFoundException) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with MavenServerWrapper

use of org.eclipse.che.plugin.maven.server.MavenServerWrapper 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 5 with MavenServerWrapper

use of org.eclipse.che.plugin.maven.server.MavenServerWrapper in project che by eclipse.

the class MavenServerManagerTest method testEffectivePom.

@Test
public void testEffectivePom() throws Exception {
    MavenServerWrapper mavenServer = manager.createMavenServer();
    String effectivePom = mavenServer.getEffectivePom(new File(MavenServerManagerTest.class.getResource("/EffectivePom/pom.xml").getFile()), Collections.emptyList(), Collections.emptyList());
    assertThat(effectivePom).isNotNull().isNotEmpty().contains("<!-- Effective POM for project").contains("'org.eclipse.che.parent:maven-parent-pom:pom:4.0.0-M6-SNAPSHOT'");
}
Also used : MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

MavenServerWrapper (org.eclipse.che.plugin.maven.server.MavenServerWrapper)5 Test (org.testng.annotations.Test)2 File (java.io.File)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 NotFoundException (org.eclipse.che.api.core.NotFoundException)1 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)1 VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)1 MavenArtifact (org.eclipse.che.maven.data.MavenArtifact)1 MavenArtifactKey (org.eclipse.che.maven.data.MavenArtifactKey)1 MavenProjectModifications (org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1