MantisBT - CMake
View Issue Details
0012886CMakeCMakepublic2012-01-19 06:002014-03-05 09:58
Frank Glinka 
Brad King 
normalfeatureN/A
closedfixed 
CMake 2.8.7 
CMake 3.0CMake 3.0 
0012886: Add a manifest or main-class file to the created jar
Hello,

the attached patch introduces two optional options to the add_jar function:

1) CMAKE_JAVA_MANIFEST

   To include name : value attribute pairs from a manifest file in the
   created jar at META-INF/MANIFEST.MF you can set the manifest file with:

        set(CMAKE_JAVA_MANIFEST mymanifest.mf)
        add_jar(foobar foobar.java)

2) CMAKE_JAVA_EXECUTABLE

   To set a class as the application entry point for stand-alone applications
   bundled into an executable jar you can set its name with:

        set(CMAKE_JAVA_EXECUTABLE foo/Main)
        add_jar(foobar foo/Main.java)

The latter one was wasn't my priority but I included it as it was easy to
realize along the first patch. It is easier to use for people only wishing to
create an executable jar than achieving the same by creating a manifest file.

Regards,
Frank

 
P.S. The corresponding discussion for this patch on the mailing list can be
found here: http://www.cmake.org/pipermail/cmake/2011-December/048015.html [^]
No tags attached.
patch java-manifest-executable-option.patch (4,336) 2012-01-19 06:00
https://public.kitware.com/Bug/file/4196/java-manifest-executable-option.patch
patch 0001-Add-MANIFEST-option-to-add_jar.patch (4,774) 2013-09-25 06:11
https://public.kitware.com/Bug/file/4887/0001-Add-MANIFEST-option-to-add_jar.patch
Issue History
2012-01-19 06:00Frank GlinkaNew Issue
2012-01-19 06:00Frank GlinkaFile Added: java-manifest-executable-option.patch
2012-08-11 21:09David ColeStatusnew => backlog
2012-08-11 21:09David ColeNote Added: 0030352
2013-09-25 06:11sebpFile Added: 0001-Add-MANIFEST-option-to-add_jar.patch
2013-09-25 06:12sebpNote Added: 0033884
2013-09-26 08:15Brad KingNote Added: 0033896
2013-09-26 08:19sebpNote Added: 0033898
2013-09-26 08:44Brad KingNote Added: 0033899
2013-09-26 08:45Brad KingAssigned To => Brad King
2013-09-26 08:45Brad KingStatusbacklog => assigned
2013-09-26 08:45Brad KingTarget Version => CMake 3.0
2013-09-26 08:56sebpNote Added: 0033900
2013-09-26 09:08Brad KingNote Added: 0033901
2013-09-26 09:08Brad KingStatusassigned => resolved
2013-09-26 09:08Brad KingResolutionopen => fixed
2013-09-26 09:08Brad KingFixed in Version => CMake 3.0
2014-03-05 09:58Robert MaynardNote Added: 0035270
2014-03-05 09:58Robert MaynardStatusresolved => closed

Notes
(0030352)
David Cole   
2012-08-11 21:09   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0033884)
sebp   
2013-09-25 06:12   
The attached patch adds support for specifying a manifest file in add_jar. Note that MANIFEST conflicts with ENTRY_POINT, thus only one of these options is allowed.
(0033896)
Brad King   
2013-09-26 08:15   
Coincidentally a patch was contributed for this just recently:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69aff17d [^]

Does that solve this?
(0033898)
sebp   
2013-09-26 08:19   
Yes, the patch adds the same features. My patch just adds the check that ENTRY_POINT and MANIFEST are not defined at the same time, otherwise calling "jar" will exit with an error.
(0033899)
Brad King   
2013-09-26 08:44   
According to "man jar" they are both allowed:

 "The letters m, f and e must appear in the same order that manifest, jarfile, entrypoint appear."
(0033900)
sebp   
2013-09-26 08:56   
You are right, it's not allowed to specify the Main-Class attribute in the manifest at the same time as specifying an entry point. Apparently this was the case when I tested it. The patch you linked to is perfectly fine then.
(0033901)
Brad King   
2013-09-26 09:08   
Great, thanks!
(0035270)
Robert Maynard   
2014-03-05 09:58   
Closing resolved issues that have not been updated in more than 4 months