use of org.eclipse.m2e.core.embedder.IMavenExecutionContext in project liferay-ide by liferay.
the class ThemePluginBuildParticipant method build.
@Override
public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {
IMavenProjectFacade facade = getMavenProjectFacade();
if (!shouldBuild(kind, facade)) {
return null;
}
ICallable<IStatus> callable = new ICallable<IStatus>() {
public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
return executeThemeMojo(facade, context, monitor);
}
};
IStatus retval = null;
try {
retval = executeMaven(facade, callable, monitor);
} catch (Exception e) {
retval = LiferayMavenCore.createErrorStatus(getGoal() + " build error", e);
}
if ((retval != null) && !retval.isOK()) {
LiferayMavenCore.log(retval);
}
try {
facade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (CoreException ce) {
}
monitor.worked(10);
return null;
}
use of org.eclipse.m2e.core.embedder.IMavenExecutionContext in project liferay-ide by liferay.
the class MavenProjectBuilder method execGoals.
public IStatus execGoals(List<String> goals, IProgressMonitor monitor) throws CoreException {
IStatus retval = null;
IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), monitor);
ICallable<IStatus> callable = new ICallable<IStatus>() {
public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
IStatus execStatus = MavenUtil.executeGoals(facade, context, goals, monitor);
MavenSession session = context.getSession();
List<Throwable> exceptions = session.getResult().getExceptions();
MultiStatusBuilder multiStatusBuilder = LiferayMavenCore.newMultiStatus();
multiStatusBuilder.add(execStatus);
multiStatusBuilder.addAll(exceptions);
return multiStatusBuilder.retval();
}
};
retval = executeMaven(facade, callable, monitor);
return retval;
}
use of org.eclipse.m2e.core.embedder.IMavenExecutionContext in project liferay-ide by liferay.
the class MavenProjectBuilder method buildLang.
public IStatus buildLang(IFile langFile, IProgressMonitor monitor) throws CoreException {
IProgressMonitor sub = SubMonitor.convert(monitor, 100);
sub.beginTask(Msgs.buildingLanguages, 100);
IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), sub);
sub.worked(10);
ICallable<IStatus> callable = new ICallable<IStatus>() {
public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
return MavenUtil.executeMojoGoal(facade, context, ILiferayMavenConstants.PLUGIN_GOAL_BUILD_LANG, monitor);
}
};
IStatus retval = executeMaven(facade, callable, sub);
sub.worked(80);
getProject().refreshLocal(IResource.DEPTH_INFINITE, sub);
sub.worked(10);
sub.done();
return retval;
}
use of org.eclipse.m2e.core.embedder.IMavenExecutionContext in project liferay-ide by liferay.
the class MavenProjectBuilder method execJarMojo.
public IStatus execJarMojo(IMavenProjectFacade projectFacade, IProgressMonitor monitor) throws CoreException {
IStatus retval = null;
ICallable<IStatus> callable = new ICallable<IStatus>() {
public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
MavenProject mavenProject = projectFacade.getMavenProject();
if (mavenProject == null) {
mavenProject = projectFacade.getMavenProject(monitor);
}
IMaven maven = MavenPlugin.getMaven();
MavenExecutionPlan plan = maven.calculateExecutionPlan(mavenProject, Arrays.asList("jar:jar"), true, monitor);
List<MojoExecution> mojoExecutions = plan.getMojoExecutions();
if (mojoExecutions != null) {
for (MojoExecution mojoExecution : mojoExecutions) {
MavenPlugin.getMaven().execute(mavenProject, mojoExecution, monitor);
}
}
return Status.OK_STATUS;
}
};
retval = executeMaven(projectFacade, callable, monitor);
return retval;
}
use of org.eclipse.m2e.core.embedder.IMavenExecutionContext in project bndtools by bndtools.
the class BndConfigurator method execJarMojo.
private void execJarMojo(final IMavenProjectFacade projectFacade, IProgressMonitor monitor) throws CoreException {
final IMaven maven = MavenPlugin.getMaven();
ProjectRegistryManager projectRegistryManager = MavenPluginActivator.getDefault().getMavenProjectManagerImpl();
ResolverConfiguration resolverConfiguration = new ResolverConfiguration();
resolverConfiguration.setResolveWorkspaceProjects(true);
IMavenExecutionContext context = projectRegistryManager.createExecutionContext(projectFacade.getPom(), resolverConfiguration);
context.execute(new ICallable<Void>() {
@Override
public Void call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor);
MavenProject mavenProject = getMavenProject(projectFacade, progress.newChild(1));
MavenExecutionPlan plan = maven.calculateExecutionPlan(mavenProject, Arrays.asList("jar:jar"), true, monitor);
List<MojoExecution> mojoExecutions = plan.getMojoExecutions();
if (mojoExecutions != null) {
for (MojoExecution mojoExecution : mojoExecutions) {
maven.execute(mavenProject, mojoExecution, progress.newChild(1));
}
}
// We can now decorate based on the build we just did.
try {
IProjectDecorator decorator = Injector.ref.get();
if (decorator != null) {
BndProjectInfo info = new MavenProjectInfo(mavenProject);
decorator.updateDecoration(projectFacade.getProject(), info);
}
} catch (Exception e) {
logger.logError("Failed to decorate project " + projectFacade.getProject().getName(), e);
}
return null;
}
}, monitor);
}
Aggregations