Skip to content

Commit 8458a98

Browse files
[MINVOKER-269] Execute forked Maven in quiet mode
1 parent e3cb4b9 commit 8458a98

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java

+14
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ public abstract class AbstractInvokerMojo
342342
@Parameter( property = "invoker.debug", defaultValue = "false" )
343343
private boolean debug;
344344

345+
/**
346+
* Whether to execute Maven in quiet mode.
347+
*
348+
* @since 3.3.0
349+
*/
350+
@Parameter( property = "invoker.quiet", defaultValue = "false" )
351+
private boolean quiet;
352+
345353
/**
346354
* Suppress logging to the <code>build.log</code> file.
347355
*
@@ -561,6 +569,11 @@ public abstract class AbstractInvokerMojo
561569
* # can be indexed
562570
* invoker.debug = true
563571
*
572+
* # Whether to execute Maven in quiet mode
573+
* # Since plugin version 3.3.0
574+
* # can be indexed
575+
* invoker.quiet = true
576+
*
564577
* The execution timeout in seconds.
565578
* # Since plugin version 3.0.2
566579
* # can be indexed
@@ -2660,6 +2673,7 @@ private InvokerProperties getInvokerProperties( final File projectDirectory, Pro
26602673

26612674
// set default value for Invoker - it will be used if not present in properties
26622675
invokerProperties.setDefaultDebug( debug );
2676+
invokerProperties.setDefaultQuiet( quiet );
26632677
invokerProperties.setDefaultGoals( goals );
26642678
invokerProperties.setDefaultProfiles( profiles );
26652679
invokerProperties.setDefaultMavenExecutable( mavenExecutable );

src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java

+15
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class InvokerProperties
4949

5050
// default values from Mojo configuration
5151
private Boolean defaultDebug;
52+
private Boolean defaultQuiet;
5253
private List<String> defaultGoals;
5354
private List<String> defaultProfiles;
5455
private String defaultMavenOpts;
@@ -69,6 +70,7 @@ private enum InvocationProperty
6970
OFFLINE( "invoker.offline" ),
7071
SYSTEM_PROPERTIES_FILE( "invoker.systemPropertiesFile" ),
7172
DEBUG( "invoker.debug" ),
73+
QUIET( "invoker.quiet" ),
7274
SETTINGS_FILE( "invoker.settingsFile" ),
7375
TIMEOUT_IN_SECONDS( "invoker.timeoutInSeconds" );
7476

@@ -131,6 +133,15 @@ public void setDefaultDebug( boolean defaultDebug )
131133
this.defaultDebug = defaultDebug;
132134
}
133135

136+
/**
137+
* Default value for quiet
138+
* @param defaultQuiet a default value
139+
*/
140+
public void setDefaultQuiet( boolean defaultQuiet )
141+
{
142+
this.defaultQuiet = defaultQuiet;
143+
}
144+
134145
/**
135146
* Default value for goals
136147
* @param defaultGoals a default value
@@ -457,6 +468,10 @@ public void configureInvocation( InvocationRequest request, int index )
457468
.map( Boolean::parseBoolean )
458469
.orElse( defaultDebug ) );
459470

471+
setIfNotNull( request::setQuiet, get( InvocationProperty.QUIET, index )
472+
.map( Boolean::parseBoolean )
473+
.orElse( defaultQuiet ) );
474+
460475
setIfNotNull( request::setTimeoutInSeconds, get( InvocationProperty.TIMEOUT_IN_SECONDS, index )
461476
.map( Integer::parseInt )
462477
.orElse( defaultTimeoutInSeconds ) );

src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java

+32
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,38 @@ public void testConfigureRequestDebug()
363363
clearInvocations( request );
364364
}
365365

366+
@Test
367+
public void testConfigureRequestQuiet()
368+
{
369+
Properties props = new Properties();
370+
InvokerProperties facade = new InvokerProperties( props );
371+
372+
props.setProperty( "invoker.quiet", "true" );
373+
facade.configureInvocation( request, 0 );
374+
verify( request ).setQuiet( true );
375+
verifyNoMoreInteractions( request );
376+
clearInvocations( request );
377+
378+
props.setProperty( "invoker.quiet", "false" );
379+
facade.configureInvocation( request, 0 );
380+
verify( request ).setQuiet( false );
381+
verifyNoMoreInteractions( request );
382+
383+
props.clear();
384+
385+
facade.setDefaultQuiet( true );
386+
facade.configureInvocation( request, 0 );
387+
verify( request ).setQuiet( true );
388+
verifyNoMoreInteractions( request );
389+
clearInvocations( request );
390+
391+
facade.setDefaultQuiet( false );
392+
facade.configureInvocation( request, 0 );
393+
verify( request ).setQuiet( false );
394+
verifyNoMoreInteractions( request );
395+
clearInvocations( request );
396+
}
397+
366398
@Test
367399
public void testConfigureRequestTimeoutInSeconds()
368400
{

0 commit comments

Comments
 (0)