问题
I would like to create a DMG file from Java.
The reason why it needs to be Java is twofold: It must be part of our build farm (which currently runs on a non Mac OS X platform) and our build uses Maven (which pretty much means Java).
As far as I can a tell inside a DMG file can be an ISO9660 file system. I can create such beast using this but then I still need the part where the whole thing is wrapped in the DMG format. Something like iso2dmg
tool except I need it for Java.
When answering: Forget about the Maven part. If you have a Java solution then I can figure out the Maven stuff myself. (e.g. creating my own little Maven plugin if I need to).
回答1:
You can use the javapackager tool.
A simple, well explained, step by step tutorial on how to create a DMG from java is here: http://centerkey.com/mac/java/
回答2:
The appbundle-maven-plugin works on both Linux and Mac to generate an app bundle(YourProgram.app) and then a .dmg. Make sure you have genisoimage as that's what it uses in Linux to create the dmg.
<plugin>
<groupId>sh.tak.appbundler</groupId>
<artifactId>appbundle-maven-plugin</artifactId>
<version>1.2.0</version>
</plugin>
https://github.com/federkasten/appbundle-maven-plugin
来源:https://stackoverflow.com/questions/30828620/create-mac-dmg-file-from-java