You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/01/18 12:21:42 UTC

[maven-jmod-plugin] branch JMOD-20 created (now abed495)

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

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


      at abed495  MJMOD-20: reorganize groovy script

This branch includes the following new commits:

     new 02d1c73  set jmod --main-class argument if it is set.
     new 9f5d466  Replace String.isBlank() from Java 11 with String.trim().isEmpty().
     new c274a7c  Add integration test.
     new 9642da4  Fix test pom.xml.
     new 762d6f4  Clean up pom.xml to remove Maven plugins from pluginManagement section to use the default ones. Refactor test to become more Groovyish. Set 9+ in invoker.java.version, replacing 1.9+. Set invoker.goals to 'package' only. Use StringUtils.isNotBlank instead of manual check for 'mainClass' parameter.
     new abed495  MJMOD-20: reorganize groovy script

The 6 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-jmod-plugin] 01/06: set jmod --main-class argument if it is set.

Posted by rf...@apache.org.
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 02d1c73ecd44027fc2edbd3cd322e93e72c6dc11
Author: Andre Tadeu de Carvalho <an...@gmail.com>
AuthorDate: Tue Dec 11 23:08:21 2018 -0200

    set jmod --main-class argument if it is set.
---
 src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
index b268372..a977e81 100644
--- a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
@@ -587,6 +587,12 @@ public class JModCreateMojo
             argsFile.println( getPlatformSeparatedList( configList ) );
         }
 
+        if ( mainClass != null && !mainClass.isBlank() )
+        {
+            argsFile.println( "--main-class" );
+            argsFile.println( mainClass );
+        }
+
         List<String> cmdsList = handleConfigurationListWithDefault( cmds, DEFAULT_CMD_DIRECTORY );
         if ( !cmdsList.isEmpty() )
         {


[maven-jmod-plugin] 06/06: MJMOD-20: reorganize groovy script

Posted by rf...@apache.org.
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 abed495c62e2df9315be97a18c547f961eaaa52b
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Jan 18 13:21:34 2019 +0100

    MJMOD-20: reorganize groovy script
---
 src/it/mjmod-20-set-main-class/verify.groovy | 62 ++++++++++++++--------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/it/mjmod-20-set-main-class/verify.groovy b/src/it/mjmod-20-set-main-class/verify.groovy
index 1b74c30..83a0cc7 100644
--- a/src/it/mjmod-20-set-main-class/verify.groovy
+++ b/src/it/mjmod-20-set-main-class/verify.groovy
@@ -20,37 +20,6 @@
 import java.util.jar.JarEntry
 import java.util.jar.JarFile
 
-def validateArtifact( String module, List<String> artifactNames )
-{
-    println( "Checking if ${basedir}/${module}/target exists." )
-    File target = new File( basedir, "/${module}/target" )
-    assert target.isDirectory()
-
-    File artifact = new File( target, "/jmods/myproject.${module}.jmod" )
-    assert artifact.isFile()
-
-    Set contents = new HashSet()
-
-    JarFile jar = new JarFile( artifact )
-    Enumeration jarEntries = jar.entries()
-    while ( jarEntries.hasMoreElements() )
-    {
-        JarEntry entry = (JarEntry) jarEntries.nextElement()
-        println( "Current entry: ${entry}" )
-        if ( !entry.isDirectory() )
-        {
-            // Only compare files
-            contents.add( entry.getName() )
-        }
-    }
-
-    assert artifactNames.size() == contents.size()
-
-    artifactNames.each{ artifactName ->
-        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" ] )
 
@@ -95,4 +64,35 @@ else
             + "${target}/jmods/myproject.greetings.jmod'" )
     System.err.println( serr )
     return false
+}
+
+def validateArtifact( String module, List<String> artifactNames )
+{
+    println( "Checking if ${basedir}/${module}/target exists." )
+    File target = new File( basedir, "/${module}/target" )
+    assert target.isDirectory()
+
+    File artifact = new File( target, "/jmods/myproject.${module}.jmod" )
+    assert artifact.isFile()
+
+    Set contents = new HashSet()
+
+    JarFile jar = new JarFile( artifact )
+    Enumeration jarEntries = jar.entries()
+    while ( jarEntries.hasMoreElements() )
+    {
+        JarEntry entry = (JarEntry) jarEntries.nextElement()
+        println( "Current entry: ${entry}" )
+        if ( !entry.isDirectory() )
+        {
+            // Only compare files
+            contents.add( entry.getName() )
+        }
+    }
+
+    assert artifactNames.size() == contents.size()
+
+    artifactNames.each{ artifactName ->
+        assert contents.contains( artifactName )
+    }
 }
\ No newline at end of file


[maven-jmod-plugin] 02/06: Replace String.isBlank() from Java 11 with String.trim().isEmpty().

Posted by rf...@apache.org.
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 9f5d4664784acad62f4a1f0968c67a549eb44c48
Author: Andre Tadeu de Carvalho <an...@gmail.com>
AuthorDate: Wed Dec 12 15:09:01 2018 -0200

    Replace String.isBlank() from Java 11 with String.trim().isEmpty().
---
 src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
index a977e81..f8ae235 100644
--- a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
@@ -587,7 +587,7 @@ public class JModCreateMojo
             argsFile.println( getPlatformSeparatedList( configList ) );
         }
 
-        if ( mainClass != null && !mainClass.isBlank() )
+        if ( mainClass != null && !mainClass.trim().isEmpty() )
         {
             argsFile.println( "--main-class" );
             argsFile.println( mainClass );


[maven-jmod-plugin] 05/06: Clean up pom.xml to remove Maven plugins from pluginManagement section to use the default ones. Refactor test to become more Groovyish. Set 9+ in invoker.java.version, replacing 1.9+. Set invoker.goals to 'package' only. Use StringUtils.isNotBlank instead of manual check for 'mainClass' parameter.

Posted by rf...@apache.org.
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 762d6f4c2b4f141fdf05607ddde5a3f0bc220980
Author: Andre Tadeu de Carvalho <an...@gmail.com>
AuthorDate: Thu Jan 17 18:13:36 2019 -0200

    Clean up pom.xml to remove Maven plugins from pluginManagement section to use the default ones. Refactor test to become more Groovyish. Set 9+ in invoker.java.version, replacing 1.9+. Set invoker.goals to 'package' only. Use StringUtils.isNotBlank instead of manual check for 'mainClass' parameter.
---
 src/it/mjmod-20-set-main-class/invoker.properties  |   4 +-
 src/it/mjmod-20-set-main-class/pom.xml             |  26 +---
 src/it/mjmod-20-set-main-class/verify.groovy       | 160 +++++++--------------
 .../apache/maven/plugins/jmod/JModCreateMojo.java  |   2 +-
 4 files changed, 57 insertions(+), 135 deletions(-)

diff --git a/src/it/mjmod-20-set-main-class/invoker.properties b/src/it/mjmod-20-set-main-class/invoker.properties
index 8948d9b..eb94c3e 100644
--- a/src/it/mjmod-20-set-main-class/invoker.properties
+++ b/src/it/mjmod-20-set-main-class/invoker.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-invoker.java.version = 1.9+
-invoker.goals = clean package
+invoker.java.version = 9+
+invoker.goals = package
diff --git a/src/it/mjmod-20-set-main-class/pom.xml b/src/it/mjmod-20-set-main-class/pom.xml
index bfbde9b..6a52afe 100644
--- a/src/it/mjmod-20-set-main-class/pom.xml
+++ b/src/it/mjmod-20-set-main-class/pom.xml
@@ -30,8 +30,6 @@
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>1.9</maven.compiler.source>
-        <maven.compiler.target>1.9</maven.compiler.target>
     </properties>
 
     <dependencyManagement>
@@ -49,35 +47,13 @@
         <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
             <plugins>
                 <plugin>
-                    <artifactId>maven-clean-plugin</artifactId>
-                    <version>3.0.0</version>
-                </plugin>
-                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
-                <plugin>
-                    <artifactId>maven-resources-plugin</artifactId>
-                    <version>3.0.2</version>
-                </plugin>
-                <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
                     <version>3.8.0</version>
                     <configuration>
-                        <target>1.9</target>
-                        <source>1.9</source>
+                        <release>9</release>
                     </configuration>
                 </plugin>
-                <plugin>
-                    <artifactId>maven-jar-plugin</artifactId>
-                    <version>3.0.2</version>
-                </plugin>
-                <plugin>
-                    <artifactId>maven-install-plugin</artifactId>
-                    <version>2.5.2</version>
-                </plugin>
-                <plugin>
-                    <artifactId>maven-deploy-plugin</artifactId>
-                    <version>2.8.2</version>
-                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>
diff --git a/src/it/mjmod-20-set-main-class/verify.groovy b/src/it/mjmod-20-set-main-class/verify.groovy
index 1b72b80..1b74c30 100644
--- a/src/it/mjmod-20-set-main-class/verify.groovy
+++ b/src/it/mjmod-20-set-main-class/verify.groovy
@@ -20,133 +20,79 @@
 import java.util.jar.JarEntry
 import java.util.jar.JarFile
 
+def validateArtifact( String module, List<String> artifactNames )
+{
+    println( "Checking if ${basedir}/${module}/target exists." )
+    File target = new File( basedir, "/${module}/target" )
+    assert target.isDirectory()
 
-try {
-    println("Checking if ${basedir}/world/target exists.")
-    File target = new File( basedir, "/world/target" )
-    if ( !target.exists() || !target.isDirectory() ) {
-        System.err.println( "${target.getAbsolutePath()} folder is missing or not a directory." )
-        return false
-    }
-
-    File artifact = new File( target, "/jmods/myproject.world.jmod" )
-    if ( !artifact.exists() || artifact.isDirectory() ) {
-        System.err.println( "${artifact.getAbsolutePath()} file is missing or a directory." )
-        return false
-    }
-
-    String[] artifactNames = [
-            "classes/module-info.class",
-            "classes/myproject/world/World.class"
-    ]
+    File artifact = new File( target, "/jmods/myproject.${module}.jmod" )
+    assert artifact.isFile()
 
     Set contents = new HashSet()
 
     JarFile jar = new JarFile( artifact )
     Enumeration jarEntries = jar.entries()
-    while ( jarEntries.hasMoreElements() ) {
+    while ( jarEntries.hasMoreElements() )
+    {
         JarEntry entry = (JarEntry) jarEntries.nextElement()
-        println("Current entry: ${entry}")
-        if ( !entry.isDirectory() ) {
+        println( "Current entry: ${entry}" )
+        if ( !entry.isDirectory() )
+        {
             // Only compare files
             contents.add( entry.getName() )
         }
     }
 
-    if  ( artifactNames.length != contents.size() ) {
-        System.err.println( "jar content size is different from the expected content size" )
-        return false
-    }
+    assert artifactNames.size() == contents.size()
+
     artifactNames.each{ artifactName ->
-        if ( !contents.contains( artifactName ) ) {
-            System.err.println( "Artifact[" + artifactName + "] not found in jar archive" )
-            return false
-        }
+        assert contents.contains( artifactName )
     }
-} catch ( Throwable e ) {
-    e.printStackTrace()
-    return false
 }
 
-try {
-    println("Checking if ${basedir}/greetings/target exists.")
-    File target = new File( basedir, "/greetings/target" )
-    if ( !target.exists() || !target.isDirectory() ) {
-        System.err.println( "${target.getAbsolutePath()} folder is missing or not a directory." )
-        return false
-    }
-
-    File artifact = new File( target, "/jmods/myproject.greetings.jmod" )
-    if ( !artifact.exists() || artifact.isDirectory() ) {
-        System.err.println( "${artifact.getAbsolutePath()} file is missing or a directory." )
-        return false
-    }
-
-    String[] artifactNames = [
-            "classes/module-info.class",
-            "classes/myproject/greetings/Main.class"
-    ]
-
-    Set contents = new HashSet()
-
-    JarFile jar = new JarFile( artifact )
-    Enumeration jarEntries = jar.entries()
-    while ( jarEntries.hasMoreElements() ) {
-        JarEntry entry = (JarEntry) jarEntries.nextElement()
-        println("Current entry: ${entry}")
-        if ( !entry.isDirectory() ) {
-            // Only compare files
-            contents.add( entry.getName() )
-        }
-    }
-
-    if  ( artifactNames.length != contents.size() ) {
-        System.err.println( "jar content size is different from the expected content size" )
-        return false
-    }
-    artifactNames.each{ artifactName ->
-        if ( !contents.contains( artifactName ) ) {
-            System.err.println( "Artifact[" + artifactName + "] not found in jar archive" )
+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(
+                    "myproject.greetings@99.0",
+                    "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
         }
-    }
-
-    def sout = new StringBuilder(), serr = new StringBuilder()
-    def proc = "jmod describe ${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("myproject.greetings@99.0",
-                "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)
-            }
+        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
+    }
+    if (!expectedLines.isEmpty()) {
+        System.err.println( "This module does not the following items:" )
+        for ( String line : expectedLines )
+        {
+            System.err.println( line )
         }
-        return true
-    } else {
-        System.err.println( "Some error happened while trying to run 'jmod describe "
-                + "${target}/jmods/myproject.greetings.jmod'" )
-        System.err.println(serr)
         return false
     }
-} catch ( Throwable e ) {
-    e.printStackTrace()
-    return false
 }
-
-return true
\ No newline at end of file
+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
diff --git a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
index f8ae235..24589a0 100644
--- a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java
@@ -587,7 +587,7 @@ public class JModCreateMojo
             argsFile.println( getPlatformSeparatedList( configList ) );
         }
 
-        if ( mainClass != null && !mainClass.trim().isEmpty() )
+        if ( StringUtils.isNotBlank( mainClass ) )
         {
             argsFile.println( "--main-class" );
             argsFile.println( mainClass );


[maven-jmod-plugin] 03/06: Add integration test.

Posted by rf...@apache.org.
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 c274a7ce47aae857a121cb80a0d6987bf5de9f93
Author: Andre Tadeu de Carvalho <an...@gmail.com>
AuthorDate: Sat Dec 15 23:37:26 2018 -0200

    Add integration test.
---
 src/it/mjmod-20-set-main-class/greetings/pom.xml   |  95 +++++++++++++
 .../greetings/src/main/java/module-info.java       |  22 +++
 .../src/main/java/myproject/greetings/Main.java    |  29 ++++
 src/it/mjmod-20-set-main-class/invoker.properties  |  18 +++
 src/it/mjmod-20-set-main-class/pom.xml             |  99 ++++++++++++++
 src/it/mjmod-20-set-main-class/verify.groovy       | 152 +++++++++++++++++++++
 src/it/mjmod-20-set-main-class/world/pom.xml       |  85 ++++++++++++
 .../world/src/main/java/module-info.java           |  22 +++
 .../world/src/main/java/myproject/world/World.java |  26 ++++
 9 files changed, 548 insertions(+)

diff --git a/src/it/mjmod-20-set-main-class/greetings/pom.xml b/src/it/mjmod-20-set-main-class/greetings/pom.xml
new file mode 100644
index 0000000..4046bd6
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/greetings/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jmod-plugin-mjmod-20</artifactId>
+        <version>99.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>myproject.greetings</artifactId>
+    <packaging>jmod</packaging>
+
+    <name>myproject.greetings</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>myproject.world</artifactId>
+            <type>jmod</type>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <mainClass>myproject.greetings.Main</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>client</classifier>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jmod-plugin</artifactId>
+                <configuration>
+                    <mainClass>myproject.greetings.Main</mainClass>
+                    <modulePath>target/jmods</modulePath>
+                    <moduleVersion>${project.version}</moduleVersion>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>list</id>
+                        <goals>
+                            <goal>list</goal>
+                        </goals>
+                        <phase>verify</phase>
+                    </execution>
+                    <execution>
+                        <id>describe</id>
+                        <goals>
+                            <goal>describe</goal>
+                        </goals>
+                        <phase>verify</phase>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/src/it/mjmod-20-set-main-class/greetings/src/main/java/module-info.java b/src/it/mjmod-20-set-main-class/greetings/src/main/java/module-info.java
new file mode 100644
index 0000000..f7a143b
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/greetings/src/main/java/module-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+module myproject.greetings {
+    requires myproject.world;
+}
\ No newline at end of file
diff --git a/src/it/mjmod-20-set-main-class/greetings/src/main/java/myproject/greetings/Main.java b/src/it/mjmod-20-set-main-class/greetings/src/main/java/myproject/greetings/Main.java
new file mode 100644
index 0000000..4a0e709
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/greetings/src/main/java/myproject/greetings/Main.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+package myproject.greetings;
+
+import myproject.world.World;
+
+public class Main {
+    public static void main(String[] args) {
+        System.out.format("Greetings %s!%n", World.name());
+    }
+}
+
diff --git a/src/it/mjmod-20-set-main-class/invoker.properties b/src/it/mjmod-20-set-main-class/invoker.properties
new file mode 100644
index 0000000..8948d9b
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+invoker.java.version = 1.9+
+invoker.goals = clean package
diff --git a/src/it/mjmod-20-set-main-class/pom.xml b/src/it/mjmod-20-set-main-class/pom.xml
new file mode 100644
index 0000000..c56f561
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.plugins</groupId>
+    <artifactId>maven-jmod-plugin-mjmod-20</artifactId>
+    <version>99.0</version>
+    <packaging>pom</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.9</maven.compiler.source>
+        <maven.compiler.target>1.9</maven.compiler.target>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>myproject.world</artifactId>
+                <version>${project.version}</version>
+                <type>jmod</type>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
+            <plugins>
+                <plugin>
+                    <artifactId>maven-clean-plugin</artifactId>
+                    <version>3.0.0</version>
+                </plugin>
+                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
+                <plugin>
+                    <artifactId>maven-resources-plugin</artifactId>
+                    <version>3.0.2</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>3.8.0</version>
+                    <configuration>
+                        <target>1.9</target>
+                        <source>1.9</source>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>3.0.2</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-install-plugin</artifactId>
+                    <version>2.5.2</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-deploy-plugin</artifactId>
+                    <version>2.8.2</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jmod-plugin</artifactId>
+                <!--<version>@project.version@</version> -->
+                <version>3.0.0-alpha-2-SNAPSHOT</version>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <modules>
+        <module>world</module>
+        <module>greetings</module>
+    </modules>
+
+</project>
\ No newline at end of file
diff --git a/src/it/mjmod-20-set-main-class/verify.groovy b/src/it/mjmod-20-set-main-class/verify.groovy
new file mode 100644
index 0000000..1b72b80
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/verify.groovy
@@ -0,0 +1,152 @@
+/*
+ * 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.util.jar.JarEntry
+import java.util.jar.JarFile
+
+
+try {
+    println("Checking if ${basedir}/world/target exists.")
+    File target = new File( basedir, "/world/target" )
+    if ( !target.exists() || !target.isDirectory() ) {
+        System.err.println( "${target.getAbsolutePath()} folder is missing or not a directory." )
+        return false
+    }
+
+    File artifact = new File( target, "/jmods/myproject.world.jmod" )
+    if ( !artifact.exists() || artifact.isDirectory() ) {
+        System.err.println( "${artifact.getAbsolutePath()} file is missing or a directory." )
+        return false
+    }
+
+    String[] artifactNames = [
+            "classes/module-info.class",
+            "classes/myproject/world/World.class"
+    ]
+
+    Set contents = new HashSet()
+
+    JarFile jar = new JarFile( artifact )
+    Enumeration jarEntries = jar.entries()
+    while ( jarEntries.hasMoreElements() ) {
+        JarEntry entry = (JarEntry) jarEntries.nextElement()
+        println("Current entry: ${entry}")
+        if ( !entry.isDirectory() ) {
+            // Only compare files
+            contents.add( entry.getName() )
+        }
+    }
+
+    if  ( artifactNames.length != contents.size() ) {
+        System.err.println( "jar content size is different from the expected content size" )
+        return false
+    }
+    artifactNames.each{ artifactName ->
+        if ( !contents.contains( artifactName ) ) {
+            System.err.println( "Artifact[" + artifactName + "] not found in jar archive" )
+            return false
+        }
+    }
+} catch ( Throwable e ) {
+    e.printStackTrace()
+    return false
+}
+
+try {
+    println("Checking if ${basedir}/greetings/target exists.")
+    File target = new File( basedir, "/greetings/target" )
+    if ( !target.exists() || !target.isDirectory() ) {
+        System.err.println( "${target.getAbsolutePath()} folder is missing or not a directory." )
+        return false
+    }
+
+    File artifact = new File( target, "/jmods/myproject.greetings.jmod" )
+    if ( !artifact.exists() || artifact.isDirectory() ) {
+        System.err.println( "${artifact.getAbsolutePath()} file is missing or a directory." )
+        return false
+    }
+
+    String[] artifactNames = [
+            "classes/module-info.class",
+            "classes/myproject/greetings/Main.class"
+    ]
+
+    Set contents = new HashSet()
+
+    JarFile jar = new JarFile( artifact )
+    Enumeration jarEntries = jar.entries()
+    while ( jarEntries.hasMoreElements() ) {
+        JarEntry entry = (JarEntry) jarEntries.nextElement()
+        println("Current entry: ${entry}")
+        if ( !entry.isDirectory() ) {
+            // Only compare files
+            contents.add( entry.getName() )
+        }
+    }
+
+    if  ( artifactNames.length != contents.size() ) {
+        System.err.println( "jar content size is different from the expected content size" )
+        return false
+    }
+    artifactNames.each{ artifactName ->
+        if ( !contents.contains( artifactName ) ) {
+            System.err.println( "Artifact[" + artifactName + "] not found in jar archive" )
+            return false
+        }
+    }
+
+    def sout = new StringBuilder(), serr = new StringBuilder()
+    def proc = "jmod describe ${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("myproject.greetings@99.0",
+                "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
+        }
+        return true
+    } else {
+        System.err.println( "Some error happened while trying to run 'jmod describe "
+                + "${target}/jmods/myproject.greetings.jmod'" )
+        System.err.println(serr)
+        return false
+    }
+} catch ( Throwable e ) {
+    e.printStackTrace()
+    return false
+}
+
+return true
\ No newline at end of file
diff --git a/src/it/mjmod-20-set-main-class/world/pom.xml b/src/it/mjmod-20-set-main-class/world/pom.xml
new file mode 100644
index 0000000..e5a0bb6
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/world/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jmod-plugin-mjmod-20</artifactId>
+        <version>99.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>myproject.world</artifactId>
+    <packaging>jmod</packaging>
+
+    <name>myproject.world</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                        </manifest>
+                    </archive>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>client</classifier>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jmod-plugin</artifactId>
+                <configuration>
+                    <modulePath>target/jmods</modulePath>
+                    <moduleVersion>${project.version}</moduleVersion>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>list</id>
+                        <goals>
+                            <goal>list</goal>
+                        </goals>
+                        <phase>verify</phase>
+                    </execution>
+                    <execution>
+                        <id>describe</id>
+                        <goals>
+                            <goal>describe</goal>
+                        </goals>
+                        <phase>verify</phase>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/src/it/mjmod-20-set-main-class/world/src/main/java/module-info.java b/src/it/mjmod-20-set-main-class/world/src/main/java/module-info.java
new file mode 100644
index 0000000..3077609
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/world/src/main/java/module-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+module myproject.world {
+    exports myproject.world;
+}
\ No newline at end of file
diff --git a/src/it/mjmod-20-set-main-class/world/src/main/java/myproject/world/World.java b/src/it/mjmod-20-set-main-class/world/src/main/java/myproject/world/World.java
new file mode 100644
index 0000000..6509579
--- /dev/null
+++ b/src/it/mjmod-20-set-main-class/world/src/main/java/myproject/world/World.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package myproject.world;
+
+public class World {
+    public static String name() {
+        return "world";
+    }
+}


[maven-jmod-plugin] 04/06: Fix test pom.xml.

Posted by rf...@apache.org.
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 9642da4780d48cad584ff3a7315bac36bbf30eb8
Author: Andre Tadeu de Carvalho <an...@gmail.com>
AuthorDate: Sun Dec 23 01:26:29 2018 -0200

    Fix test pom.xml.
---
 src/it/mjmod-20-set-main-class/pom.xml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/it/mjmod-20-set-main-class/pom.xml b/src/it/mjmod-20-set-main-class/pom.xml
index c56f561..bfbde9b 100644
--- a/src/it/mjmod-20-set-main-class/pom.xml
+++ b/src/it/mjmod-20-set-main-class/pom.xml
@@ -84,8 +84,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jmod-plugin</artifactId>
-                <!--<version>@project.version@</version> -->
-                <version>3.0.0-alpha-2-SNAPSHOT</version>
+                <version>@project.version@</version>
                 <extensions>true</extensions>
             </plugin>
         </plugins>