mirror of https://github.com/apache/maven.git
[MNG-7501] add relative path to pom.xml in module build start output
This commit is contained in:
parent
e4f347ed85
commit
c9a3e0e45b
|
@ -23,6 +23,7 @@ import static org.apache.maven.cli.CLIReportingUtils.formatDuration;
|
|||
import static org.apache.maven.cli.CLIReportingUtils.formatTimestamp;
|
||||
import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -333,6 +334,15 @@ public class ExecutionEventLogger
|
|||
infoMain( building + ( ( pad > 0 ) ? chars( ' ', pad ) : "" ) + progress );
|
||||
}
|
||||
|
||||
// path to pom.xml
|
||||
File currentPom = project.getFile();
|
||||
if ( currentPom != null )
|
||||
{
|
||||
MavenSession session = event.getSession();
|
||||
File rootBasedir = session.getTopLevelProject().getBasedir();
|
||||
logger.info( " from " + rootBasedir.toPath().relativize( currentPom.toPath() ) );
|
||||
}
|
||||
|
||||
// ----------[ packaging ]----------
|
||||
prefix = chars( '-', Math.max( 0, ( LINE_LENGTH - project.getPackaging().length() - 4 ) / 2 ) );
|
||||
suffix = chars( '-', Math.max( 0, LINE_LENGTH - project.getPackaging().length() - 4 - prefix.length() ) );
|
||||
|
|
|
@ -23,7 +23,11 @@ import static org.mockito.Mockito.inOrder;
|
|||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.maven.execution.ExecutionEvent;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.shared.utils.logging.MessageUtils;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -56,6 +60,7 @@ public class ExecutionEventLoggerTest
|
|||
when( logger.isInfoEnabled() ).thenReturn( true );
|
||||
executionEventLogger = new ExecutionEventLogger( logger );
|
||||
|
||||
File basedir = new File( "" ).getAbsoluteFile();
|
||||
ExecutionEvent event = mock( ExecutionEvent.class );
|
||||
MavenProject project = mock( MavenProject.class );
|
||||
when( project.getGroupId() ).thenReturn( "org.apache.maven" );
|
||||
|
@ -63,8 +68,15 @@ public class ExecutionEventLoggerTest
|
|||
when( project.getPackaging() ).thenReturn( "jar" );
|
||||
when( project.getName() ).thenReturn( "Apache Maven Embedder" );
|
||||
when( project.getVersion() ).thenReturn( "3.5.4-SNAPSHOT" );
|
||||
when( project.getFile() ).thenReturn( new File( basedir, "maven-embedder/pom.xml" ) );
|
||||
when( event.getProject() ).thenReturn( project );
|
||||
|
||||
MavenProject rootProject = mock( MavenProject.class );
|
||||
when( rootProject.getBasedir() ).thenReturn( basedir );
|
||||
MavenSession session = mock( MavenSession.class );
|
||||
when( session.getTopLevelProject() ).thenReturn( rootProject );
|
||||
when( event.getSession() ).thenReturn( session );
|
||||
|
||||
// execute
|
||||
executionEventLogger.projectStarted( event );
|
||||
|
||||
|
@ -73,6 +85,7 @@ public class ExecutionEventLoggerTest
|
|||
inOrder.verify( logger ).info( "" );
|
||||
inOrder.verify( logger ).info( "------------------< org.apache.maven:maven-embedder >-------------------" );
|
||||
inOrder.verify( logger ).info( "Building Apache Maven Embedder 3.5.4-SNAPSHOT" );
|
||||
inOrder.verify( logger ).info( adaptDirSeparator( " from maven-embedder/pom.xml" ) );
|
||||
inOrder.verify( logger ).info( "--------------------------------[ jar ]---------------------------------" );
|
||||
}
|
||||
|
||||
|
@ -84,6 +97,7 @@ public class ExecutionEventLoggerTest
|
|||
when( logger.isInfoEnabled() ).thenReturn( true );
|
||||
executionEventLogger = new ExecutionEventLogger( logger );
|
||||
|
||||
File basedir = new File( "" ).getAbsoluteFile();
|
||||
ExecutionEvent event = mock( ExecutionEvent.class );
|
||||
MavenProject project = mock( MavenProject.class );
|
||||
when( project.getGroupId() ).thenReturn( "org.apache.maven.plugins.overflow" );
|
||||
|
@ -92,6 +106,12 @@ public class ExecutionEventLoggerTest
|
|||
when( project.getName() ).thenReturn( "Apache Maven Project Info Reports Plugin" );
|
||||
when( project.getVersion() ).thenReturn( "3.0.0-SNAPSHOT" );
|
||||
when( event.getProject() ).thenReturn( project );
|
||||
when( project.getFile() ).thenReturn( new File( basedir, "pom.xml" ) );
|
||||
when( project.getBasedir() ).thenReturn( basedir );
|
||||
|
||||
MavenSession session = mock( MavenSession.class );
|
||||
when( session.getTopLevelProject() ).thenReturn( project );
|
||||
when( event.getSession() ).thenReturn( session );
|
||||
|
||||
// execute
|
||||
executionEventLogger.projectStarted( event );
|
||||
|
@ -101,6 +121,43 @@ public class ExecutionEventLoggerTest
|
|||
inOrder.verify( logger ).info( "" );
|
||||
inOrder.verify( logger ).info( "--< org.apache.maven.plugins.overflow:maven-project-info-reports-plugin >--" );
|
||||
inOrder.verify( logger ).info( "Building Apache Maven Project Info Reports Plugin 3.0.0-SNAPSHOT" );
|
||||
inOrder.verify( logger ).info( adaptDirSeparator( " from pom.xml" ) );
|
||||
inOrder.verify( logger ).info( "----------------------------[ maven-plugin ]----------------------------" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectStartedNoPom()
|
||||
{
|
||||
// prepare
|
||||
Logger logger = mock( Logger.class );
|
||||
when( logger.isInfoEnabled() ).thenReturn( true );
|
||||
executionEventLogger = new ExecutionEventLogger( logger );
|
||||
|
||||
File basedir = new File( "" ).getAbsoluteFile();
|
||||
ExecutionEvent event = mock( ExecutionEvent.class );
|
||||
MavenProject project = mock( MavenProject.class );
|
||||
when( project.getGroupId() ).thenReturn( "org.apache.maven" );
|
||||
when( project.getArtifactId() ).thenReturn( "standalone-pom" );
|
||||
when( project.getPackaging() ).thenReturn( "pom" );
|
||||
when( project.getName() ).thenReturn( "Maven Stub Project (No POM)" );
|
||||
when( project.getVersion() ).thenReturn( "1" );
|
||||
when( event.getProject() ).thenReturn( project );
|
||||
when( project.getFile() ).thenReturn( null );
|
||||
when( project.getBasedir() ).thenReturn( basedir );
|
||||
|
||||
// execute
|
||||
executionEventLogger.projectStarted( event );
|
||||
|
||||
// verify
|
||||
InOrder inOrder = inOrder( logger );
|
||||
inOrder.verify( logger ).info( "" );
|
||||
inOrder.verify( logger ).info( "------------------< org.apache.maven:standalone-pom >-------------------" );
|
||||
inOrder.verify( logger ).info( "Building Maven Stub Project (No POM) 1" );
|
||||
inOrder.verify( logger ).info( "--------------------------------[ pom ]---------------------------------" );
|
||||
}
|
||||
|
||||
private static String adaptDirSeparator( String path )
|
||||
{
|
||||
return FilenameUtils.separatorsToSystem( path );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue