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

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

Introduction

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

Prototype

public String getLifecyclePhase() 

Source Link

Usage

From source file:com.soebes.maven.extensions.MojoTimer.java

License:Apache License

private MojoKey createMojoKey(MojoExecution mojo) {
    return new MojoKey(mojo.getGroupId(), mojo.getArtifactId(), mojo.getVersion(), mojo.getGoal(),
            mojo.getExecutionId(), mojo.getLifecyclePhase());
}

From source file:fr.jcgay.maven.plugin.buildplan.display.AbstractTableDescriptor.java

License:Apache License

protected static Map<TableColumn, Integer> findMaxSize(Collection<MojoExecution> executions,
        TableColumn... columns) {

    Map<TableColumn, Integer> result = new HashMap<TableColumn, Integer>();

    Multimap<TableColumn, Integer> count = ArrayListMultimap.create();
    for (MojoExecution execution : executions) {
        for (TableColumn column : columns) {
            switch (column) {
            case ARTIFACT_ID:
                count.put(column, safeLength(execution.getArtifactId()));
                break;
            case EXECUTION_ID:
                count.put(column, safeLength(execution.getExecutionId()));
                break;
            case GOAL:
                count.put(column, safeLength(execution.getGoal()));
                break;
            case PHASE:
                MojoDescriptor mojoDescriptor = execution.getMojoDescriptor();
                if (mojoDescriptor != null && mojoDescriptor.getPhase() != null) {
                    count.put(column, safeLength(mojoDescriptor.getPhase()));
                } else {
                    count.put(column, safeLength(execution.getLifecyclePhase()));
                }/*w w  w .ja v  a 2 s.co  m*/
            }
        }
    }
    for (TableColumn column : TableColumn.values()) {
        count.put(column, column.title().length());
    }

    for (TableColumn key : count.keySet()) {
        result.put(key, Collections.max(count.get(key)));
    }

    return result;
}

From source file:io.takari.maven.timeline.buildevents.BuildEventListener.java

License:Apache License

private Execution key(ExecutionEvent event) {
    final MojoExecution mojo = event.getMojoExecution();
    final MavenProject project = event.getProject();
    return new Execution(project.getGroupId(), project.getArtifactId(), mojo.getLifecyclePhase(),
            mojo.getGoal(), mojo.getExecutionId());
}

From source file:net.gageot.maven.buildevents.BuildEventListener.java

License:Apache License

private String key(ExecutionEvent event) {
    MojoExecution mojo = event.getMojoExecution();
    String goal = mojo.getGoal();
    String phase = mojo.getLifecyclePhase();
    String group = event.getProject().getGroupId();
    String project = event.getProject().getArtifactId();
    return group + "/" + project + "/" + phase + "/" + goal;
}

From source file:net.rapicault.maveninspector.views.MojoLabelProvider.java

License:Open Source License

@Override
public String getColumnText(Object element, int columnIndex) {
    MojoExecution mojoToPrint = null;
    if (element instanceof MojoExecution) {
        mojoToPrint = (MojoExecution) element;
    } else {/* ww  w.  j  ava  2  s  . co m*/
        return "";
    }

    if (ColumnNames.PHASE.ordinal() == columnIndex) {
        return mojoToPrint.getLifecyclePhase();
    }

    if (ColumnNames.GOAL.ordinal() == columnIndex) {
        return mojoToPrint.getGoal();
    }

    if (ColumnNames.PLUGIN.ordinal() == columnIndex) {
        return mojoToPrint.getPlugin().getId();
    }
    return "";
}

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()));
    }// w ww.  j a  va  2s  .  c o  m
    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.eclipse.m2e.core.project.configurator.MojoExecutionKey.java

License:Open Source License

public MojoExecutionKey(MojoExecution mojoExecution) {
    groupId = mojoExecution.getGroupId();
    artifactId = mojoExecution.getArtifactId();
    version = mojoExecution.getVersion();
    goal = mojoExecution.getGoal();/*  w  w w .j  a v a2s. c  om*/
    executionId = mojoExecution.getExecutionId();
    lifecyclePhase = mojoExecution.getLifecyclePhase();
}

From source file:org.hudsonci.maven.eventspy_30.handler.ExecutionEventHandler.java

License:Open Source License

private void recordMojoStarted(final ExecutionEvent event) {
    if (ExecutionEvent.Type.MojoStarted.equals(event.getType())) {
        MojoExecution mojoExecution = event.getMojoExecution();
        ProjectLogger.log(event.getProject(), "mojo started - " + mojoExecution.getLifecyclePhase() + " "
                + mojoExecution.getArtifactId() + " " + mojoExecution.getExecutionId());

        // There are none.
        //log.debug("Mojo Plugin deps: {}", mojoExecution.getPlugin().getDependencies());
    }/*from w ww.ja v  a  2  s  .  c  om*/
}

From source file:org.jboss.tools.m2e.extras.BuildPathContributorProjectConfigurator.java

License:Open Source License

/**
 * Adds a source or resource folder to the classpath depending on the
 * lifecycle phase of the execution: *-sources map to a source folder;
 * *-resources map to a resource folder. The output folder is set to the
 * test output folder if the phase matches "-test-".
 *///ww w  .  j a va  2s.  com
@Override
public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath,
        IProgressMonitor monitor) throws CoreException {
    IMavenProjectFacade facade = request.getMavenProjectFacade();

    assertHasNature(request.getProject(), JavaCore.NATURE_ID);

    for (MojoExecution mojoExecution : getMojoExecutions(request, monitor)) {
        String lifecyclePhase = mojoExecution.getLifecyclePhase();
        if (lifecyclePhase == null || lifecyclePhase.isEmpty()) {
            continue;
        }
        if (lifecyclePhase.endsWith("-sources")) {
            File[] sources = getSourceFolders(request, mojoExecution);

            for (File source : sources) {
                IPath sourcePath = getFullPath(facade, source);

                if (sourcePath != null && !classpath.containsPath(sourcePath)) {
                    classpath.addSourceEntry(sourcePath,
                            lifecyclePhase.contains("-test-") ? facade.getTestOutputLocation()
                                    : facade.getOutputLocation(),
                            true);
                }
            }
        } else if (lifecyclePhase.endsWith("-resources")) {
            File[] sources = getSourceFolders(request, mojoExecution);

            for (File source : sources) {
                IPath sourcePath = getFullPath(facade, source);

                if (sourcePath != null && !classpath.containsPath(sourcePath)) {
                    classpath.addSourceEntry(sourcePath,
                            lifecyclePhase.contains("-test-") ? facade.getTestOutputLocation()
                                    : facade.getOutputLocation(),
                            new IPath[0], new IPath[] { new Path("**") }, true);
                }
            }
        }
    }
}

From source file:org.jboss.tools.m2e.extras.DependencyUnpackProjectConfigurator.java

License:Open Source License

@Override
public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath,
        IProgressMonitor monitor) throws CoreException {
    IMavenProjectFacade facade = request.getMavenProjectFacade();

    assertHasNature(request.getProject(), JavaCore.NATURE_ID);

    for (MojoExecution mojoExecution : getMojoExecutions(request, monitor)) {
        String lifecyclePhase = mojoExecution.getLifecyclePhase();
        if (lifecyclePhase == null || lifecyclePhase.isEmpty()) {
            continue;
        }/* w  ww .j a  v a 2  s.c  om*/
        if (lifecyclePhase.endsWith("-sources")) {
            File[] sources = getSourceFolders(request, mojoExecution);

            for (File source : sources) {
                IPath sourcePath = getFullPath(facade, source);

                if (sourcePath != null && !classpath.containsPath(sourcePath)) {
                    classpath.addSourceEntry(sourcePath,
                            lifecyclePhase.contains("-test-") ? facade.getTestOutputLocation()
                                    : facade.getOutputLocation(),
                            true);
                }
            }
        } else if (lifecyclePhase.endsWith("-resources")) {
            File[] sources = getSourceFolders(request, mojoExecution);

            for (File source : sources) {
                IPath sourcePath = getFullPath(facade, source);

                if (sourcePath != null && !classpath.containsPath(sourcePath)) {
                    classpath.addSourceEntry(sourcePath,
                            lifecyclePhase.contains("-test-") ? facade.getTestOutputLocation()
                                    : facade.getOutputLocation(),
                            new IPath[0], new IPath[] { new Path("**") }, true);
                }
            }
        }
    }
}