You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/09/30 16:50:00 UTC

[jira] [Commented] (MJAR-238) Allow setting of module main class

    [ https://issues.apache.org/jira/browse/MJAR-238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16633425#comment-16633425 ] 

ASF GitHub Bot commented on MJAR-238:
-------------------------------------

plamentotev opened a new pull request #2: [MJAR-238] Allow setting of module main class
URL: https://github.com/apache/maven-jar-plugin/pull/2
 
 
   This pull request adds support for modular JAR files. Of course it was possible to create JAR files that contains `module-info.class` but the `jar` tools part of the JDK does more that that. It allows the module main class and version to be specified, adds the list of the packages included in the module and verifies that the module descriptor is correct.
   
   This PR modifies the JAR plugin to use the new `ModularJarArchiver` so the above mentioned information can be added to the module descriptor as well to the validated.  `ModularJarArchiver` handles gracefully non-modular JAR archives so it is safe to be used for all JAR files without prior knowledge if the archive is going to contain `module-info.class` or not.
   
    `ModularJarArchiver` requires the JDK used to run Maven to be 9 or newer in order to modify the module descriptor as the current implementation (`JarToolModularJarArchiver`) uses the JDK `jar` tool and does not support tool chains. If the JDK used is 8 or older then `ModularJarArchiver` will gracefully fallback to treating the archive as regular JAR file and will just pack the module descriptor without modifying or validating it.
   
   The current implementation does not allow the user to specify the module version, but that is not a problem as it is set by the compiler plugin. And if needed could easily be added later - `ModularJarArchiver` already support specifying the module version.
   
   
    - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Allow setting of module main class
> ----------------------------------
>
>                 Key: MJAR-238
>                 URL: https://issues.apache.org/jira/browse/MJAR-238
>             Project: Maven JAR Plugin
>          Issue Type: Improvement
>         Environment: Java9 build 9+176, MacOS
>            Reporter: Machiel Groeneveld
>            Assignee: Robert Scholte
>            Priority: Minor
>
> When a Java9 module is created using the maven-jar plugin, setting the manifest/mainclass does not set the module main class. Therefore the module is not executable without specifying the main class. Executing the module using java -m domain.app gives the following error:
> _module jigsaw.app does not have a MainClass attribute_
> According to the module specification a module (jar) can have a main class set. If I understand correctly it's inside the module-info.class as a property called ModuleMainClass
> When using the JDK9 jar command it will update the jar and the module-info.class.
> {noformat}
>   -e, --main-class=CLASSNAME The application entry point for stand-alone
>                              applications bundled into a modular, or executable,
>                              jar archive
> {noformat}
> I guess it would make sense to have this as a separate configuration item since the mainclass entry in the manifest file is not needed in 'module mode' and vice versa.
> If this is a duplicate of another issue, please close this one, I couldn't find any existing issues related to this.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)