use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenDomAnnotator method addProblems.
private static void addProblems(DomElement element, MavenDomProjectModel model, DomElementAnnotationHolder holder, MavenProjectProblem.ProblemType... types) {
MavenProject mavenProject = MavenDomUtil.findProject(model);
if (mavenProject != null) {
for (MavenProjectProblem each : mavenProject.getProblems()) {
MavenProjectProblem.ProblemType type = each.getType();
if (!Arrays.asList(types).contains(type))
continue;
VirtualFile problemFile = LocalFileSystem.getInstance().findFileByPath(each.getPath());
LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY;
if (problemFile != null && !Comparing.equal(mavenProject.getFile(), problemFile)) {
fixes = new LocalQuickFix[] { new OpenProblemFileFix(problemFile) };
}
holder.createProblem(element, HighlightSeverity.ERROR, each.getDescription(), fixes);
}
}
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenProjectsTreeReadingTest method testAddingProjectAsAggregatorForExistingOne.
public void testAddingProjectAsAggregatorForExistingOne() throws Exception {
VirtualFile m = createModulePom("m", "<groupId>test</groupId>" + "<artifactId>m</artifactId>" + "<version>1</version>");
updateAll(m);
List<MavenProject> roots = myTree.getRootProjects();
assertEquals(1, roots.size());
assertEquals(m, roots.get(0).getFile());
assertEquals(0, myTree.getModules(roots.get(0)).size());
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + " <module>m</module>" + "</modules>");
update(myProjectPom);
roots = myTree.getRootProjects();
assertEquals(1, roots.size());
assertEquals(myProjectPom, roots.get(0).getFile());
assertEquals(1, myTree.getModules(roots.get(0)).size());
assertEquals(m, myTree.getModules(roots.get(0)).get(0).getFile());
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenProjectsTreeReadingTest method testUpdatingModelWithNewProfiles.
public void testUpdatingModelWithNewProfiles() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<profiles>" + " <profile>" + " <id>one</id>" + " <modules>" + " <module>m1</module>" + " </modules>" + " </profile>" + " <profile>" + " <id>two</id>" + " <modules>" + " <module>m2</module>" + " </modules>" + " </profile>" + "</profiles>");
VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>");
VirtualFile m2 = createModulePom("m2", "<groupId>test</groupId>" + "<artifactId>m2</artifactId>" + "<version>1</version>");
updateAll(Collections.singletonList("one"), myProjectPom);
List<MavenProject> roots = myTree.getRootProjects();
assertEquals(1, roots.size());
assertEquals(myProjectPom, roots.get(0).getFile());
assertEquals(1, myTree.getModules(roots.get(0)).size());
assertEquals(m1, myTree.getModules(roots.get(0)).get(0).getFile());
updateAll(Collections.singletonList("two"), myProjectPom);
roots = myTree.getRootProjects();
assertEquals(1, roots.size());
assertEquals(myProjectPom, roots.get(0).getFile());
assertEquals(1, myTree.getModules(roots.get(0)).size());
assertEquals(m2, myTree.getModules(roots.get(0)).get(0).getFile());
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenProjectsTreeReadingTest method testModulesWithWhiteSpaces.
public void testModulesWithWhiteSpaces() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + " <module>" + "" + " m" + "" + " </module>" + "</modules>");
VirtualFile m = createModulePom("m", "<groupId>test</groupId>" + "<artifactId>m</artifactId>" + "<version>1</version>");
updateAll(myProjectPom);
List<MavenProject> roots = myTree.getRootProjects();
assertEquals(1, roots.size());
assertEquals(myProjectPom, roots.get(0).getFile());
assertEquals(1, myTree.getModules(roots.get(0)).size());
assertEquals(m, myTree.getModules(roots.get(0)).get(0).getFile());
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenProjectsTreeReadingTest method testOutputPathsAreBasedOnTargetPathWhenResolving.
public void testOutputPathsAreBasedOnTargetPathWhenResolving() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + " <directory>my-target</directory>" + "</build>");
updateAll(myProjectPom);
MavenProject project = myTree.getRootProjects().get(0);
PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target"), project.getBuildDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target/classes"), project.getOutputDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target/test-classes"), project.getTestOutputDirectory());
MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject);
try {
myTree.resolve(myProject, project, getMavenGeneralSettings(), embeddersManager, NULL_MAVEN_CONSOLE, EMPTY_MAVEN_PROCESS);
} finally {
embeddersManager.releaseInTests();
}
PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target"), project.getBuildDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target/classes"), project.getOutputDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target/test-classes"), project.getTestOutputDirectory());
}
Aggregations