use of org.eclipse.che.maven.data.MavenModel in project che by eclipse.
the class ProjectResolverTest method testProjectHasDependencies.
@Test
public void testProjectHasDependencies() throws Exception {
MavenServerResult resolveProject = mavenServer.resolveProject(new File(MavenServerTest.class.getResource("/FirstProject/pom.xml").getFile()), Collections.emptyList(), Collections.emptyList());
assertNotNull(resolveProject);
MavenProjectInfo projectInfo = resolveProject.getProjectInfo();
assertNotNull(projectInfo);
MavenModel mavenModel = projectInfo.getMavenModel();
assertNotNull(mavenModel);
List<MavenArtifact> dependencies = mavenModel.getDependencies();
assertFalse(dependencies.isEmpty());
assertEquals(26, dependencies.size());
}
use of org.eclipse.che.maven.data.MavenModel in project che by eclipse.
the class MavenModelUtil method convertToMavenModel.
public static Model convertToMavenModel(MavenModel model) {
Model result = new Model();
result.setArtifactId(model.getMavenKey().getArtifactId());
result.setGroupId(model.getMavenKey().getGroupId());
result.setVersion(model.getMavenKey().getVersion());
result.setPackaging(model.getPackaging());
result.setName(model.getName());
if (model.getParent() != null) {
Parent parent = new Parent();
MavenKey parentKey = model.getParent().getMavenKey();
parent.setArtifactId(parentKey.getArtifactId());
parent.setGroupId(parentKey.getGroupId());
parent.setVersion(parentKey.getVersion());
parent.setRelativePath(model.getParent().getRelativePath());
result.setParent(parent);
}
result.setProperties(model.getProperties());
result.setModules(model.getModules());
result.setBuild(new Build());
MavenBuild modelBuild = model.getBuild();
convertToMavenBuildBase(modelBuild, result.getBuild());
result.getBuild().setSourceDirectory(modelBuild.getSources().get(0));
result.getBuild().setTestSourceDirectory(modelBuild.getTestSources().get(0));
result.setProfiles(convertToMavenProfiles(model.getProfiles()));
return result;
}
use of org.eclipse.che.maven.data.MavenModel in project che by eclipse.
the class MavenModelUtil method convertModel.
public static MavenModel convertModel(Model model, List<String> sources, List<String> testSources, Collection<Artifact> dependencies, Collection<Artifact> extensions, File localRepo) {
MavenModel result = new MavenModel();
result.setMavenKey(new MavenKey(model.getGroupId(), model.getArtifactId(), model.getVersion()));
Parent parent = model.getParent();
if (parent != null) {
result.setParent(new MavenParent(new MavenKey(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()), parent.getRelativePath()));
}
result.setName(model.getName());
result.setPackaging(model.getPackaging());
result.setProperties(model.getProperties() != null ? model.getProperties() : new Properties());
result.setModules(model.getModules());
result.setPlugins(convertPlugins(model));
Map<Artifact, MavenArtifact> convertedArtifacts = new HashMap<>();
result.setExtensions(convertArtifacts(extensions, convertedArtifacts, localRepo));
result.setDependencies(convertArtifacts(dependencies, convertedArtifacts, localRepo));
result.setRemoteRepositories(convertRepositories(model.getRepositories()));
result.setProfiles(convertProfiles(model.getProfiles()));
convertBuild(result.getBuild(), model.getBuild(), sources, testSources);
return result;
}
use of org.eclipse.che.maven.data.MavenModel in project che by eclipse.
the class MavenServerImpl method interpolateModel.
public static MavenModel interpolateModel(MavenModel model, File projectDir) throws RemoteException {
Model result = MavenModelUtil.convertToMavenModel(model);
result = internalInterpolate(result, projectDir);
return MavenModelUtil.convertModel(result);
}
use of org.eclipse.che.maven.data.MavenModel 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);
}
Aggregations