Search in sources :

Example 1 with ICallable

use of org.eclipse.m2e.core.embedder.ICallable 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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with ICallable

use of org.eclipse.m2e.core.embedder.ICallable 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;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MultiStatusBuilder(com.liferay.ide.core.util.MultiStatusBuilder) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Example 3 with ICallable

use of org.eclipse.m2e.core.embedder.ICallable 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;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Example 4 with ICallable

use of org.eclipse.m2e.core.embedder.ICallable 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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) MojoExecution(org.apache.maven.plugin.MojoExecution) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) MavenExecutionPlan(org.apache.maven.lifecycle.MavenExecutionPlan) IMaven(org.eclipse.m2e.core.embedder.IMaven)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 ICallable (org.eclipse.m2e.core.embedder.ICallable)4 IMavenExecutionContext (org.eclipse.m2e.core.embedder.IMavenExecutionContext)4 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)3 MultiStatusBuilder (com.liferay.ide.core.util.MultiStatusBuilder)1 MavenSession (org.apache.maven.execution.MavenSession)1 MavenExecutionPlan (org.apache.maven.lifecycle.MavenExecutionPlan)1 MojoExecution (org.apache.maven.plugin.MojoExecution)1 MavenProject (org.apache.maven.project.MavenProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IMaven (org.eclipse.m2e.core.embedder.IMaven)1