use of org.jetbrains.idea.maven.project.MavenProjectsManager in project azure-tools-for-java by Microsoft.
the class MavenProjectGenerator method importMavenProject.
private void importMavenProject() throws ConfigurationException {
Project project = this.module.getProject();
String baseDirPath = project.getBasePath();
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
File pomFile = new File(baseDirPath + File.separator + "pom.xml");
VirtualFile pom = VfsUtil.findFileByIoFile(pomFile, true);
manager.addManagedFiles(Collections.singletonList(pom));
manager.scheduleImportAndResolve();
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project android by JetBrains.
the class AndroidMavenExecutor method generateResources.
public static Map<CompilerMessageCategory, List<String>> generateResources(final Module module) {
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(module.getProject());
final MavenRunnerParameters parameters = new MavenRunnerParameters(true, projectsManager.findProject(module).getDirectory(), Collections.singletonList("process-resources"), projectsManager.getExplicitProfiles());
final Map<CompilerMessageCategory, List<String>> result = new HashMap<CompilerMessageCategory, List<String>>();
result.put(CompilerMessageCategory.ERROR, new ArrayList<String>());
try {
JavaParameters javaParams = ApplicationManager.getApplication().runReadAction(new Computable<JavaParameters>() {
@Nullable
@Override
public JavaParameters compute() {
try {
return MavenExternalParameters.createJavaParameters(module.getProject(), parameters);
} catch (ExecutionException e) {
LOG.info(e);
result.get(CompilerMessageCategory.ERROR).add(e.getMessage());
return null;
}
}
});
if (javaParams == null) {
return result;
}
GeneralCommandLine commandLine = javaParams.toCommandLine();
final StringBuildingOutputProcessor processor = new StringBuildingOutputProcessor();
boolean success = AndroidUtils.executeCommand(commandLine, processor, WaitingStrategies.WaitForever.getInstance()) == ExecutionStatus.SUCCESS;
String message = processor.getMessage();
if (!success) {
LOG.info(message);
String lcmessage = message.toLowerCase();
int buildErrorIndex = lcmessage.indexOf(BUILD_ERROR_INDICATOR);
if (buildErrorIndex >= 0) {
result.get(CompilerMessageCategory.ERROR).add(message.substring(buildErrorIndex));
}
}
} catch (ExecutionException e) {
LOG.info(e);
result.get(CompilerMessageCategory.ERROR).add(e.getMessage());
}
return result;
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project liferay-ide by liferay.
the class AbstractLiferayMavenGoalAction method checkOrPerform.
public boolean checkOrPerform(DataContext context, boolean perform) {
Project project = MavenActionUtil.getProject(context);
MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
if ((project == null) || (mavenProject == null)) {
return false;
}
if (!perform) {
return true;
}
String projectDir = mavenProject.getDirectory();
MavenProjectsManager mavenProjectsManager = MavenActionUtil.getProjectsManager(context);
MavenExplicitProfiles explicitProfiles = mavenProjectsManager.getExplicitProfiles();
Collection<String> enabledProfiles = explicitProfiles.getEnabledProfiles();
Collection<String> disabledProfiles = explicitProfiles.getDisabledProfiles();
MavenRunnerParameters params = new MavenRunnerParameters(true, projectDir, goals, enabledProfiles, disabledProfiles);
MavenRunConfigurationType.runConfiguration(project, params, null);
return true;
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project liferay-ide by liferay.
the class LiferayWorkspaceUtil method isValidMavenWorkspaceLocation.
public static boolean isValidMavenWorkspaceLocation(Project project) {
File pomFile = new File(project.getBasePath(), _BUILD_MAVEN_FILE_NAME);
if (!pomFile.exists()) {
return false;
}
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
VirtualFile virtualPom = fileSystem.findFileByPath(pomFile.getPath());
if (virtualPom.exists()) {
boolean pom = MavenUtil.isPomFile(project, virtualPom);
if (!pom) {
return false;
}
}
try {
MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(project);
MavenProject mavenWorkspaceProject = mavenProjectsManager.findProject(virtualPom);
MavenPlugin liferayWorkspacePlugin = mavenWorkspaceProject.findPlugin("com.liferay", "com.liferay.portal.tools.bundle.support");
if (liferayWorkspacePlugin != null) {
return true;
}
} catch (Exception e) {
return false;
}
return false;
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project moe-ide-integration by multi-os-engine.
the class MOEMavenTask method runTask.
public boolean runTask() {
String workDirectory = getWorkPath();
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(module.getProject());
File mavenHome = MavenUtil.resolveMavenHomeDirectory(projectsManager.getGeneralSettings().getMavenHome());
if (mavenHome == null) {
Notification notification = new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Failed to execute goal", RunnerBundle.message("external.maven.home.no.default.with.fix"), NotificationType.ERROR, new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
ShowSettingsUtil.getInstance().showSettingsDialog(module.getProject(), MavenSettings.DISPLAY_NAME);
}
});
Notifications.Bus.notify(notification, module.getProject());
return false;
}
StringBuilder goalBuilder = new StringBuilder();
setGoalTarget(goalBuilder);
addArguments(goalBuilder);
MavenRunnerParameters parameters = new MavenRunnerParameters(true, workDirectory, Arrays.asList(ParametersList.parse(goalBuilder.toString())), Collections.<String>emptyList());
MavenGeneralSettings generalSettings = new MavenGeneralSettings();
generalSettings.setMavenHome(mavenHome.getPath());
MavenRunnerSettings runnerSettings = MavenRunner.getInstance(module.getProject()).getSettings().clone();
runnerSettings.setMavenProperties(new LinkedHashMap<String, String>());
runnerSettings.setSkipTests(true);
RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(generalSettings, runnerSettings, parameters, module.getProject());
ProgramRunner runner = DefaultJavaProgramRunner.getInstance();
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
ExecutionEnvironment environment = new ExecutionEnvironment(executor, runner, configSettings, module.getProject());
return executeTask(module.getProject(), getMavenProject(), environment, goalBuilder.toString());
}
Aggregations