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/07/12 22:35:59 UTC

[maven-plugin-tools] branch MPLUGIN-405 created (now 2954cec2)

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

sjaranowski pushed a change to branch MPLUGIN-405
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git


      at 2954cec2 [MPLUGIN-405] Don't print empty Memory, Disk Space in System Requirements

This branch includes the following new commits:

     new 2954cec2 [MPLUGIN-405] Don't print empty Memory, Disk Space in System Requirements

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-plugin-tools] 01/01: [MPLUGIN-405] Don't print empty Memory, Disk Space in System Requirements

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

sjaranowski pushed a commit to branch MPLUGIN-405
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 2954cec2768e7779bf5cfbe149cc35420b03c395
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Wed Jul 13 00:35:01 2022 +0200

    [MPLUGIN-405] Don't print empty Memory, Disk Space in System Requirements
---
 maven-plugin-plugin/src/it/plugin-report/pom.xml   |  3 ++
 .../src/it/plugin-report/verify.bsh                | 56 ----------------------
 .../src/it/plugin-report/verify.groovy             | 28 +++++++++++
 .../apache/maven/plugin/plugin/PluginReport.java   | 28 ++++++-----
 4 files changed, 47 insertions(+), 68 deletions(-)

diff --git a/maven-plugin-plugin/src/it/plugin-report/pom.xml b/maven-plugin-plugin/src/it/plugin-report/pom.xml
index 925acd70..3cdb6896 100644
--- a/maven-plugin-plugin/src/it/plugin-report/pom.xml
+++ b/maven-plugin-plugin/src/it/plugin-report/pom.xml
@@ -81,6 +81,9 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-site-plugin</artifactId>
         <version>@sitePluginVersion@</version>
+        <configuration>
+          <locales>en</locales>
+        </configuration>
       </plugin>
     </plugins>
   </build>
diff --git a/maven-plugin-plugin/src/it/plugin-report/verify.bsh b/maven-plugin-plugin/src/it/plugin-report/verify.bsh
deleted file mode 100644
index 091a10a0..00000000
--- a/maven-plugin-plugin/src/it/plugin-report/verify.bsh
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.*;
-import java.util.*;
-import java.util.regex.*;
-
-try
-{
-    File siteDir = new File( basedir, "target/site" );
-    System.out.println( "Checking for existence of site directory: " + siteDir );
-    if ( !siteDir.isDirectory() )
-    {
-        System.out.println( "FAILED!" );
-        return false;
-    }
-
-    String[] expectedFiles = {
-        "noop-mojo.html",
-        "noop-mojo.html",
-        "report-mojo.html",
-    };
-    for ( String path : expectedFiles )
-    {
-        File file = new File( siteDir, path );
-        System.out.println( "Checking for existence of doc file: " + file );
-        if ( !file.isFile() || file.length() <= 0 )
-        {
-            System.out.println( "FAILED!" );
-            return false;
-        }
-    }
-}
-catch( Throwable t )
-{
-    t.printStackTrace();
-    return false;
-}
-
-return true;
diff --git a/maven-plugin-plugin/src/it/plugin-report/verify.groovy b/maven-plugin-plugin/src/it/plugin-report/verify.groovy
new file mode 100644
index 00000000..0da48db4
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-report/verify.groovy
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+assert new File( basedir, 'target/site/noop-mojo.html' ).isFile()
+assert new File( basedir, 'target/site/report-mojo.html' ).isFile()
+
+def pluginInfo = new File( basedir, 'target/site/plugin-info.html' )
+assert pluginInfo.isFile()
+
+assert !pluginInfo.text.contains('Memory')
+assert !pluginInfo.text.contains('Disk Space')
+assert !pluginInfo.text.contains('No minimum requirement.')
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
index 08894227..0ef02e59 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
@@ -597,19 +597,23 @@ public class PluginReport
                 ( jdk != null ? jdk : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
             sink.tableRow_();
 
-            sink.tableRow();
-            tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.memory" ) );
-            tableCell( ( StringUtils.isNotEmpty( requirements.getMemory() )
-                ? requirements.getMemory()
-                : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
-            sink.tableRow_();
+            String memory = requirements.getMemory();
+            if ( StringUtils.isNotEmpty( memory ) )
+            {
+                sink.tableRow();
+                tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.memory" ) );
+                tableCell( memory );
+                sink.tableRow_();
+            }
 
-            sink.tableRow();
-            tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.diskspace" ) );
-            tableCell( ( StringUtils.isNotEmpty( requirements.getDiskSpace() )
-                ? requirements.getDiskSpace()
-                : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
-            sink.tableRow_();
+            String diskSpace = requirements.getDiskSpace();
+            if ( StringUtils.isNotEmpty( diskSpace ) )
+            {
+                sink.tableRow();
+                tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.diskspace" ) );
+                tableCell( diskSpace );
+                sink.tableRow_();
+            }
 
             if ( requirements.getOthers() != null && requirements.getOthers().size() > 0 )
             {