Re: [maven] 01/01: [MNG-6391] - Printout version of last built module in reactor build

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [maven] 01/01: [MNG-6391] - Printout version of last built module in reactor build

rfscholte
See below...

On Wed, 11 Apr 2018 20:02:45 +0200, <[hidden email]> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> khmarbaise pushed a commit to branch MNG-6391
> in repository https://gitbox.apache.org/repos/asf/maven.git
>
> commit 95c3856eec104b6badc9b4848129eef32722a354
> Author: Karl Heinz Marbaise <[hidden email]>
> AuthorDate: Wed Apr 11 19:42:38 2018 +0200
>
>     [MNG-6391] - Printout version of last built module in reactor build
> ---
>  .../maven/cli/event/ExecutionEventLogger.java      | 32  
> ++++++++++++++++++----
>  1 file changed, 27 insertions(+), 5 deletions(-)
>
> diff --git  
> a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java  
> b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
> index 51d00b7..88f30a1 100644
> ---  
> a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
> +++  
> b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
> @@ -141,6 +141,23 @@ public class ExecutionEventLogger
>          }
>      }
> +    private boolean isSingleVersionedReactor( MavenSession session )
> +    {
> +        boolean result = true;
> +
> +        MavenProject topProject = session.getTopLevelProject();
> +        List<MavenProject> sortedProjects =  
> session.getProjectDependencyGraph().getSortedProjects();
> +        for ( MavenProject mavenProject : sortedProjects )
> +        {
> +            if ( !topProject.getVersion().equals(  
> mavenProject.getVersion() ) )
> +            {
> +                result = false;

please add a break here, no need for further looping.

thanks,
Robert

> +            }
> +        }
> +
> +        return result;
> +    }
> +
>      private void logReactorSummary( MavenSession session )
>      {
>          infoLine( '-' );
> @@ -152,9 +169,8 @@ public class ExecutionEventLogger
>          MavenExecutionResult result = session.getResult();
>         List<MavenProject> projects = session.getProjects();
> -        MavenProject lastProject = projects.get( projects.size() - 1 );
> -        MavenProject topProject = session.getTopLevelProject();
> +        boolean isSingleVersion = isSingleVersionedReactor( session );
>          for ( MavenProject project : projects )
>          {
>              StringBuilder buffer = new StringBuilder( 128 );
> @@ -162,8 +178,7 @@ public class ExecutionEventLogger
>              buffer.append( project.getName() );
>              buffer.append( ' ' );
> -            if ( topProject.equals( project ) || lastProject.equals(  
> project )
> -                || !topProject.getVersion().equals(  
> project.getVersion() ) )
> +            if ( !isSingleVersion )
>              {
>                  buffer.append( project.getVersion() );
>                  buffer.append( ' ' );
> @@ -241,7 +256,14 @@ public class ExecutionEventLogger
>         String wallClock = session.getRequest().getDegreeOfConcurrency()  
> > 1 ? " (Wall Clock)" : "";
> -        logger.info( "Total time: " + formatDuration( time ) +  
> wallClock );
> +        boolean isSingleVersion = isSingleVersionedReactor( session );
> +
> +        if ( isSingleVersion )
> +        {
> +            logger.info( "Version:     " +  
> session.getTopLevelProject().getVersion() );
> +        }
> +
> +        logger.info( "Total time:  " + formatDuration( time ) +  
> wallClock );
>         logger.info( "Finished at: " + formatTimestamp( finish ) );
>      }

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]