Bug 62789

Summary: Update JAR Task to Specify --module-version Parameter
Product: Ant Reporter: Bruce Alspaugh <alspaughb>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 1.10.1   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Bruce Alspaugh 2018-10-02 05:42:34 UTC
Java 9 and later added several new options to the jar tool. I would like to use the --module-version option with Ant's Jar task, but I could not find that option in the manual. I can accomplish this using exec, but it would be simpler if that option worked with the jar task.
Comment 1 Jan Mat 2018-10-02 10:35:00 UTC
I did a very small test:
- created a simple module-info.java
  module com.greetings { }
- compiled with JDK 10.0.1 (Win7-64bit)
  javac .
- created a module jar with JDK 10
  jar.exe 
    --create 
    --file foo.jar  
    --main-class=com.foo.Main 
    --module-version=1.0 
    .
- compared the JAR with the parameters and the original sources

What I could see is, that
1) the paramater --module-version is placed in the compiled module-info.class file
2) the parameter --main-class is placed in the manifest AND in the compiled module-info.class

Adding the value to the generated manifest should be trivial, but changing the compiled file ... needs discussion. ;-)
Comment 2 Jaikiran Pai 2018-10-03 08:18:37 UTC
FWIW, the --hash-modules option (and some others) of the jar command to plays a role according to[1] in the generated jar file. More specifically, the "Packaging: Modular JAR files" section of [1] has details of these options.

[1] http://openjdk.java.net/jeps/261