Search in sources :

Example 16 with MavenKey

use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.

the class MavenServerImpl method createResult.

private MavenServerResult createResult(File pom, MavenResult mavenResult) throws RemoteException {
    List<MavenProjectProblem> problems = new ArrayList<>();
    Set<MavenKey> unresolvedArtifacts = new HashSet<>();
    validate(pom, mavenResult.getExceptions(), problems);
    MavenProject project = mavenResult.getMavenProject();
    if (project == null) {
        return new MavenServerResult(null, problems, unresolvedArtifacts);
    }
    MavenModel model = null;
    try {
        DependencyResolutionResult resolutionResult = mavenResult.getDependencyResolutionResult();
        org.eclipse.aether.graph.DependencyNode dependencyNode = null;
        if (resolutionResult != null) {
            dependencyNode = resolutionResult.getDependencyGraph();
        }
        List<org.eclipse.aether.graph.DependencyNode> dependencyNodes = null;
        if (dependencyNode != null) {
            dependencyNodes = dependencyNode.getChildren();
        }
        model = MavenModelUtil.convertProjectToModel(project, dependencyNodes, new File(localRepo.getBasedir()));
    } catch (Exception e) {
        validate(project.getFile(), Collections.singletonList(e), problems);
    }
    List<String> activeProfiles = getActiveProfiles(project);
    MavenProjectInfo projectInfo = new MavenProjectInfo(model, null, activeProfiles);
    return new MavenServerResult(projectInfo, problems, unresolvedArtifacts);
}
Also used : MavenKey(org.eclipse.che.maven.data.MavenKey) DependencyResolutionResult(org.apache.maven.project.DependencyResolutionResult) ArrayList(java.util.ArrayList) ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) InitializationException(org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException) ModelInterpolationException(org.apache.maven.project.interpolation.ModelInterpolationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) InvalidProjectModelException(org.apache.maven.project.InvalidProjectModelException) SettingsBuildingException(org.apache.maven.settings.building.SettingsBuildingException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) MavenExecutionException(org.apache.maven.MavenExecutionException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) MavenExecutionRequestPopulationException(org.apache.maven.execution.MavenExecutionRequestPopulationException) MavenProjectProblem(org.eclipse.che.maven.data.MavenProjectProblem) MavenProject(org.apache.maven.project.MavenProject) MavenModel(org.eclipse.che.maven.data.MavenModel) File(java.io.File) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 17 with MavenKey

use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.

the class MavenServerTest method testInterpolateModel.

@Test
public void testInterpolateModel() throws Exception {
    MavenModel model = new MavenModel();
    model.setMavenKey(new MavenKey("aaa", "bbb", "ccc"));
    model.getBuild().setSources(Collections.singletonList("src/main/java"));
    model.getBuild().setTestSources(Collections.singletonList("src/test/java"));
    MavenModel interpolateModel = MavenServerImpl.interpolateModel(model, new File(MavenServerTest.class.getResource("/EffectivePom/pom.xml").getFile()));
    Assert.assertNotNull(interpolateModel);
}
Also used : MavenKey(org.eclipse.che.maven.data.MavenKey) MavenModel(org.eclipse.che.maven.data.MavenModel) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

MavenKey (org.eclipse.che.maven.data.MavenKey)17 MavenModel (org.eclipse.che.maven.data.MavenModel)6 MavenProject (org.eclipse.che.plugin.maven.server.core.project.MavenProject)6 Test (org.testng.annotations.Test)6 HashSet (java.util.HashSet)4 MavenParent (org.eclipse.che.maven.data.MavenParent)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 MavenArtifact (org.eclipse.che.maven.data.MavenArtifact)3 MavenBuild (org.eclipse.che.maven.data.MavenBuild)3 MavenWorkspaceCache (org.eclipse.che.maven.data.MavenWorkspaceCache)3 IProject (org.eclipse.core.resources.IProject)3 Path (org.eclipse.core.runtime.Path)3 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 Parent (org.apache.maven.model.Parent)2 MavenProjectProblem (org.eclipse.che.maven.data.MavenProjectProblem)2 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Singleton (com.google.inject.Singleton)1