You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/05/21 17:35:10 UTC

[maven-invoker-plugin] branch MINVOKER-269 created (now 32f3c05)

This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a change to branch MINVOKER-269
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


      at 32f3c05  [MINVOKER-269] Execute forked Maven in quiet mode

This branch includes the following new commits:

     new 32f3c05  [MINVOKER-269] Execute forked Maven in quiet mode

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-invoker-plugin] 01/01: [MINVOKER-269] Execute forked Maven in quiet mode

Posted by sj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch MINVOKER-269
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git

commit 32f3c0551cab91ce9ad2f4e014bc070cef611288
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Sat May 21 19:33:58 2022 +0200

    [MINVOKER-269] Execute forked Maven in quiet mode
---
 .../maven/plugins/invoker/AbstractInvokerMojo.java | 14 ++++++++++
 .../maven/plugins/invoker/InvokerProperties.java   | 15 ++++++++++
 .../plugins/invoker/InvokerPropertiesTest.java     | 32 ++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
index 45f9ffc..53730df 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -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.
      *
@@ -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
@@ -2660,6 +2673,7 @@ public abstract class AbstractInvokerMojo
 
         // 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 );
diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
index ecebdcd..93e4876 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
@@ -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;
@@ -69,6 +70,7 @@ class InvokerProperties
         OFFLINE( "invoker.offline" ),
         SYSTEM_PROPERTIES_FILE( "invoker.systemPropertiesFile" ),
         DEBUG( "invoker.debug" ),
+        QUIET( "invoker.quiet" ),
         SETTINGS_FILE( "invoker.settingsFile" ),
         TIMEOUT_IN_SECONDS( "invoker.timeoutInSeconds" );
 
@@ -131,6 +133,15 @@ class InvokerProperties
         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
@@ -457,6 +468,10 @@ class InvokerProperties
             .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 ) );
diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
index 1deeb11..a414221 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
@@ -363,6 +363,38 @@ public class InvokerPropertiesTest
         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()
     {