use of org.eclipse.m2e.core.project.ResolverConfiguration in project azure-tools-for-java by Microsoft.
the class MavenExecuteAction method setProjectConfiguration.
private void setProjectConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IContainer basedir) {
IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
IFile pomFile = basedir.getFile(new Path(IMavenConstants.POM_FILE_NAME));
IMavenProjectFacade projectFacade = projectManager.create(pomFile, false, new NullProgressMonitor());
if (projectFacade != null) {
ResolverConfiguration configuration = projectFacade.getResolverConfiguration();
String selectedProfiles = configuration.getSelectedProfiles();
if (selectedProfiles != null && selectedProfiles.length() > 0) {
workingCopy.setAttribute(MavenLaunchConstants.ATTR_PROFILES, selectedProfiles);
}
}
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project azure-tools-for-java by Microsoft.
the class HDInsightsJavaProjectWizard method performFinish.
@Override
public boolean performFinish() {
try {
CreateProjectUtil.createSampleFile(this.id, this.pageOne.getProjectName(), pageOne.sparkLibraryOptionsPanel.getUsingMaven(), pageOne.sparkLibraryOptionsPanel.getSparkVersion());
} catch (CoreException e) {
Activator.getDefault().log("Create HDInsight project error", e);
}
// Configure Java project first and then enable Maven nature, otherwise the classpath will be overwritten
boolean result = super.performFinish();
if (pageOne.sparkLibraryOptionsPanel.getUsingMaven()) {
try {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
MavenPlugin.getProjectConfigurationManager().enableMavenNature(pageTwo.getJavaProject().getProject(), new ResolverConfiguration(), monitor);
} catch (CoreException e) {
Activator.getDefault().log("Error in enabling Maven nature", e);
}
}
});
} catch (InvocationTargetException | InterruptedException e1) {
Activator.getDefault().log("Fail to enable Maven feature", e1);
}
}
return result;
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project azure-tools-for-java by Microsoft.
the class HDInsightsScalaProjectWizard method performFinish.
@Override
public boolean performFinish() {
try {
CreateProjectUtil.createSampleFile(this.id, this.hdInsightScalaPageOne.getProjectName(), this.isUsingMaven, this.sparkVersion);
} catch (CoreException e) {
Activator.getDefault().log("Create HDInsight project error", e);
}
// Configure Java project first and then enable Maven nature, otherwise the classpath will be overwritten
boolean result = super.performFinish();
if (isUsingMaven) {
try {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
MavenPlugin.getProjectConfigurationManager().enableMavenNature(hdInsightScalaPageTwo.getJavaProject().getProject(), new ResolverConfiguration(), monitor);
} catch (CoreException e) {
Activator.getDefault().log("Error in enabling Maven nature", e);
}
}
});
} catch (InvocationTargetException | InterruptedException e1) {
Activator.getDefault().log("Fail to enable Maven feature", e1);
}
}
return result;
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project azure-tools-for-java by Microsoft.
the class MavenUtils method getMavenProject.
@NotNull
private static MavenProject getMavenProject(@NotNull IFile pom) throws Exception {
final IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
final NullProgressMonitor monitor = new NullProgressMonitor();
if (projectManager == null) {
throw new Exception(CANNOT_GET_REG);
}
final IMavenProjectFacade mavenFacade = projectManager.create(pom, true, monitor);
if (mavenFacade == null) {
throw new Exception(CANNOT_CREATE_FACADE);
}
final MavenProject mavenProject = mavenFacade.getMavenProject(monitor);
if (mavenProject == null) {
throw new Exception(CANNOT_GET_MAVEN_PROJ);
}
final ResolverConfiguration configuration = mavenFacade.getResolverConfiguration();
configuration.setResolveWorkspaceProjects(true);
return mavenProject;
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project liferay-ide by liferay.
the class MavenUtil method executeMojoGoal.
public static IStatus executeMojoGoal(IMavenProjectFacade facade, IMavenExecutionContext context, String goal, IProgressMonitor monitor) throws CoreException {
IStatus retval = null;
IMaven maven = MavenPlugin.getMaven();
List<String> goals = Collections.singletonList(goal);
MavenProject mavenProject = facade.getMavenProject(monitor);
MavenExecutionPlan plan = maven.calculateExecutionPlan(mavenProject, goals, true, monitor);
Plugin plugin6x = getPlugin(facade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
String executionArtifactId = null;
if (plugin6x != null) {
executionArtifactId = ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_ARTIFACT_ID;
} else {
Plugin plugin7x = getPlugin(facade, ILiferayMavenConstants.SERVICE_BUILDER_PLUGIN_KEY, monitor);
if (plugin7x != null) {
executionArtifactId = ILiferayMavenConstants.SERVICE_BUILDER_PLUGIN_ARTIFACT_ID;
}
}
MojoExecution liferayMojoExecution = getExecution(plan, executionArtifactId);
if (liferayMojoExecution != null) {
ResolverConfiguration configuration = facade.getResolverConfiguration();
configuration.setResolveWorkspaceProjects(true);
maven.execute(mavenProject, liferayMojoExecution, monitor);
}
MavenSession session = context.getSession();
List<Throwable> exceptions = session.getResult().getExceptions();
if (exceptions.size() == 1) {
retval = LiferayMavenCore.createErrorStatus(exceptions.get(0));
} else if (exceptions.size() > 1) {
List<IStatus> statues = new ArrayList<>();
for (Throwable t : exceptions) {
statues.add(LiferayMavenCore.createErrorStatus(t));
}
IStatus firstStatus = statues.get(0);
retval = new MultiStatus(LiferayMavenCore.PLUGIN_ID, IStatus.ERROR, statues.toArray(new IStatus[0]), firstStatus.getMessage(), firstStatus.getException());
}
if (retval == null) {
return Status.OK_STATUS;
}
return retval;
}
Aggregations