use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MiscImportingTest method testExceptionsFromMavenExtensionsAreReportedAsProblems.
public void testExceptionsFromMavenExtensionsAreReportedAsProblems() throws Exception {
MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "plugins");
setRepositoryPath(helper.getTestDataPath("plugins"));
getMavenGeneralSettings().setWorkOffline(true);
importProjectWithMaven3("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<description>throw!</description>" + "" + "<build>" + " <extensions>" + " <extension>" + " <groupId>intellij.test</groupId>" + " <artifactId>maven-extension</artifactId>" + " <version>1.0</version>" + " </extension>" + " </extensions>" + "</build>");
List<MavenProject> projects = myProjectsTree.getProjects();
assertEquals(1, projects.size());
MavenProject mavenProject = projects.get(0);
assertEquals(mavenProject.getProblems().toString(), 1, mavenProject.getProblems().size());
assertEquals("throw!", mavenProject.getProblems().get(0).getDescription());
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-plugins by JetBrains.
the class Flexmojos3ImporterTest method testTransitiveDepsOnPartialProjectImport.
public void testTransitiveDepsOnPartialProjectImport() throws IOException, MavenProcessCanceledException {
createProjectPom(mavenProjectDescription("aggregator", "pom") + " <modules>\n" + " <module>app</module>\n" + " <module>libA</module>\n" + " <module>libB</module>\n" + " </modules>\n");
final VirtualFile app = createModulePom("app", parent() + " <artifactId>ttApp</artifactId>\n" + " <packaging>jar</packaging>\n" + "\n" + dependencies("A", "jar"));
createModulePom("libA", parent() + " <artifactId>A</artifactId>\n" + " <packaging>jar</packaging>\n" + " \n" + dependencies("B", "jar"));
createModulePom("libB", parent() + " <artifactId>B</artifactId>\n" + " <packaging>jar</packaging>");
importProject();
MavenProjectsTree.EmbedderTask task = new MavenProjectsTree.EmbedderTask() {
@Override
public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
MavenWorkspaceMap workspaceMap = new MavenWorkspaceMap();
for (MavenProject mavenProject : myProjectsTree.getProjects()) {
if (MavenConstants.TYPE_JAR.equalsIgnoreCase(mavenProject.getPackaging())) {
workspaceMap.register(mavenProject.getMavenId(), new File(mavenProject.getFile().getPath()), new File(mavenProject.getMavenId().getArtifactId() + ".jar"));
} else {
workspaceMap.register(mavenProject.getMavenId(), new File(mavenProject.getFile().getPath()));
}
}
embedder.customizeForStrictResolve(workspaceMap, NULL_MAVEN_CONSOLE, EMPTY_MAVEN_PROCESS);
MavenServerExecutionResult result = embedder.execute(app, Collections.emptyList(), Collections.emptyList(), Collections.singletonList("compile"));
assertEmpty(result.problems);
assertNotNull(result);
// test find all transitive deps (MavenWorkspaceMap filler is responsible for)
MavenModel mavenModel = result.projectData.mavenModel;
assertTransitiveDeps(TEST_GROUP_ID, TEST_VERSION, mavenModel.getDependencies());
// test correct artifact file (must be SWC/JAR (project product), but not POM) (CustomArtifactResolver is responsible for)
MavenArtifact resolve = embedder.resolve(new MavenArtifactInfo(TEST_GROUP_ID, "B", TEST_VERSION, MavenConstants.TYPE_JAR, null), mavenModel.getRemoteRepositories());
assertNotNull(resolve);
assertEquals("B.jar", resolve.getFile().getPath());
}
};
MavenProject appProject = myProjectsTree.findProject(new MavenId(TEST_GROUP_ID, "ttApp", TEST_VERSION));
assertNotNull(appProject);
myProjectsTree.executeWithEmbedder(appProject, myProjectsManager.getEmbeddersManager(), MavenEmbeddersManager.FOR_POST_PROCESSING, NULL_MAVEN_CONSOLE, EMPTY_MAVEN_PROCESS, task);
List<MavenArtifact> appSubProjectDeps = appProject.getDependencies();
assertTransitiveDeps(TEST_GROUP_ID, TEST_VERSION, appSubProjectDeps);
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class ToggleBeforeRunTaskAction method doIsSelected.
@Override
protected boolean doIsSelected(AnActionEvent e) {
final DataContext context = e.getDataContext();
final Pair<MavenProject, String> desc = getTaskDesc(context);
if (desc != null) {
final RunManagerEx runManager = getRunManager(context);
if (runManager == null)
return false;
for (MavenBeforeRunTask each : runManager.getBeforeRunTasks(MavenBeforeRunTasksProvider.ID)) {
if (each.isFor(desc.first, desc.second))
return true;
}
}
return false;
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class ToggleBeforeRunTaskAction method setSelected.
@Override
public void setSelected(final AnActionEvent e, boolean state) {
final DataContext context = e.getDataContext();
final Pair<MavenProject, String> desc = getTaskDesc(context);
if (desc != null) {
new MavenExecuteBeforeRunDialog(MavenActionUtil.getProject(context), desc.first, desc.second).show();
}
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class ToggleBeforeRunTaskAction method getTaskDesc.
@Nullable
protected static Pair<MavenProject, String> getTaskDesc(DataContext context) {
List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.size() != 1)
return null;
MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
if (mavenProject == null)
return null;
return Pair.create(mavenProject, goals.get(0));
}
Aggregations