Hi David,
Hope this helps with the packaging. I have cut this out of one of my
projects:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>Zip Binary Jar and libs</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>zip</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<arguments>
<argument>-r</argument>
<argument>${project.build.finalName}.zip</argument>
<argument>${project.build.finalName}.jar</argument>
<argument>libs</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>org.myapp.Main</mainClass>
<addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<excludeScope>test</excludeScope>
<outputDirectory>
${project.build.directory}/libs
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The /maven-dependency-plugin/ is used to copy all the dependencies into
the 'libs' directory.
The /maven-jar-plugin/ is used to add the classpathPrefix: 'libs/' to
the manifest. The forward slash at the end is required.
The /exec-maven-plugin/ is used to package everything into a 'zip'
archive for release. Just unpack this zip file on the target system,
and set the CLASSPATH to include the jar file, and all should work.
I have as yet only tested this on my local system.
Cheers,
Brad.
On 4/9/20 9:21 pm, David Gradwell wrote:
Chris,
Hopefully some of the following will help. We too did not want to use
XCode (much!). You have to install it and use certain upload/notarise
tools, but that works.
So, my steps list is:
1. Set up an Apple developer ID, pay fee etc. using an
email – we use a@b.c <mailto:a@b.c> in the following.
2. Create and download a DeveloperID signing cert to your
development Mac's login keychain from
https://developer.apple.com/account/resources/certificates/list
3. Create and download a Developer ID profile to System
Preferences/Profiles.
4. Build your project with Ant since Ant puts all the
library files in a folder called lib in dist. If Maven is your
primary environment, just build the top level of the project with
Ant. If you know how to make Maven put all the dependencies in one
place ready for jpackage please tell me !
5. Local test the Ant project and if it behaves proceed.
6. Make a Mac icon.
7. Using the pre-release Java 15 (you will have to download
it) then run jpackage with something like the following script. I’ve
hacked it a bit for confidentiality reasons. There may be some space
characters that need removing!.
export JAVA_HOME="/Users/myuser/Java Downloads/jdk-15.jdk/Contents/Home"
export PATH="
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/myuser/Java
Downloads/jdk-15.jdk/Contents/Home/bin"
echo $PATH
rm -r /Users/myuser/NetBeansDev/MYAPPNAMEAnt/jpackageappimagetemp
rm -r /Users/myuser/NetBeansDev/MYAPPNAMEAnt/jpackageappimageoutput
jpackage --type app-image --app-version 0.0.1 --copyright "My company
2020" --name MYAPPNAME --dest
/Users/myuser/NetBeansDev/MYAPPNAMEAnt/jpackageappimageoutput --temp
/Users/myuser/NetBeansDev/MYAPPNAMEAnt/jpackageappimagetemp --vendor
"My Company" --icon
/Users/myuser/NetBeansDev/MYAPPNAMEAnt/MYAPPNAME.icns --input
/Users/myuser/NetBeansDev/MYAPPNAMEAnt/dist --main-jar
MYAPPNAMEAnt.jar --main-class com.you MYAPPNAME.SomeClass
--java-options " -Xdock:name=MYAPPNAME" --mac-package-identifier
MYAPPNAME --mac-sign --mac-signing-keychain
"/Users/myuser/Library/Keychains/login.keychain-db" --verbose
8. Check that the signing worked and that the app has
appeared at
/Users/myuser/NetBeansDev/MYAPPNAMEAnt/jpackageappimageoutput/MYAPPNAME.app
and that it is double clickable and passes basic testing. Make a
backup of what you have created.
9. Zip the .app using Finder compress.
10. Upload
See
https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow
section on “Upload Your App to the Notarization Service”.
Create an application password using the Apple
Developer site..
xcrun altool --notarize-app --primary-bundle-id
"MyAppNotarisation4Sept2020" --username a@b.c <mailto:a@b.c>
--password "Apple generated app password" --file
/Users/myuser/NetBeansDev/MYAPPNAMEAnt/jpackageappimageoutput/MYAPPNAME.app.zip
--verbose
Look at the output carefully and hope you get an email.
11. Check the notarization history
xcrun altool --notarization-history 0 --username a@b.c <mailto:a@b.c>
--password "Apple generated app password"
12. Staple the .app
xcrun stapler staple
"/Users/myuser/NetBeansDev/MYAPPNAMEAnt/jpackageappimageoutput/MYAPPNAME.app"
13. Test: You can now put the .app on your web site, down
load it, copy it /Applications on any machine and then double click it.
We have also succeeded in making an installer and a .dmg. The .dmg
has to be made from the stapled .app. This process is less tested.
Let me know if you get the above to work and I will share.
As mentioned, I’m working on a Java app to do all the above with one
click – not finished yet !!
Regards
David
On 04/09/2020, 13:32, "Chris Olsen" <col...@mchsi.com> wrote:
David --
I am much interested in your statement...
> We have also mastered the issues around Apple notarization
needed to distribute an .app or .dmg.
Can elaborate on this? Or better yet provide some code or
script to make this happen? I do NOT want to mess with XCode!!
-- Chris
----- Original Message -----
From: "David Gradwell" <da...@gradwell.com>
To: "HRH" <hrh...@yahoo.com.INVALID>, "users"
<users@netbeans.apache.org>
Sent: Friday, September 4, 2020 5:24:18 AM
Subject: Re: Maven deployment plugin for JavaFX
I have exactly the same question for any standard Java
application. In previous versions of NetBeans an Ant project used to
provide this capability but Ant package as seems to be broken in
NetBeans 12. For example, using:
Product Version: Apache NetBeans IDE 12.0
Java: 14.0.1; OpenJDK 64-Bit Server VM 14.0.1+7
Runtime: OpenJDK Runtime Environment 14.0.1+7
We get /AntProject/nbproject/build-native.xml:519: typedef class
com.sun.javafx.tools.ant.FXJar cannot be found
using the classloader AntClassLoader[].
In order to use Maven which as you say appears not to support we
now use jpackage successfully. We have also mastered the issues around
Apple notarization needed to distribute an .app or .dmg.
So now we are working on a Java app that will do all the steps in
one click for any application !
I agree it would be nice to find a NetBeans plugin for Maven to do
all the packaging. If one needs writing then I am happy to contribute
the logic and worked examples.
David Gradwell