use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testUnresolvedArtifacts.
public void _testUnresolvedArtifacts() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>fff</groupId>" + " <artifactId>zzz</artifactId>" + " <version>666</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, new MavenId("fff", "zzz", "666"));
}
use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testUnresolvedSystemArtifactsWithoutPath.
public void _testUnresolvedSystemArtifactsWithoutPath() throws Exception {
// need to repair model before resolving
if (ignore())
return;
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>fff</groupId>" + " <artifactId>zzz</artifactId>" + " <version>666</version>" + " <scope>system</scope>" + " </dependency>" + "</dependencies>");
myEmbedder.customizeForResolve(new SoutMavenConsole(), EMPTY_MAVEN_PROCESS);
MavenServerExecutionResult result = myEmbedder.resolveProject(myProjectPom, Collections.<String>emptyList(), Collections.<String>emptyList());
assertNotNull(result);
assertOrderedElementsAreEqual(result.unresolvedArtifacts, new MavenId("fff", "zzz", "666"));
}
use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-community by JetBrains.
the class MavenServerEmbedderTest method _testResolvingProjectWithExtensions.
public void _testResolvingProjectWithExtensions() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>com.adobe.flex.framework</groupId>" + " <artifactId>framework</artifactId>" + " <version>3.2.0.3958</version>" + " <type>resource-bundle</type>" + " <classifier>en_US</classifier>" + " </dependency>" + "</dependencies>" + "<build>" + " <plugins>" + " <plugin>" + " <groupId>org.sonatype.flexmojos</groupId>" + " <artifactId>flexmojos-maven-plugin</artifactId>" + " <version>3.5.0</version>" + " <extensions>true</extensions>" + " </plugin>" + " </plugins>" + "</build>");
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 p = result.projectData.mavenModel;
assertEquals(1, p.getDependencies().size());
assertEquals("rb.swc", p.getDependencies().get(0).getExtension());
}
use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-community by JetBrains.
the class MavenProjectReader method generateSources.
@Nullable
public static MavenProjectReaderResult generateSources(MavenEmbedderWrapper embedder, MavenImportingSettings importingSettings, VirtualFile file, MavenExplicitProfiles profiles, MavenConsole console) throws MavenProcessCanceledException {
try {
List<String> goals = Collections.singletonList(importingSettings.getUpdateFoldersOnImportPhase());
MavenServerExecutionResult result = embedder.execute(file, profiles.getEnabledProfiles(), profiles.getDisabledProfiles(), goals);
MavenServerExecutionResult.ProjectData projectData = result.projectData;
if (projectData == null)
return null;
return new MavenProjectReaderResult(projectData.mavenModel, projectData.mavenModelMap, new MavenExplicitProfiles(projectData.activatedProfiles, profiles.getDisabledProfiles()), projectData.nativeMavenProject, result.problems, result.unresolvedArtifacts);
} catch (Throwable e) {
console.printException(e);
MavenLog.LOG.warn(e);
return null;
}
}
use of org.jetbrains.idea.maven.server.MavenServerExecutionResult in project intellij-community by JetBrains.
the class MavenProjectReader method resolveProject.
public Collection<MavenProjectReaderResult> resolveProject(final MavenGeneralSettings generalSettings, MavenEmbedderWrapper embedder, Collection<VirtualFile> files, final MavenExplicitProfiles explicitProfiles, final MavenProjectReaderProjectLocator locator) throws MavenProcessCanceledException {
try {
Collection<MavenServerExecutionResult> executionResults = embedder.resolveProject(files, explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles());
Collection<MavenProjectReaderResult> readerResults = ContainerUtil.newArrayList();
for (MavenServerExecutionResult result : executionResults) {
MavenServerExecutionResult.ProjectData projectData = result.projectData;
if (projectData == null) {
if (files.size() == 1) {
final VirtualFile file = files.iterator().next();
MavenProjectReaderResult temp = readProject(generalSettings, file, explicitProfiles, locator);
temp.readingProblems.addAll(result.problems);
temp.unresolvedArtifactIds.addAll(result.unresolvedArtifacts);
readerResults.add(temp);
}
} else {
readerResults.add(new MavenProjectReaderResult(projectData.mavenModel, projectData.mavenModelMap, new MavenExplicitProfiles(projectData.activatedProfiles, explicitProfiles.getDisabledProfiles()), projectData.nativeMavenProject, result.problems, result.unresolvedArtifacts));
}
}
return readerResults;
} catch (MavenProcessCanceledException e) {
throw e;
} catch (final Throwable e) {
MavenLog.LOG.info(e);
// print exception since we need to know if something wrong with our logic
MavenLog.printInTests(e);
return ContainerUtil.mapNotNull(files, file -> {
MavenProjectReaderResult result = readProject(generalSettings, file, explicitProfiles, locator);
String message = e.getMessage();
if (message != null) {
result.readingProblems.add(MavenProjectProblem.createStructureProblem(file.getPath(), message));
} else {
result.readingProblems.add(MavenProjectProblem.createSyntaxProblem(file.getPath(), MavenProjectProblem.ProblemType.SYNTAX));
}
return result;
});
}
}
Aggregations