Example usage for org.apache.maven.plugin MojoExecution setLifecyclePhase

List of usage examples for org.apache.maven.plugin MojoExecution setLifecyclePhase

Introduction

In this page you can find the example usage for org.apache.maven.plugin MojoExecution setLifecyclePhase.

Prototype

public void setLifecyclePhase(String lifecyclePhase) 

Source Link

Usage

From source file:org.eclipse.m2e.core.internal.embedder.MavenImpl.java

License:Open Source License

@SuppressWarnings("deprecation")
public MojoExecution setupMojoExecution(MavenSession session, MavenProject project, MojoExecution execution)
        throws CoreException {
    MojoExecution clone = new MojoExecution(execution.getPlugin(), execution.getGoal(),
            execution.getExecutionId());
    clone.setMojoDescriptor(execution.getMojoDescriptor());
    if (execution.getConfiguration() != null) {
        clone.setConfiguration(new Xpp3Dom(execution.getConfiguration()));
    }//from  w  ww.  j  a  v a  2 s  .c  om
    clone.setLifecyclePhase(execution.getLifecyclePhase());
    LifecycleExecutionPlanCalculator executionPlanCalculator = lookup(LifecycleExecutionPlanCalculator.class);
    try {
        executionPlanCalculator.setupMojoExecution(session, project, clone);
    } catch (Exception ex) {
        throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1,
                NLS.bind(Messages.MavenImpl_error_calc_build_plan, ex.getMessage()), ex));
    }
    return clone;
}

From source file:org.sonatype.tycho.m2e.felix.internal.MavenBundlePluginConfigurator.java

License:Open Source License

protected static MojoExecution amendMojoExecution(MavenProject mavenProject, MojoExecution execution,
        Map<String, String> instructions) {
    if ("bundle".equals(execution.getGoal())) {
        // do not generate complete bundle. this is both slow and can produce unexpected workspace changes
        // that will trigger unexpected/endless workspace build.
        // we rely on the fact that ManifestPlugin mojo extends BundlePlugin and does not introduce any
        // additional required parameters, so can run manifest goal in place of bundle goal.
        MojoDescriptor descriptor = execution.getMojoDescriptor().clone();
        descriptor.setGoal("manifest");
        descriptor.setImplementation("org.apache.felix.bundleplugin.ManifestPlugin");
        MojoExecution _execution = new MojoExecution(execution.getPlugin(), "manifest",
                "m2e-tycho:" + execution.getExecutionId() + ":manifest");
        _execution.setConfiguration(execution.getConfiguration());
        _execution.setMojoDescriptor(descriptor);
        _execution.setLifecyclePhase(execution.getLifecyclePhase());
        execution = _execution;//from  ww  w . ja v  a 2s .c  o m
    }

    Xpp3Dom configuration = new Xpp3Dom(execution.getConfiguration());
    if (VERSION_2_3_6.compareTo(new DefaultArtifactVersion(execution.getVersion())) <= 0) {
        setBoolean(configuration, "rebuildBundle", true);
    }

    if (isDeclerativeServices(mavenProject.getBasedir(), instructions)) {
        setBoolean(configuration, "unpackBundle", true);
    }

    execution.setConfiguration(configuration);

    return execution;
}