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

rfscholte pushed a commit to branch JMOD-20
in repository https://gitbox.apache.org/repos/asf/maven-jmod-plugin.git

commit a146d2c3221d15ca2f53f4e24e410d97df918004
Author: rfscholte <[email protected]>
AuthorDate: Fri Jan 18 14:35:43 2019 +0100

    MJMOD-20: rewrite groovy, Jenkins Pipeline fails to execute jmod command 
directly and catch output
---
 src/it/mjmod-20-set-main-class/invoker.properties |  2 +-
 src/it/mjmod-20-set-main-class/verify.groovy      | 58 +++++++----------------
 2 files changed, 17 insertions(+), 43 deletions(-)

diff --git a/src/it/mjmod-20-set-main-class/invoker.properties 
b/src/it/mjmod-20-set-main-class/invoker.properties
index eb94c3e..8cefaba 100644
--- a/src/it/mjmod-20-set-main-class/invoker.properties
+++ b/src/it/mjmod-20-set-main-class/invoker.properties
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 invoker.java.version = 9+
-invoker.goals = package
+invoker.goals = verify
diff --git a/src/it/mjmod-20-set-main-class/verify.groovy 
b/src/it/mjmod-20-set-main-class/verify.groovy
index 340a7c9..1a1aec3 100644
--- a/src/it/mjmod-20-set-main-class/verify.groovy
+++ b/src/it/mjmod-20-set-main-class/verify.groovy
@@ -23,48 +23,22 @@ import java.util.jar.JarFile
 validateArtifact( "world", [ "classes/module-info.class", 
"classes/myproject/world/World.class" ] )
 validateArtifact( "greetings", [ "classes/module-info.class", 
"classes/myproject/greetings/Main.class" ] )
 
-def sout = new StringBuilder(), serr = new StringBuilder()
-def proc = "jmod describe 
${basedir}/greetings/target/jmods/myproject.greetings.jmod".execute()
-proc.consumeProcessOutput( sout, serr )
-proc.waitForOrKill( 1000 )
-if ( ! sout.toString().trim().isEmpty() && serr.toString().trim().isEmpty() )
-{
-    Set<String> expectedLines = new HashSet(
-            Arrays.asList(
-                    "[email protected]",
-                    "requires java.base mandated",
-                    "requires myproject.world",
-                    "contains myproject.greetings",
-                    "main-class myproject.greetings.Main" ) )
-    String[] lines = sout.toString().split("\n")
-    for ( String line : lines )
-    {
-        if ( ! line.trim().isEmpty() && !expectedLines.contains(line) )
-        {
-            System.err.println( "This line was not returned from jmod: 
${line}" )
-            return false
-        }
-        else
-        {
-            expectedLines.remove(line)
-        }
-    }
-    if (!expectedLines.isEmpty()) {
-        System.err.println( "This module does not the following items:" )
-        for ( String line : expectedLines )
-        {
-            System.err.println( line )
-        }
-        return false
-    }
-}
-else
-{
-    System.err.println( "Some error happened while trying to run 'jmod 
describe "
-            + "${basedir}/greetings/target/jmods/myproject.greetings.jmod'" )
-    System.err.println( serr )
-    return false
-}
+def buildLog = new File(basedir,'build.log')
+
+def describeLines = buildLog.readLines()
+                            .dropWhile{ it != '[INFO] 
[email protected]' } // start line, inclusive
+                            .takeWhile{ !it.startsWith('[INFO] ---') }         
   // end line, inclusive
+                            .grep()                                            
   // remove empty lines
+                            .collect{ it - '[INFO] ' } as Set                  
      // strip loglevel
+
+def expectedLines = [
+                "[email protected]",
+                "requires java.base mandated",
+                "requires myproject.world",
+                "contains myproject.greetings",
+                "main-class myproject.greetings.Main"] as Set
+
+assert describeLines == expectedLines
 
 def validateArtifact(module, artifactNames)
 {

Reply via email to