use of org.eclipse.m2e.core.project.ResolverConfiguration in project liferay-ide by liferay.
the class MavenUtil method executeGoals.
public static IStatus executeGoals(IMavenProjectFacade facade, IMavenExecutionContext context, List<String> goals, IProgressMonitor monitor) throws CoreException {
IMaven maven = MavenPlugin.getMaven();
MavenProject mavenProject = facade.getMavenProject(monitor);
MavenExecutionPlan plan = maven.calculateExecutionPlan(mavenProject, goals, true, monitor);
List<MojoExecution> mojos = plan.getMojoExecutions();
ResolverConfiguration configuration = facade.getResolverConfiguration();
configuration.setResolveWorkspaceProjects(true);
for (MojoExecution mojo : mojos) {
maven.execute(mavenProject, mojo, monitor);
}
return Status.OK_STATUS;
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project liferay-ide by liferay.
the class ThemePluginBuildParticipant method executeThemeMojo.
protected IStatus executeThemeMojo(IMavenProjectFacade facade, IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
IStatus retval = null;
List<String> goals = Collections.singletonList(getGoal());
MavenProject mavenProject = facade.getMavenProject(monitor);
MavenExecutionPlan plan = maven.calculateExecutionPlan(mavenProject, goals, true, monitor);
monitor.worked(10);
MojoExecution liferayMojoExecution = MavenUtil.getExecution(plan, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_ARTIFACT_ID);
Xpp3Dom originalConfig = liferayMojoExecution.getConfiguration();
Xpp3Dom config = Xpp3DomUtils.mergeXpp3Dom(new Xpp3Dom("configuration"), originalConfig);
configureExecution(facade, config);
boolean parentHierarchyLoaded = false;
try {
parentHierarchyLoaded = MavenUtil.loadParentHierarchy(facade, monitor);
monitor.worked(10);
ResolverConfiguration configuration = facade.getResolverConfiguration();
configuration.setResolveWorkspaceProjects(true);
liferayMojoExecution.setConfiguration(config);
maven.execute(mavenProject, liferayMojoExecution, monitor);
monitor.worked(50);
MavenSession mavenSession = context.getSession();
List<Throwable> exceptions = mavenSession.getResult().getExceptions();
if (exceptions.size() == 1) {
retval = LiferayMavenCore.createErrorStatus(exceptions.get(0));
} else if (exceptions.size() > 1) {
List<IStatus> statuses = new ArrayList<>();
for (Throwable t : exceptions) {
statuses.add(LiferayMavenCore.createErrorStatus(t));
}
retval = LiferayMavenCore.createMultiStatus(IStatus.ERROR, statuses.toArray(new IStatus[0]));
}
retval = retval == null ? Status.OK_STATUS : retval;
} catch (CoreException ce) {
retval = LiferayMavenCore.createErrorStatus(ce);
} finally {
liferayMojoExecution.setConfiguration(originalConfig);
if (parentHierarchyLoaded) {
mavenProject.setParent(null);
}
}
return retval;
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project liferay-ide by liferay.
the class MavenUIProjectBuilder method runMavenGoal.
public IStatus runMavenGoal(IMavenProjectFacade projectFacade, String goal, String mode, IProgressMonitor monitor) throws CoreException {
IStatus retval = Status.OK_STATUS;
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);
IPath basedirLocation = getProject().getLocation();
String newName = launchManager.generateLaunchConfigurationName(basedirLocation.lastSegment());
ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName);
workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, basedirLocation.toString());
workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goal);
workingCopy.setAttribute(MavenLaunchConstants.ATTR_UPDATE_SNAPSHOTS, Boolean.TRUE);
workingCopy.setAttribute(MavenLaunchConstants.ATTR_WORKSPACE_RESOLUTION, Boolean.TRUE);
workingCopy.setAttribute(MavenLaunchConstants.ATTR_SKIP_TESTS, Boolean.TRUE);
if (projectFacade != null) {
ResolverConfiguration configuration = projectFacade.getResolverConfiguration();
String selectedProfiles = configuration.getSelectedProfiles();
if ((selectedProfiles != null) && (selectedProfiles.length() > 0)) {
workingCopy.setAttribute(MavenLaunchConstants.ATTR_PROFILES, selectedProfiles);
}
/*
* <?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration
* type="org.eclipse.m2e.Maven2LaunchConfigurationType"> <booleanAttribute
* key="M2_DEBUG_OUTPUT" value="false"/> <booleanAttribute
* key="M2_NON_RECURSIVE" value="false"/> <booleanAttribute key="M2_OFFLINE"
* value="false"/> <stringAttribute key="M2_PROFILES" value="v6.2.0"/>
* <listAttribute key="M2_PROPERTIES"/> <stringAttribute key="M2_RUNTIME"
* value="EMBEDDED"/> <intAttribute key="M2_THREADS" value="1"/>
* <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY"
* value="D:/dev java/workspaces/runtime-eclipse-ide-juno-sr2/WorldDatabase/WorldDatabase-portlet"
* /> </launchConfiguration>
*/
UIJob launchJob = new UIJob("maven launch") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
DebugUITools.launch(workingCopy, mode);
return Status.OK_STATUS;
}
};
boolean[] launchTerminated = new boolean[1];
ILaunchListener[] listener = new ILaunchListener[1];
listener[0] = new LaunchAdapter() {
public void launchChanged(ILaunch launch) {
if (launch.getLaunchConfiguration().equals(workingCopy)) {
Thread t = new Thread() {
@Override
public void run() {
while ((launch.getProcesses().length > 0) && !launch.getProcesses()[0].isTerminated()) {
try {
sleep(100);
} catch (InterruptedException ie) {
}
}
launchTerminated[0] = true;
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
launchManager.removeLaunchListener(listener[0]);
}
};
t.start();
}
}
};
launchManager = DebugPlugin.getDefault().getLaunchManager();
launchManager.addLaunchListener(listener[0]);
launchJob.schedule();
while ((Display.getCurrent() == null) && !launchTerminated[0]) {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
}
}
}
return retval;
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project liferay-ide by liferay.
the class MavenProjectRemoteServerPublisher method _execMavenLaunch.
private boolean _execMavenLaunch(IProject project, String goal, IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(_launchConfigurationTypeId);
IPath basedirLocation = project.getLocation();
String newName = launchManager.generateLaunchConfigurationName(basedirLocation.lastSegment());
ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName);
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dmaven.multiModuleProjectDirectory");
workingCopy.setAttribute(_attrPomDir, basedirLocation.toString());
workingCopy.setAttribute(_attrGoals, goal);
workingCopy.setAttribute(_attrUpdateSnapshots, Boolean.TRUE);
workingCopy.setAttribute(_attrWorkspaceResolution, Boolean.TRUE);
workingCopy.setAttribute(_attrSkipTests, Boolean.TRUE);
if (facade != null) {
ResolverConfiguration configuration = facade.getResolverConfiguration();
String selectedProfiles = configuration.getSelectedProfiles();
if ((selectedProfiles != null) && (selectedProfiles.length() > 0)) {
workingCopy.setAttribute(_attrProfiles, selectedProfiles);
}
new LaunchHelper().launch(workingCopy, "run", monitor);
return true;
} else {
return false;
}
}
use of org.eclipse.m2e.core.project.ResolverConfiguration in project mdw-designer by CenturyLinkCloud.
the class ProjectConfigurator method addMavenNature.
@SuppressWarnings("deprecation")
public void addMavenNature(IProgressMonitor monitor) throws CoreException {
ResolverConfiguration configuration = new ResolverConfiguration();
configuration.setResolveWorkspaceProjects(false);
configuration.setActiveProfiles("");
IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
configurationManager.enableMavenNature(project.getSourceProject(), configuration, monitor);
configurationManager.updateProjectConfiguration(project.getSourceProject(), monitor);
}
Aggregations