use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testResolvingProject.
public void _testResolvingProject() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.0</version>" + " </dependency>" + "</dependencies>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
MavenServerExecutionResult result = myEmbedder.resolveProject(myProjectPom, Collections.<String>emptyList(), Collections.<String>emptyList());
assertNotNull(result.projectData);
assertOrderedElementsAreEqual(result.unresolvedArtifacts);
MavenModel project = result.projectData.mavenModel;
assertNotNull(project);
assertEquals("project", project.getMavenId().getArtifactId());
assertEquals(1, project.getDependencies().size());
}
use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testExecutionGoals.
public void _testExecutionGoals() throws Exception {
createProjectSubFile("src/main/java/A.java", "public class A {}");
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
MavenServerExecutionResult result = myEmbedder.execute(myProjectPom, Collections.<String>emptyList(), Collections.<String>emptyList(), Arrays.asList("compile"));
assertNotNull(result.projectData);
assertNotNull(new File(getProjectPath(), "target").exists());
assertOrderedElementsAreEqual(result.unresolvedArtifacts);
MavenModel project = result.projectData.mavenModel;
assertNotNull(project);
assertEquals("project", project.getMavenId().getArtifactId());
}
use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-plugins by JetBrains.
the class Flexmojos3GenerateConfigTask method perform.
public void perform(final Project project, final MavenEmbeddersManager embeddersManager, final MavenConsole console, final MavenProgressIndicator indicator) throws MavenProcessCanceledException {
if (myModule.isDisposed())
return;
indicator.setText(FlexBundle.message("generating.flex.config.for", myMavenProject.getDisplayName()));
final MavenProjectsTree.EmbedderTask task = new MavenProjectsTree.EmbedderTask() {
public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
List<VirtualFile> temporaryFiles = null;
final IgnoredFileBean[] filesToIgnoreOriginal = ChangeListManager.getInstance(project).getFilesToIgnore();
try {
MavenWorkspaceMap workspaceMap = new MavenWorkspaceMap();
temporaryFiles = mavenIdToOutputFileMapping(workspaceMap, project, myTree.getProjects());
embedder.customizeForStrictResolve(workspaceMap, console, indicator);
final String generateConfigGoal = FlexmojosImporter.FLEXMOJOS_GROUP_ID + ":" + FlexmojosImporter.FLEXMOJOS_ARTIFACT_ID + ":generate-config-" + myMavenProject.getPackaging();
final MavenExplicitProfiles profilesIds = myMavenProject.getActivatedProfilesIds();
MavenServerExecutionResult result = embedder.execute(myMavenProject.getFile(), profilesIds.getEnabledProfiles(), profilesIds.getDisabledProfiles(), Collections.singletonList(generateConfigGoal));
if (result.projectData == null) {
myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
}
MavenUtil.invokeAndWaitWriteAction(project, () -> {
// need to refresh externally created file
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(myConfigFilePath);
if (file != null) {
file.refresh(false, false);
updateMainClass(myModule, file);
}
});
} catch (MavenProcessCanceledException e) {
throw e;
} catch (Exception e) {
myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
console.printException(e);
MavenLog.LOG.warn(e);
} finally {
ChangeListManager.getInstance(project).setFilesToIgnore(filesToIgnoreOriginal);
if (temporaryFiles != null && !temporaryFiles.isEmpty()) {
removeTemporaryFiles(project, temporaryFiles);
}
}
}
};
myTree.executeWithEmbedder(myMavenProject, embeddersManager, MavenEmbeddersManager.FOR_POST_PROCESSING, console, indicator, task);
}
Aggregations