use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project moe-ide-integration by multi-os-engine.
the class MOEMavenTask method executeTask.
public boolean executeTask(final Project project, final MavenProject mavenProject, final ExecutionEnvironment env, final String goal) {
final Semaphore targetDone = new Semaphore();
final boolean[] result = new boolean[] { true };
try {
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
if (project == null || project.isDisposed() || mavenProject == null)
return;
final MavenExplicitProfiles explicitProfiles = MavenProjectsManager.getInstance(project).getExplicitProfiles();
final MOEMavenRunner mavenRunner = MOEMavenRunner.getInstance(project);
targetDone.down();
new Task.Backgroundable(project, title, true) {
public void run(@NotNull ProgressIndicator indicator) {
try {
MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), ParametersListUtil.parse(goal), explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles());
result[0] = mavenRunner.runBatch(Collections.singletonList(params), null, null, title, indicator);
} finally {
targetDone.up();
}
}
@Override
public boolean shouldStartInBackground() {
return startInBackground;
}
@Override
public void processSentToBackground() {
MOEMavenRunner.getInstance(project).getSettings().setRunMavenInBackground(true);
}
}.queue();
}
}, ModalityState.NON_MODAL);
} catch (Exception e) {
MavenLog.LOG.error(e);
return false;
}
targetDone.waitFor();
return result[0];
}
use of org.jetbrains.idea.maven.model.MavenExplicitProfiles 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.MavenExplicitProfiles in project intellij-community by JetBrains.
the class ToggleProfileAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
MavenProjectsManager manager = MavenActionUtil.getProjectsManager(e.getDataContext());
if (manager == null)
return;
Map<String, MavenProfileKind> selectedProfiles = e.getData(MavenDataKeys.MAVEN_PROFILES);
if (selectedProfiles == null)
return;
Set<String> selectedProfileIds = selectedProfiles.keySet();
MavenProfileKind targetState = getTargetState(manager, selectedProfiles);
if (targetState == null)
return;
MavenExplicitProfiles newExplicitProfiles = manager.getExplicitProfiles().clone();
switch(targetState) {
case NONE:
// disable explicitly
newExplicitProfiles.getEnabledProfiles().removeAll(selectedProfileIds);
newExplicitProfiles.getDisabledProfiles().addAll(selectedProfileIds);
break;
case EXPLICIT:
// enable explicitly
newExplicitProfiles.getDisabledProfiles().removeAll(selectedProfileIds);
newExplicitProfiles.getEnabledProfiles().addAll(selectedProfileIds);
break;
case IMPLICIT:
default:
// reset to default state
newExplicitProfiles.getEnabledProfiles().removeAll(selectedProfileIds);
newExplicitProfiles.getDisabledProfiles().removeAll(selectedProfileIds);
break;
}
manager.setExplicitProfiles(newExplicitProfiles);
}
use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.
the class MavenWorkspaceSettingsComponent method getState.
@Override
@NotNull
public MavenWorkspaceSettings getState() {
MavenExplicitProfiles profiles = MavenProjectsManager.getInstance(myProject).getExplicitProfiles();
mySettings.setEnabledProfiles(profiles.getEnabledProfiles());
mySettings.setDisabledProfiles(profiles.getDisabledProfiles());
return mySettings;
}
use of org.jetbrains.idea.maven.model.MavenExplicitProfiles in project intellij-community by JetBrains.
the class MavenProjectBuilder method commit.
@Override
public List<Module> commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider, ModifiableArtifactModel artifactModel) {
MavenWorkspaceSettings settings = MavenWorkspaceSettingsComponent.getInstance(project).getSettings();
settings.generalSettings = getGeneralSettings();
settings.importingSettings = getImportingSettings();
String settingsFile = System.getProperty("idea.maven.import.settings.file");
if (!StringUtil.isEmptyOrSpaces(settingsFile)) {
settings.generalSettings.setUserSettingsFile(settingsFile.trim());
}
MavenExplicitProfiles selectedProfiles = getSelectedProfiles();
String enabledProfilesList = System.getProperty("idea.maven.import.enabled.profiles");
String disabledProfilesList = System.getProperty("idea.maven.import.disabled.profiles");
if (enabledProfilesList != null || disabledProfilesList != null) {
selectedProfiles = selectedProfiles.clone();
appendProfilesFromString(selectedProfiles.getEnabledProfiles(), enabledProfilesList);
appendProfilesFromString(selectedProfiles.getDisabledProfiles(), disabledProfilesList);
}
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
manager.setIgnoredState(getParameters().mySelectedProjects, false);
manager.addManagedFilesWithProfiles(MavenUtil.collectFiles(getParameters().mySelectedProjects), selectedProfiles);
manager.waitForReadingCompletion();
boolean isFromUI = model != null;
return manager.importProjects(isFromUI ? new IdeUIModifiableModelsProvider(project, model, (ModulesConfigurator) modulesProvider, artifactModel) : new IdeModifiableModelsProviderImpl(project));
}
Aggregations