Skip to content

Commit

Permalink
[MINVOKER-269] Execute forked Maven in quiet mode
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed May 23, 2022
1 parent e3cb4b9 commit 8458a98
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
Expand Up @@ -342,6 +342,14 @@ public abstract class AbstractInvokerMojo
@Parameter( property = "invoker.debug", defaultValue = "false" )
private boolean debug;

/**
* Whether to execute Maven in quiet mode.
*
* @since 3.3.0
*/
@Parameter( property = "invoker.quiet", defaultValue = "false" )
private boolean quiet;

/**
* Suppress logging to the <code>build.log</code> file.
*
Expand Down Expand Up @@ -561,6 +569,11 @@ public abstract class AbstractInvokerMojo
* # can be indexed
* invoker.debug = true
*
* # Whether to execute Maven in quiet mode
* # Since plugin version 3.3.0
* # can be indexed
* invoker.quiet = true
*
* The execution timeout in seconds.
* # Since plugin version 3.0.2
* # can be indexed
Expand Down Expand Up @@ -2660,6 +2673,7 @@ private InvokerProperties getInvokerProperties( final File projectDirectory, Pro

// set default value for Invoker - it will be used if not present in properties
invokerProperties.setDefaultDebug( debug );
invokerProperties.setDefaultQuiet( quiet );
invokerProperties.setDefaultGoals( goals );
invokerProperties.setDefaultProfiles( profiles );
invokerProperties.setDefaultMavenExecutable( mavenExecutable );
Expand Down
Expand Up @@ -49,6 +49,7 @@ class InvokerProperties

// default values from Mojo configuration
private Boolean defaultDebug;
private Boolean defaultQuiet;
private List<String> defaultGoals;
private List<String> defaultProfiles;
private String defaultMavenOpts;
Expand All @@ -69,6 +70,7 @@ private enum InvocationProperty
OFFLINE( "invoker.offline" ),
SYSTEM_PROPERTIES_FILE( "invoker.systemPropertiesFile" ),
DEBUG( "invoker.debug" ),
QUIET( "invoker.quiet" ),
SETTINGS_FILE( "invoker.settingsFile" ),
TIMEOUT_IN_SECONDS( "invoker.timeoutInSeconds" );

Expand Down Expand Up @@ -131,6 +133,15 @@ public void setDefaultDebug( boolean defaultDebug )
this.defaultDebug = defaultDebug;
}

/**
* Default value for quiet
* @param defaultQuiet a default value
*/
public void setDefaultQuiet( boolean defaultQuiet )
{
this.defaultQuiet = defaultQuiet;
}

/**
* Default value for goals
* @param defaultGoals a default value
Expand Down Expand Up @@ -457,6 +468,10 @@ public void configureInvocation( InvocationRequest request, int index )
.map( Boolean::parseBoolean )
.orElse( defaultDebug ) );

setIfNotNull( request::setQuiet, get( InvocationProperty.QUIET, index )
.map( Boolean::parseBoolean )
.orElse( defaultQuiet ) );

setIfNotNull( request::setTimeoutInSeconds, get( InvocationProperty.TIMEOUT_IN_SECONDS, index )
.map( Integer::parseInt )
.orElse( defaultTimeoutInSeconds ) );
Expand Down
Expand Up @@ -363,6 +363,38 @@ public void testConfigureRequestDebug()
clearInvocations( request );
}

@Test
public void testConfigureRequestQuiet()
{
Properties props = new Properties();
InvokerProperties facade = new InvokerProperties( props );

props.setProperty( "invoker.quiet", "true" );
facade.configureInvocation( request, 0 );
verify( request ).setQuiet( true );
verifyNoMoreInteractions( request );
clearInvocations( request );

props.setProperty( "invoker.quiet", "false" );
facade.configureInvocation( request, 0 );
verify( request ).setQuiet( false );
verifyNoMoreInteractions( request );

props.clear();

facade.setDefaultQuiet( true );
facade.configureInvocation( request, 0 );
verify( request ).setQuiet( true );
verifyNoMoreInteractions( request );
clearInvocations( request );

facade.setDefaultQuiet( false );
facade.configureInvocation( request, 0 );
verify( request ).setQuiet( false );
verifyNoMoreInteractions( request );
clearInvocations( request );
}

@Test
public void testConfigureRequestTimeoutInSeconds()
{
Expand Down

0 comments on commit 8458a98

Please sign in to comment.