Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINVOKER-269] Execute forked Maven in quiet mode #123

Merged
merged 1 commit into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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