Java Code Examples for org.apache.maven.execution.MavenSession#getCurrentProject()

The following examples show how to use org.apache.maven.execution.MavenSession#getCurrentProject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
    throws LifecycleExecutionException

{
    if (SkipCheck.skip(session.getCurrentProject().getBasedir())
            && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase)
            .anyMatch(s ->
                    s.contains("group.idealworld.dew:dew-maven-plugin:release")
                            || s.contains("dew:release")
                            || s.contains("deploy"))) {
        return;
    }
    DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );

    PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
    }
}
 
Example 2
Source File: SingleThreadedBuilder.java    From dew with Apache License 2.0 6 votes vote down vote up
public void build(MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds,
                  List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus) {
    for (TaskSegment taskSegment : taskSegments) {
        for (ProjectSegment projectBuild : projectBuilds.getByTaskSegment(taskSegment)) {
            try {
                if (null != session.getCurrentProject() && SkipCheck.skip(session.getCurrentProject().getBasedir())
                        && session.getGoals().stream().map(String::toLowerCase)
                        .anyMatch(s ->
                                s.contains("group.idealworld.dew:dew-maven-plugin:release")
                                        || s.contains("dew:release")
                                        || s.contains("deploy"))) {
                    continue;
                }
                lifecycleModuleBuilder.buildProject(session, reactorContext, projectBuild.getProject(),
                        taskSegment);
                if (reactorBuildStatus.isHalted()) {
                    break;
                }
            } catch (Exception e) {
                break; // Why are we just ignoring this exception? Are exceptions are being used for flow control
            }
        }
    }
}
 
Example 3
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
    throws LifecycleExecutionException

{
    if (SkipCheck.skip(session.getCurrentProject().getBasedir())
            && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase)
            .anyMatch(s ->
                    s.contains("group.idealworld.dew:dew-maven-plugin:release")
                            || s.contains("dew:release")
                            || s.contains("deploy"))) {
        return;
    }
    DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );

    PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
    }
}
 
Example 4
Source File: SingleThreadedBuilder.java    From dew with Apache License 2.0 6 votes vote down vote up
public void build(MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds,
                  List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus) {
    for (TaskSegment taskSegment : taskSegments) {
        for (ProjectSegment projectBuild : projectBuilds.getByTaskSegment(taskSegment)) {
            try {
                if (null != session.getCurrentProject() && SkipCheck.skip(projectBuild.getProject().getBasedir())
                        && session.getGoals().stream().map(String::toLowerCase)
                        .anyMatch(s ->
                                s.contains("group.idealworld.dew:dew-maven-plugin:release")
                                        || s.contains("dew:release")
                                        || s.contains("deploy"))) {
                    continue;
                }
                lifecycleModuleBuilder.buildProject(session, reactorContext, projectBuild.getProject(),
                        taskSegment);
                if (reactorBuildStatus.isHalted()) {
                    break;
                }
            } catch (Exception e) {
                break; // Why are we just ignoring this exception? Are exceptions are being used for flow control
            }
        }
    }
}
 
Example 5
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
        throws LifecycleExecutionException

{
    if (SkipCheck.skip(session.getCurrentProject().getBasedir())
            && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase)
            .anyMatch(s ->
                    s.contains("group.idealworld.dew:dew-maven-plugin:release")
                            || s.contains("dew:release")
                            || s.contains("deploy"))) {
        return;
    }
    DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );

    PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
    }
}
 
Example 6
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
    throws LifecycleExecutionException

{
    if (SkipCheck.skip(session.getCurrentProject().getBasedir())
            && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase)
            .anyMatch(s ->
                    s.contains("group.idealworld.dew:dew-maven-plugin:release")
                            || s.contains("dew:release")
                            || s.contains("deploy"))) {
        return;
    }
    DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );

    PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
    }
}
 
Example 7
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
    throws LifecycleExecutionException

{
    if (SkipCheck.skip(session.getCurrentProject().getBasedir())
            && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase)
            .anyMatch(s ->
                    s.contains("group.idealworld.dew:dew-maven-plugin:release")
                            || s.contains("dew:release")
                            || s.contains("deploy"))) {
        return;
    }
    DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );

    PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
    }
}
 
Example 8
Source File: MutableMojo.java    From java-specialagent with Apache License 2.0 6 votes vote down vote up
static void resolveDependencies(final MavenSession session, final MojoExecution execution, final MojoExecutor executor, final ProjectDependenciesResolver projectDependenciesResolver) throws DependencyResolutionException, LifecycleExecutionException {
//    flushProjectArtifactsCache(executor);

    final MavenProject project = session.getCurrentProject();
    final Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
    final Map<String,List<MojoExecution>> executions = new LinkedHashMap<>(execution.getForkedExecutions());
    final ExecutionListener executionListener = session.getRequest().getExecutionListener();
    try {
      project.setDependencyArtifacts(null);
      execution.getForkedExecutions().clear();
      session.getRequest().setExecutionListener(null);
      executor.execute(session, Collections.singletonList(execution), new ProjectIndex(session.getProjects()));
    }
    finally {
      execution.getForkedExecutions().putAll(executions);
      session.getRequest().setExecutionListener(executionListener);
      project.setDependencyArtifacts(dependencyArtifacts);
    }

    projectDependenciesResolver.resolve(newDefaultDependencyResolutionRequest(session));
  }
 
Example 9
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
    throws LifecycleExecutionException

{
    if (SkipCheck.skip(session.getCurrentProject().getBasedir())
            && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase)
            .anyMatch(s ->
                    s.contains("group.idealworld.dew:dew-maven-plugin:release")
                            || s.contains("dew:release")
                            || s.contains("deploy"))) {
        return;
    }
    DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );

    PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
    }
}
 
Example 10
Source File: SingleThreadedBuilder.java    From dew with Apache License 2.0 6 votes vote down vote up
public void build(MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds,
                  List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus) {
    for (TaskSegment taskSegment : taskSegments) {
        for (ProjectSegment projectBuild : projectBuilds.getByTaskSegment(taskSegment)) {
            try {
                if (null != session.getCurrentProject() && SkipCheck.skip(session.getCurrentProject().getBasedir())
                        && session.getGoals().stream().map(String::toLowerCase)
                        .anyMatch(s ->
                                s.contains("group.idealworld.dew:dew-maven-plugin:release")
                                        || s.contains("dew:release")
                                        || s.contains("deploy"))) {
                    continue;
                }
                lifecycleModuleBuilder.buildProject(session, reactorContext, projectBuild.getProject(),
                        taskSegment);
                if (reactorBuildStatus.isHalted()) {
                    break;
                }
            } catch (Exception e) {
                break; // Why are we just ignoring this exception? Are exceptions are being used for flow control
            }
        }
    }
}
 
Example 11
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
public void execute(MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex)
        throws LifecycleExecutionException {
    if (SkipCheck.skip(session.getCurrentProject().getBasedir())
            && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase)
            .anyMatch(s ->
                    s.contains("group.idealworld.dew:dew-maven-plugin:release")
                            || s.contains("dew:release")
                            || s.contains("deploy"))) {
        return;
    }
    DependencyContext dependencyContext = newDependencyContext(session, mojoExecutions);

    PhaseRecorder phaseRecorder = new PhaseRecorder(session.getCurrentProject());

    for (MojoExecution mojoExecution : mojoExecutions) {
        execute(session, mojoExecution, projectIndex, dependencyContext, phaseRecorder);
    }
}
 
Example 12
Source File: SingleThreadedBuilder.java    From dew with Apache License 2.0 6 votes vote down vote up
public void build(MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds,
                  List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus) {
    for (TaskSegment taskSegment : taskSegments) {
        for (ProjectSegment projectBuild : projectBuilds.getByTaskSegment(taskSegment)) {
            try {
                if (null != session.getCurrentProject() && SkipCheck.skip(session.getCurrentProject().getBasedir())
                        && session.getGoals().stream().map(String::toLowerCase)
                        .anyMatch(s ->
                                s.contains("group.idealworld.dew:dew-maven-plugin:release")
                                        || s.contains("dew:release")
                                        || s.contains("deploy"))) {
                    continue;
                }
                lifecycleModuleBuilder.buildProject(session, reactorContext, projectBuild.getProject(),
                        taskSegment);
                if (reactorBuildStatus.isHalted()) {
                    break;
                }
            } catch (Exception e) {
                break; // Why are we just ignoring this exception? Are exceptions are being used for flow control
            }
        }
    }
}
 
Example 13
Source File: MojoExecutor.java    From dew with Apache License 2.0 5 votes vote down vote up
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<>();
    Set<String> scopesToResolve = new TreeSet<>();

    collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );

    return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}
 
Example 14
Source File: MojoExecutor.java    From dew with Apache License 2.0 5 votes vote down vote up
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<>();
    Set<String> scopesToResolve = new TreeSet<>();

    collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );

    return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}
 
Example 15
Source File: LifecycleStarter.java    From dew with Apache License 2.0 5 votes vote down vote up
private void singleThreadedBuild( MavenSession session, ReactorContext callableContext,
                                  ProjectBuildList projectBuilds, List<TaskSegment> taskSegments,
                                  ReactorBuildStatus reactorBuildStatus )
{
    for ( TaskSegment taskSegment : taskSegments )
    {
        for ( ProjectSegment projectBuild : projectBuilds.getByTaskSegment( taskSegment ) )
        {
            try
            {
                if (null != session.getCurrentProject() && SkipCheck.skip(session.getCurrentProject().getBasedir())
                        && session.getGoals().stream().map(String::toLowerCase)
                        .anyMatch(s ->
                                s.contains("group.idealworld.dew:dew-maven-plugin:release")
                                        || s.contains("dew:release")
                                        || s.contains("deploy"))) {
                    continue;
                }
                lifecycleModuleBuilder.buildProject( session, callableContext, projectBuild.getProject(),
                                                     taskSegment );
                if ( reactorBuildStatus.isHalted() )
                {
                    break;
                }
            }
            catch ( Exception e )
            {
                break;  // Why are we just ignoring this exception? Are exceptions are being used for flow control
            }

        }
    }
}
 
Example 16
Source File: MojoExecutor.java    From dew with Apache License 2.0 5 votes vote down vote up
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<String>();
    Set<String> scopesToResolve = new TreeSet<String>();

    collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );

    return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}
 
Example 17
Source File: MojoExecutor.java    From dew with Apache License 2.0 5 votes vote down vote up
public DependencyContext newDependencyContext(MavenSession session, List<MojoExecution> mojoExecutions) {
    Set<String> scopesToCollect = new TreeSet<String>();
    Set<String> scopesToResolve = new TreeSet<String>();

    collectDependencyRequirements(scopesToResolve, scopesToCollect, mojoExecutions);

    return new DependencyContext(session.getCurrentProject(), scopesToCollect, scopesToResolve);
}
 
Example 18
Source File: MojoExecutor.java    From dew with Apache License 2.0 5 votes vote down vote up
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<>();
    Set<String> scopesToResolve = new TreeSet<>();

    collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );

    return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}
 
Example 19
Source File: MojoExecutor.java    From dew with Apache License 2.0 5 votes vote down vote up
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<>();
    Set<String> scopesToResolve = new TreeSet<>();

    collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );

    return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}
 
Example 20
Source File: MojoExecutor.java    From dew with Apache License 2.0 5 votes vote down vote up
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<String>();
    Set<String> scopesToResolve = new TreeSet<String>();

    collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );

    return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}