This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jmod-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 45e710e [MJMOD-20] Fix ITs when running with Jenkins Pipeline
45e710e is described below
commit 45e710e9110688fc6d4aaa0fd13e71b58acac142
Author: rfscholte <[email protected]>
AuthorDate: Fri Jan 18 14:55:20 2019 +0100
[MJMOD-20] Fix ITs when running with Jenkins Pipeline
---
src/it/mjmod-20-set-main-class/invoker.properties | 2 +-
src/it/mjmod-20-set-main-class/verify.groovy | 74 ++++++++---------------
2 files changed, 25 insertions(+), 51 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 1b74c30..62d0712 100644
--- a/src/it/mjmod-20-set-main-class/verify.groovy
+++ b/src/it/mjmod-20-set-main-class/verify.groovy
@@ -20,13 +20,33 @@
import java.util.jar.JarEntry
import java.util.jar.JarFile
-def validateArtifact( String module, List<String> artifactNames )
+validateArtifact( "world", [ "classes/module-info.class",
"classes/myproject/world/World.class" ] )
+validateArtifact( "greetings", [ "classes/module-info.class",
"classes/myproject/greetings/Main.class" ] )
+
+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)
{
println( "Checking if ${basedir}/${module}/target exists." )
- File target = new File( basedir, "/${module}/target" )
- assert target.isDirectory()
+ def targetDir = new File( basedir, "/${module}/target" )
+ assert targetDir.isDirectory()
- File artifact = new File( target, "/jmods/myproject.${module}.jmod" )
+ File artifact = new File( targetDir, "/jmods/myproject.${module}.jmod" )
assert artifact.isFile()
Set contents = new HashSet()
@@ -50,49 +70,3 @@ def validateArtifact( String module, List<String>
artifactNames )
assert contents.contains( artifactName )
}
}
-
-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 "
- + "${target}/jmods/myproject.greetings.jmod'" )
- System.err.println( serr )
- return false
-}
\ No newline at end of file