use of org.jetbrains.idea.maven.model.MavenWorkspaceMap in project intellij-community by JetBrains.
the class CustomMaven3ArtifactResolver method resolveAsModule.
private boolean resolveAsModule(Artifact a) {
// method is called from different threads, so we have to copy the reference so ensure there is no race conditions.
MavenWorkspaceMap map = myWorkspaceMap;
if (map == null)
return false;
MavenWorkspaceMap.Data resolved = map.findFileAndOriginalId(MavenModelConverter.createMavenId(a));
if (resolved == null)
return false;
a.setResolved(true);
a.setFile(resolved.getFile(a.getType()));
a.selectVersion(resolved.originalId.getVersion());
return true;
}
use of org.jetbrains.idea.maven.model.MavenWorkspaceMap in project intellij-community by JetBrains.
the class CustomArtifactResolver method resolveAsModule.
private boolean resolveAsModule(Artifact a) {
// method is called from different threads, so we have to copy the reference so ensure there is no race conditions.
MavenWorkspaceMap map = myWorkspaceMap;
if (map == null)
return false;
MavenWorkspaceMap.Data resolved = map.findFileAndOriginalId(Maven2ModelConverter.createMavenId(a));
if (resolved == null)
return false;
a.setResolved(true);
a.setFile(resolved.getFile(a.getType()));
a.selectVersion(resolved.originalId.getVersion());
return true;
}
use of org.jetbrains.idea.maven.model.MavenWorkspaceMap in project intellij-community by JetBrains.
the class CustomMaven30ArtifactResolver method resolveAsModule.
private boolean resolveAsModule(Artifact a) {
// method is called from different threads, so we have to copy the reference so ensure there is no race conditions.
MavenWorkspaceMap map = myWorkspaceMap;
if (map == null)
return false;
MavenWorkspaceMap.Data resolved = map.findFileAndOriginalId(MavenModelConverter.createMavenId(a));
if (resolved == null)
return false;
a.setResolved(true);
a.setFile(resolved.getFile(a.getType()));
a.selectVersion(resolved.originalId.getVersion());
return true;
}
use of org.jetbrains.idea.maven.model.MavenWorkspaceMap 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);
}
use of org.jetbrains.idea.maven.model.MavenWorkspaceMap in project intellij-community by JetBrains.
the class CustomMaven3RepositoryMetadataManager method resolve.
@Override
public void resolve(RepositoryMetadata metadata, RepositoryRequest request) throws RepositoryMetadataResolutionException {
super.resolve(metadata, request);
MavenWorkspaceMap map = myWorkspaceMap;
if (map == null)
return;
Metadata data = metadata.getMetadata();
Versioning versioning = data.getVersioning();
if (versioning == null) {
data.setVersioning(versioning = new Versioning());
}
for (MavenId each : map.getAvailableIds()) {
if (each.equals(data.getGroupId(), data.getArtifactId())) {
versioning.addVersion(each.getVersion());
}
}
}
Aggregations