Git Product home page Git Product logo

fvarrui / javapackager Goto Github PK

View Code? Open in Web Editor NEW
1.0K 15.0 129.0 6.51 MB

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.

License: GNU General Public License v3.0

Java 79.37% Shell 11.71% Velocity Template Language 8.90% Groovy 0.03%
java packager maven-plugin native installer debian-packages rpm-packages dmg maven distribution

javapackager's Introduction

JavaPackager

Maven Central GPL-3.0

JavaPackager is a hybrid plugin for Maven and Gradle which provides an easy way to package Java applications in native Windows, MacOS or GNU/Linux executables, and generate installers for them.

History

It was born while teaching to my students how to build and distribute their Java apps, and after seeing that a chain of several plugins was needed to achieve this task, I decided to develop a plugin πŸ’ to rule them all.

Apps packaged with JavaPackager

How to use this plugin

Package your app with Maven

Add the following plugin tag to your pom.xml:

<plugin>
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>{latest.version}</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>package</goal>
            </goals>
            <configuration>
                <!-- mandatory -->
                <mainClass>path.to.your.mainClass</mainClass>
                <!-- optional -->
                <bundleJre>true|false</bundleJre>
                <generateInstaller>true|false</generateInstaller>
                <administratorRequired>true|false</administratorRequired>
                <platform>auto|linux|mac|windows</platform>
                <additionalResources>
                    <additionalResource>file path</additionalResource>
                    <additionalResource>folder path</additionalResource>
                    <additionalResource>...</additionalResource>
                </additionalResources>
                <linuxConfig>...</linuxConfig>
                <macConfig>...</macConfig>
                <winConfig>...</winConfig>
                [...]
            </configuration>
        </execution>
    </executions>
</plugin>

And execute the next command in project's root folder:

mvn package

Package your app with Gradle

Apply JavaPackager plugin in build.gradle using legacy mode (because at the moment it's only available in Maven Central repository):

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'io.github.fvarrui:javapackager:{latest.version}'
    }
}

apply plugin: 'io.github.fvarrui.javapackager.plugin'

Create your packaging task:

task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
    // mandatory
    mainClass = 'path.to.your.mainClass'
    // optional
    bundleJre = true|false
    generateInstaller = true|false
    administratorRequired = true|false
    platform = "auto"|"linux"|"mac"|"windows"
    additionalResources = [ file('file path'), file('folder path'), ... ]
    linuxConfig {
        ...
    }
    macConfig {
        ...
    }
    winConfig {
        ...
    }
    ...
}

And execute the next command in project's root folder:

gradle packageMyApp

Generated artifacts

By default it will generate next artifacts in ${outputDirectory} folder:

Artifact Description Platform Requires
${name} Directory with native application and other assets. All
${name}-${version}-runnable.jar Runnable JAR file. All
${name}_${version}.AppImage AppImage package file. GNU/Linux FUSE 2 to run the app.
${name}_${version}.deb DEB package file. All
${name}_${version}.rpm RPM package file. All
${name}_${version}.exe Setup file. Windows Inno SetupΒ (isccΒ command must be in PATH variable)
${name}_${version}.msi MSI installer file. Windows WiX ToolsetΒ (candleΒ and light commands must be in PATH variable)
${name}_${version}.msm MSI merge module file. Windows WiX ToolsetΒ (Β candleΒ and light commands must be in PATH variable)
${name}_${version}.dmg Disk image file (uses hdiutil). MacOS
${name}_${version}.pkg PKG installer file (uses pkgbuild). MacOS
${name}-${version}-${platform}.zip Zipball containing generated directory ${name}. All
${name}-${version}-${platform}.tar.gz Compressed tarball containing generated directory ${name}. All
assets Directory with all intermediate files generated by JavaPackager. All

Tip

Inno Setup and WiX Toolset installation guide.

Plugin configuration properties

Property Mandatory Default value Description
additionalModulePaths ❌ [] Additional module paths for jdeps.
additionalModules ❌ [] Additional modules to the ones identified by jdeps or the specified with modules property.
additionalResources ❌ [] Additional files and folders to include in the bundled app.
arch ❌ ${os.arch} The dependency of some ArtifactGenerator objects in the process of making packages, such as GenerateDeb
administratorRequired ❌ false App will run as administrator (with elevated privileges).
assetsDir ❌ ${basedir}/assets or ${projectdir}/assets Assets location (icons and custom Velocity templates).
bundleJre ❌ false Embeds a customized JRE with the app.
classpath ❌ List of additional paths to JVM classpath, separated with ; (recommended) or :.
copyDependencies ❌ true Bundles all dependencies (JAR files) with the app.
createTarball ❌ false Bundles app folder in tarball.
createZipball ❌ false Bundles app folder in zipball.
customizedJre ❌ true Generates a customized JRE, including only identified or specified modules. Otherwise, all modules will be included.
description ❌ ${project.description} or ${displayName} Project description.
displayName ❌ ${project.name} or ${name} App name to show.
envPath ❌ Defines PATH environment variable in GNU/Linux and MacOS startup scripts.
extra ❌ Map with extra properties to be used in customized Velocity templates, accesible through $info.extra variable.
fileAssociations ❌ FileAssociation[] Associate file extensions or MIME types to the app.
forceInstaller ❌ false If true, skips operating system check when generating installers.
generateInstaller ❌ true Generates an installer for the app.
jdkPath ❌ ${java.home} JDK used to generate a customized JRE. It allows to bundle customized JREs for different platforms.
jreDirectoryName ❌ "jre" Bundled JRE directory name.
jreMinVersion ❌ JRE minimum version. If an appropriate version cannot be found display error message. Disabled if a JRE is bundled.
jrePath ❌ "" Path to JRE folder. If specified, it will bundle this JRE with the app, and won't generate a customized JRE. For Java 8 version or least.
licenseFile ❌ ${project.licenses[0].url} or ${basedir}/LICENSE or ${projectdir}/LICENSE Path to project license file.
mainClass βœ”οΈ ${exec.mainClass} Full path to your app main class.
manifest ❌ Allows adding additional entries to MANIFEST.MF file.
modules ❌ [] Modules to customize the bundled JRE. Don't use jdeps to get module dependencies.
name ❌ ${project.name} or ${project.artifactId} App name.
organizationName ❌ ${project.organization.name} or "ACME" Organization name.
organizationUrl ❌ ${project.organization.url} Organization website URL.
organizationEmail ❌ Organization email.
outputDirectory ❌ ${project.build.directory} or ${project.builddir} Output directory (where the artifacts will be generated).
packagingJdk ❌ ${java.home} JDK used in the execution of jlink and other JDK tools.
platform ❌ auto Defines the target platform, which could be different to the execution platform. Possible values: auto, mac, linux, windows. Use auto for using execution platform as target.
runnableJar ❌ Defines your own JAR file to be bundled. If it's ommited, the plugin packages your code in a runnable JAR and bundle it with the app.
scripts ❌ Specify bootstrap script. Pre and post-install scripts comming soon!
url ❌ App website URL.
useResourcesAsWorkingDir ❌ true Uses app resources folder as default working directory (always true on MacOS).
version ❌ ${project.version} App version.
vmArgs ❌ [] VM arguments.

Important

Some default values depends on the used building tool.

Platform specific properties

Property Mandatory Description
linuxConfig ❌ GNU/Linux specific properties.
macConfig ❌ MacOS specific properties.
winConfig ❌ Windows specific properties.

Warning

Be careful when using the platform property if your project uses platform dependent libraries, so the libraries of the current platform will be copied, not those required for the target platform. You can solve this problem using classifiers.

Plugin assets

Any asset used by JavaPackager, such as application icons or templates, can be replaced just by placing a file with the same name in ${assetsDir} folder organized by platform.

${assetsDir}/
β”œβ”€β”€ linux/
β”œβ”€β”€ mac/
└── windows/

Icons

If icons are located in ${assetsDir} folder, it would not be necessary to use icon properties:

${assetsDir}/
β”œβ”€β”€ linux/
β”‚   └── ${name}.png     # on GNU/Linux it has to be a PNG file
β”œβ”€β”€ mac/
β”‚   └── ${name}.icns    # on MacOS it has to be a ICNS file
└── windows/
    └── ${name}.ico     # on Windows it has to be a ICO file

Warning

If icon is not specified , it will use an icon by default for all platforms.

Templates

Velocity templates (.vtl files) are used to generate some artifacts which have to be bundled with the app or needed to generate other artifacts.

It is possible to use your own customized templates. You just have to put one of the following templates in the ${assetsDir} folder organized by platform, and the plugin will use these templates instead of default ones:

${assetsDir}/
β”œβ”€β”€ linux/
|   β”œβ”€β”€ assembly.xml.vtl               # maven-assembly-plugin template to generate ZIP/TGZ bundles for GNU/Linux
|   β”œβ”€β”€ control.vtl                    # DEB control template
|   β”œβ”€β”€ desktop.vtl                    # Desktop template
|   β”œβ”€β”€ desktop-appimage.vtl           # AppImage format Desktop template
|   β”œβ”€β”€ mime.xml.vtl                   # MIME.XML template
β”‚   └── startup.sh.vtl                 # Startup script template
β”œβ”€β”€ mac/
|   β”œβ”€β”€ assembly.xml.vtl               # maven-assembly-plugin template to generate ZIP/TGZ bundles for MacOS
|   β”œβ”€β”€ customize-dmg.applescript.vtl  # DMG customization Applescript template
|   β”œβ”€β”€ Info.plist.vtl                 # Info.plist template
β”‚   └── startup.vtl                    # Startup script template
└── windows/
    β”œβ”€β”€ assembly.xml.vtl               # maven-assembly-plugin template to generate ZIP/TGZ bundles for Windows
    β”œβ”€β”€ exe.manifest.vtl               # exe.manifest template
    β”œβ”€β”€ ini.vtl                        # WinRun4J INI template
    β”œβ”€β”€ iss.vtl                        # Inno Setup Script template
    β”œβ”€β”€ msm.wxs.vtl                    # WiX Toolset WXS template to generate Merge Module
    β”œβ”€β”€ startup.vbs.vtl                # Startup script template (VB Script)
    β”œβ”€β”€ why-ini.vtl                    # WHY INI template
    └── wxs.vtl                        # WiX Toolset WXS template to generate MSI

An object called info of type PackagerSettings is passed to all templates with all plugin properties.

You can use default templates as examples to create your own templates, and use the extra map property to add your own properties in the plugin settings to use in your custom templates (e.g. ${info.extra["myProperty"]}).

Additional JVM options at runtime

When you build your app, all configuration details are hardcoded into the executable and cannot be changed without recreating or hacking it with a resource editor. JavaPackager introduces a feature that allows to pass additional JVM options at runtime from an .l4j.ini file (like Launch4j does, but available for all platforms in the same way). So, you can specify these options in the packager's configuration (packaging time), in INI file (runtime) or in both.

The INI file's name must correspond to ${name}.l4j.ini and it has to be located next to the executable on Windows and GNU/Linux, and in Resources folder on MacOS.

The options should be separated with spaces or new lines:

# Additional JVM options
-Dswing.aatext=true
-Dsomevar="%SOMEVAR%"
-Xms16m

Important

An VM argument per line.

And then bundle this file with your app:

<additionalResources>
    <additionalResource>${name}.l4j.ini</additionalResource>
</additionalResources>

Note

Last property copies ${name}.l4j.ini file next to the EXE/binary on Windows/Linux, and in Resources folder on MacOS.

How to use SNAPSHOT versions

Here you can find the uploaded JavaPackager SNAPSHOT versions.

Maven

Add the plugin repository to your pom.xml:

<pluginRepositories>
    <pluginRepository>
        <id>nexus</id>
        <name>nexus-snapshot-repository</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>

And then you can use the latest SNAPSHOT version:

<plugin>    
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>{javapackager.version}-SNAPSHOT</version>
    [...]
</plugin>

Or a specific SNAPSHOT version (specifying its timestamp and index):

<plugin>
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>{javapackager.version}-{timestamp}-{index}</version>
    [...]
</plugin>

SNAPSHOT version example: 1.7.2-20230505.095442-5.

Gradle

Add the plugin repository to your build.gradle and use the latest SNAPSHOT version:

buildscript {
    repositories {
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots"
        }
    }
    dependencies {
        classpath 'io.github.fvarrui:javapackager:{javapackager.version}-SNAPSHOT'
    }
}

Or set a specific SNAPSHOT version specifying its timestamp and index:

buildscript {
    [...]
    dependencies {
        classpath 'io.github.fvarrui:javapackager:{javapackager.version}-{timestamp}-{index}'
    }
}

SNAPSHOT version example: 1.7.2-20230505.095442-5.

How to build and install the plugin in your local repo

Execute next commands in BASH (GNU/Linux or macOS) or CMD (Windows):

  1. Download source code and change to the project directory:
git clone https://github.com/fvarrui/JavaPackager.git [--branch devel]
cd JavaPackager
  1. Compile, package and install the plugin in your local repository (ommit ./ on Windows):
./gradlew publishToMavenLocal

Important

It is recommended to build the plugin with Java 19.

How to release the plugin to Maven Central

Run next command (ommit ./ on Windows):

./gradlew publish closeAndReleaseRepository

javapackager's People

Contributors

airlenet avatar antoninhuaut avatar astropixelprocessor avatar commi avatar cristiangreco avatar dexman545 avatar easyg0ing1 avatar farzadpanahi avatar fvarrui avatar gradle-update-robot avatar gregoirekourdouli avatar jyoo980 avatar keastrid avatar kerner1000 avatar lhdream avatar maths22 avatar mica-alex avatar mlopezfc avatar ogerardin avatar orange-guo avatar osiris-team avatar pyeroh avatar ricardovargasleslie avatar saptarshisarkar12 avatar swissbuechi avatar treimers avatar zfqjava avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javapackager's Issues

Building for different OS with optimized JRE

Hi, thanks for the great plugin!
I have one question though:

I'm currently building on Windows and my goal is to let this plugin analyze my code to get the minimal required modules and build a custom JRE which is bundled as an executable for Windows+Linux+MacOS (I don't need an installer).

I have got it running for Windows by using a JDK11 to build and the following config:

<configuration>
	<mainClass>test.Main</mainClass>
	<bundleJre>true</bundleJre>
	<generateInstaller>false</generateInstaller>
</configuration>

Now I'm trying to get the outputs for Linux+MacOS, but it doesnt work because the Java version I'm using is on Windows, so my guess was that if I configure something like the following:

<configuration>
	<mainClass>test.Main</mainClass>
	<bundleJre>true</bundleJre>
	<generateInstaller>false</generateInstaller>
	<jrePath>PATH_TO_LINUX_JAVA</jrePath>
	<platform>linux</platform>
</configuration>

should work, and it seems to create a correct output bundle.
Unfortunately the module analysis seems to be missing (so no optimized JRE is generated) which means the output zip has 200MB (the windows version with the optimized JRE has 40MB)

I have checked https://github.com/ElderResearch/JavaPackager/blob/master/src/main/java/fvarrui/maven/plugin/javapackager/PackageMojo.java and it seems that getRequiredModules() is only called when no JRE is specified which means it doesnt work for another OS right?

Is there a way to build optimized JREs for other OSes than the one the build is running? I haven't used jlink other than through this plugin, but according to https://stackoverflow.com/questions/47593409/create-java-runtime-image-on-one-platform-for-another-using-jlink it should be theoretically be possible to run it for another platform (if I have JDKs for all target OSes available).

I've found #13 which is talking about different platforms, but I guess its not about the module analysis part.

Thanks again for your help!

Add verification on Project name

I know it but in file system some characters as : can be root of issues.
I think a verification of this kind of stuff should be add before anything else.
it s useless to start packaging if we can know by review of var if will have troubles.

For now all this are not file system safe (exept for some file system : ext3/4 )

β€œ < > / \ : * ? |

java.util.NoSuchElementException: No value present - PackageMojo.java:931

hi,

Was just testing out this plugin with my existing app, which is currently tested only against Java 1.8. Besides getting rid of using String.isBlank() to be able to use this with java 1.8, now I get

Caused by: java.util.NoSuchElementException: No value present
at java.util.Optional.get (Optional.java:135)
at io.github.fvarrui.javapackager.PackageMojo.generateDmgImage (PackageMojo.java:931)
at io.github.fvarrui.javapackager.PackageMojo.execute (PackageMojo.java:347)

I've also seen in the logs the following:
[error] hdiutil: create: Only one image can be created at a time.
[error] Usage: hdiutil create [options]
[error] hdiutil create -help

and

[error] hdiutil: attach: extra image argument "Run" - "target/assets/" already specified
[error] Usage: hdiutil attach [options]
[error] hdiutil attach -help

Any idea? any hints on what the problem is?

Many thx in advance

Cutom assets folder not resolved in current module scope

I have a main POM with submodules, one of which is dedicated to building distribution packages and installers. So my structure is like:

pom.xml
module1
    pom.xml
...
dist
    pom.xml

The javapackager plugin is of course in the dist/pom.xml, but if I want to provide a custom icon I must put the assets folder at the main pom level:

pom.xml
assets
    mac
        xxx.icns
    ...
module1
    pom.xml
...
dist
    pom.xml

I suggest that customized assets should be resolved in the scope of the plugin's current module, i.e.:

pom.xml
module1
    pom.xml
...
dist
    assets
        mac
            xxx.icns
        ...
    pom.xml

Failed build under Windows

Hi Fran,

Trying to build a packet under Windows now and I have a problem.
This is what I get when I try to make a build:

--- javapackager:0.9.4:package (bundle-for-windows) @ PhotoAnnotator ---
Packaging app for windows
[info] Removing folder [C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator]
No license file specified
Creating runnable JAR...
Building jar: C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator-1.0.1-runnable.jar
Creating Windows app bundle...
Copying all dependencies to PhotoAnnotator folder ...
Copying exiftool-lib-2.5.2.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\exiftool-lib-2.5.2.jar
Copying opencsv-5.0.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\opencsv-5.0.jar
Copying commons-lang3-3.9.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\commons-lang3-3.9.jar
Copying commons-text-1.7.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\commons-text-1.7.jar
Copying commons-beanutils-1.9.4.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\commons-beanutils-1.9.4.jar
Copying commons-logging-1.2.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\commons-logging-1.2.jar
Copying commons-collections-3.2.2.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\commons-collections-3.2.2.jar
Copying commons-collections4-4.4.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\commons-collections4-4.4.jar
Copying darcula-2018.2.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\darcula-2018.2.jar
Copying annotations-16.0.1.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\annotations-16.0.1.jar
Copying commons-io-2.6.jar to C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\commons-io-2.6.jar
Copying additional resources
Bundling JRE ... with C:\Program Files\jdk-13.0.2
Getting required modules ... 
[info] Executing command: cmd.exe /X /C ""C:\Program Files\jdk-13.0.2\bin\jdeps" -q --multi-release 13 --ignore-missing-deps --print-module-deps C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\libs\*.jar C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator-1.0.1-runnable.jar"
[info] java.base,java.desktop,java.scripting,java.sql
- Modules: [java.base, java.desktop, java.scripting, java.sql, jdk.zipfs]
Creating JRE with next modules included: java.base,java.desktop,java.scripting,java.sql,jdk.zipfs
[info] Executing command: cmd.exe /X /C ""C:\Program Files\jdk-13.0.2\bin\jlink" --module-path "C:\Program Files\jdk-13.0.2\jmods" --add-modules java.base,java.desktop,java.scripting,java.sql,jdk.zipfs --output C:\Users\mristuccia\Developer\PhotoAnnotator\target\PhotoAnnotator\jre --no-header-files --no-man-pages --strip-debug --compress=2"
VersionInfo [companyName=Marco Ristuccia, copyright=Marco Ristuccia, fileDescription=PhotoAnnotator, fileVersion=1.0.0.0, internalName=PhotoAnnotator, language=null, originalFilename=PhotoAnnotator.exe, productName=PhotoAnnotator, productVersion=1.0.0.0, trademarks=null, txtFileVersion=1.0.1, txtProductVersion=1.0.1]
Platform-specific work directory already exists: C:\Users\mristuccia\.m2\repository\net\sf\launch4j\launch4j\3.12\launch4j-3.12-workdir-win32
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/mristuccia/.m2/repository/com/thoughtworks/xstream/xstream/1.4.8/xstream-1.4.8.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
launch4j: Compiling resources
launch4j: C:\Users\mristuccia\.m2\repository\net\sf\launch4j\launch4j\3.12\launch4j-3.12-workdir-win32\bin\windres.exe: icon file `C:\Users\mristuccia\Developer\PhotoAnnotator\src\main\resources\PhotoAnnotator.icns' does not contain icon data
launch4j: Generated resource file...

launch4j: LANGUAGE 0, 1
1 VERSIONINFO
FILEVERSION 1, 0, 0, 0
PRODUCTVERSION 1, 0, 0, 0
FILEFLAGSMASK 0
FILEOS 0x40000
FILETYPE 1
{
 BLOCK "StringFileInfo"
 {
  BLOCK "040904E4"
  {
   VALUE "CompanyName", "Marco Ristuccia"
   VALUE "FileDescription", "PhotoAnnotator"
   VALUE "FileVersion", "1.0.1"
   VALUE "InternalName", "PhotoAnnotator"
   VALUE "LegalCopyright", "Marco Ristuccia"
   VALUE "LegalTrademarks", ""
   VALUE "OriginalFilename", "PhotoAnnotator.exe"
   VALUE "ProductName", "PhotoAnnotator"
   VALUE "ProductVersion", "1.0.1"
  }
 }
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409, 0x04E4
}
}1 RCDATA BEGIN "jre\0" END
18 RCDATA BEGIN "1\0" END
30 RCDATA BEGIN "2\0" END
1 24 "C:\\Users\\mristuccia\\Developer\\PhotoAnnotator\\target\\assets\\PhotoAnnotator.exe.manifest"
1 ICON DISCARDABLE "C:\\Users\\mristuccia\\Developer\\PhotoAnnotator\\src\\main\\resources\\PhotoAnnotator.icns"
21 RCDATA BEGIN "http://java.com/download\0" END
20 RCDATA BEGIN "32\0" END
101 RCDATA BEGIN "An error occurred while starting the application.\0" END
102 RCDATA BEGIN "This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.\0" END
103 RCDATA BEGIN "This application requires a Java Runtime Environment\0" END
104 RCDATA BEGIN "The registry refers to a nonexistent Java Runtime Environment installation or the runtime is corrupted.\0" END
17 RCDATA BEGIN "true\0" END
15 RCDATA BEGIN "com.marcoristuccia.photoannotator.PhotoAnnotator\0" END
16 RCDATA BEGIN "exiftool-lib-2.5.2.jar;opencsv-5.0.jar;commons-lang3-3.9.jar;commons-text-1.7.jar;commons-beanutils-1.9.4.jar;commons-logging-1.2.jar;commons-collections-3.2.2.jar;commons-collections4-4.4.jar;darcula-2018.2.jar;annotations-16.0.1.jar;commons-io-2.6.jar\0" END


net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: Exec failed (1): C:\Users\mristuccia\.m2\repository\net\sf\launch4j\launch4j\3.12\launch4j-3.12-workdir-win32\bin\windres.exe --preprocessor=type -J rc -O coff -F pe-i386 C:\Users\MRISTU~1\AppData\Local\Temp\launch4j5154200424852081323rc C:\Users\MRISTU~1\AppData\Local\Temp\launch4j16907059095660829957o
	at net.sf.launch4j.Builder.build(Builder.java:149)
	at com.akathist.maven.plugins.launch4j.Launch4jMojo.doExecute(Launch4jMojo.java:432)
	at com.akathist.maven.plugins.launch4j.Launch4jMojo.execute(Launch4jMojo.java:321)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:119)
	at io.github.fvarrui.javapackager.PackageMojo.createWindowsApp(PackageMojo.java:661)
	at io.github.fvarrui.javapackager.PackageMojo.execute(PackageMojo.java:336)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: net.sf.launch4j.ExecException: Exec failed (1): C:\Users\mristuccia\.m2\repository\net\sf\launch4j\launch4j\3.12\launch4j-3.12-workdir-win32\bin\windres.exe --preprocessor=type -J rc -O coff -F pe-i386 C:\Users\MRISTU~1\AppData\Local\Temp\launch4j5154200424852081323rc C:\Users\MRISTU~1\AppData\Local\Temp\launch4j16907059095660829957o
	at net.sf.launch4j.Util.exec(Util.java:156)
	at net.sf.launch4j.Cmd.exec(Builder.java:215)
	at net.sf.launch4j.Builder.build(Builder.java:100)
	... 28 more
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 35.141 s
Finished at: 2020-03-29T23:09:39+02:00
Final Memory: 26M/78M
------------------------------------------------------------------------
Failed to execute goal io.github.fvarrui:javapackager:0.9.4:package (bundle-for-windows) on project PhotoAnnotator: Failed to build the executable; please verify your configuration. net.sf.launch4j.ExecException: Exec failed (1): C:\Users\mristuccia\.m2\repository\net\sf\launch4j\launch4j\3.12\launch4j-3.12-workdir-win32\bin\windres.exe --preprocessor=type -J rc -O coff -F pe-i386 C:\Users\MRISTU~1\AppData\Local\Temp\launch4j5154200424852081323rc C:\Users\MRISTU~1\AppData\Local\Temp\launch4j16907059095660829957o -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

And this is the plugin configuration I'm using (tried with 0.9.2, 0.9.3.and 0.9.4):

<plugin>
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>0.9.4</version>
    <executions>
        <execution>
            <id>bundle-for-windows</id>
            <phase>package</phase>
            <goals>
                <goal>package</goal>
            </goals>
            <configuration>
                <mainClass>com.marcoristuccia.photoannotator.PhotoAnnotator</mainClass>
                <displayName>PhotoAnnotator</displayName>
                <organizationName>Marco Ristuccia</organizationName>
                <organizationUrl>http://www.marcoristuccia.com/it</organizationUrl>
                <iconFile>${project.build.resources[0].directory}/PhotoAnnotator.icns</iconFile>
                <bundleJre>true</bundleJre>
                <platform>auto</platform>
                <administratorRequired>false</administratorRequired>
                <generateInstaller>true</generateInstaller>
                <additionalModules>
                    <param>jdk.zipfs</param>
                </additionalModules>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>

Any idea?

Thanks in advance.

Best,
marco

ISCC

'iscc' is not regognzed as internal or external program. Any suggestions to fix this?

Using the JavaPackager maven plugin, on a project without dependencies fails

Basic usage with no dependencies fails, adding any dependency resolves the problem

mvn --version:

mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/<user>/.sdkman/candidates/maven/current
Java version: 11.0.6, vendor: Amazon.com Inc., runtime: /Users/<user>/.sdkman/candidates/java/11.0.6-amzn
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.4", arch: "x86_64", family: "mac"

pom:

            <plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>0.9.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.example.Application</mainClass>
                            <bundleJre>true</bundleJre>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
[INFO] Bundling JRE ... with /Users/<user>/.sdkman/candidates/java/11.0.6-amzn
[INFO] Getting required modules ... 
[info] Executing command: /bin/bash -c /Users/<user>/.sdkman/candidates/java/11.0.6-amzn/bin/jdeps -q --multi-release 11 --list-deps /Users/<user>/example/target/my-example/my-example.app/Contents/Resources/Java/libs/*.jar /Users/<user>/example/target/my-example-0.1.0-SNAPSHOT-runnable.jar
[info] Warning: Path does not exist: /Users/<user>/example/target/my-example/my-example.app/Contents/Resources/Java/libs/*.jar
[info]    java.base
[info]    java.desktop
[INFO] - Modules: [Warning: Path does not exist: , java.base, java.desktop]
[INFO] Creating JRE with next modules included: Warning: Path does not exist: ,java.base,java.desktop
[info] Executing command: /bin/bash -c /Users/<user>/.sdkman/candidates/java/11.0.6-amzn/bin/jlink --module-path /Users/<user>/.sdkman/candidates/java/11.0.6-amzn/jmods --add-modules Warning: Path does not exist: ,java.base,java.desktop --output /Users/<user>/example/target/my-example/my-example.app/Contents/PlugIns/jre/Contents/Home --no-header-files --no-man-pages --strip-debug --compress=2
[info] Error: invalid argument: Path does not exist: ,java.base,java.desktop --output /Users/<user>/example/target/my-example/my-example.app/Contents/PlugIns/jre/Contents/Home --no-header-files --no-man-pages --strip-debug --compress=2
[info] Usage: jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...]
[info] Use --help for a list of possible options

Failed to execute goal io.github.fvarrui:javapackager:0.9.5:package

When I try to package a project, I get the error message:
[ERROR] Failed to execute goal io.github.fvarrui:javapackager:0.9.5:package (default) on project FlatLaF-ASCII-editor:
Unable to execute mojo:
Plugin com.akathist.maven.plugins.launch4j:launch4j-maven-plugin:1.7.25 or one of its dependencies could not be resolved:
Failed to read artifact descriptor for com.akathist.maven.plugins.launch4j:launch4j-maven-plugin:jar:1.7.25:
Could not transfer artifact com.akathist.maven.plugins.launch4j:launch4j-maven-plugin:pom:1.7.25 from/to central (https://repo.maven.apache.org/maven2):
Transfer failed for https://repo.maven.apache.org/maven2/com/akathist/maven/plugins/launch4j/launch4j-maven-plugin/1.7.25/launch4j-maven-plugin-1.7.25.pom: java.lang.RuntimeException:
Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 1]

Packaging failed with multi-release jar

When packaging with a multi-release jar, I get a NPE from your plugin.
I'm using Maven, the faulty library is H2 (which is now multi-release), and when the plugin runs jeps, it gets an error, because h2-1.4.199.jar is a multi-release jar file but --multi-release option is not set.
Then jlink is called with that message, which is obviously not a valid modules list, and the jre folder is not created by jlink. Hence the NPE.

I tried to run the jdeps command on my machine, with the multi-release option, and it returns modules names.

BTW, thank you very much for this plugin, it does its jobs perfectly ! I spent too much time trying to fit my JavaFX/"Java 8 only libraries" app in the module system, and kept failing. It makes it work like a breeze !

Cannot launch JavaFX 14 App on MacOS

Hi,

I have created the macOS installer of a simple JavaFX 14 App with version 1.0.1-SNAPSHOT and VM args like "--module-path=${JFX_HOME}/lib --add-modules=javafx.fxml,javafx.controls,javafx.graphics,javafx.media". However, I cannot launch the app (error: com.apple.xpc.launchd[1] (XXX): Service exited with abnormal code: 78 or 1).

I have investigated and found the problem is that vmArg, which is in file Contents/Info.plist, is incorrect.
Then i added above args to file Contents/MacOS/universalJavaApplicationStub and double-click on file startup, it worked. It still not work if i double-click on icon app in Applications.

Could you please let me know what i am wrong?

Thanks,
Bac Nguyen

How do I read from additionalResources?

I'm really enjoying this utility. I have some extra resources that I've embedded into my Mac app but I can't figure out how to read them. I wrote some code to tell me what java thinks its root directory and it seems to be set to "/" and not anywhere within the blah.app directory. How do I get my root path set correctly so I can read from my resources directory.

Thanks.

DMG generation fails on Travis-CI: "No value present"

Build fails on Travis-CI on a macOS environment during DMG generation phase with error:
[ERROR] Failed to execute goal io.github.fvarrui:javapackager:1.0.2:package (default) on project xpman-fx-dist: Execution default of goal io.github.fvarrui:javapackager:1.0.2:package failed: No value present -> [Help 1]

Full build log: https://travis-ci.com/github/ogerardin/xpman/jobs/348812330#L1904

The same POM works fine when building locally on my Mac.

Package Artifact as Windows MergeModule?

Hi,

I've got a fair bit of experience with WIX through Visual Studio and I like to use merge modules instead of an MSI so they can be added to a larger installer package. Is it possible to use JavaPackager to output as a MergeModule instead of a full MSI?

Thanks!
Russ

Use JavaPackager from Gradle

Greetings,

I understand, from looking at the commits, that this is on the roadmap. I have a Java desktop app (running with OpenJDK 8u265) that requires packaging, specifically on macOS for now. I used to rely on Oracle JDK 8u192's built-in javapackager but that is not part of OpenJDK and I can't have the Mac DMG notarized by Apple with 8u192. Our app is built with Gradle.

Regards.

A new packaging tool can integrate into your plugin

Hi,Yesterday, JDK14 was released with a new packaging tool ,that you can integrate into your plug-in if you are interested.

TheΒ jpackageΒ tool will take as input a Java application and a Java run-time image, and produce a Java application image that includes all the necessary dependencies. It will be able to produce a native package in a platform-specific format, such as an exe on Windows or a dmg on macOS.

dmg file not generated

I tried the JavaPackager as a replacement for sh.tak.appbundler and replaced all the configuration switches with the new ones. I get a successful build, but no dmg file. However, I have this in my configuration:

 <dmg>
    <generate>true</generate>
    <createApplicationsSymlink>true</createApplicationsSymlink>
</dmg>

JDeps fails on package

Maven log
pom.xml
While the maven output indicates that activation is not found it is clearly in the libs directory as show below
explorer_E1vcgh6apj
I've been tinkering with this for awhile now and at this point I'm not sure whether the root issue is with docx4j (the source of the dependency) or with JavaPackager, but I haven't seen any similar issues so my bet is it is an issue with JavaPackager. My hunch is that it may have a bit to do with the dependency scopes under docx4j all being set to compile, but I'm not sure.

EDIT: I'm 99.94% sure it doesn't matter but I do have some custom velocity templates to set the app as default.

0.9.0 mac problems

Hi Fran,

I have problem with the new 0.9.0 version. The app does not start under macOS.

By manually launching the startup script I get this:

marco$ ./phPatcher.app/Contents/MacOS/startup
-bash: ./phPatcher.app/Contents/MacOS/startup: /bin/sh^M: bad interpreter: No such file or directory

I think there is the newline problem again. :)

Best,
marco

Add as Gradle plugin

This would help out your gradle friends!
jpackage with OpenJDK 14 has been a bust lately and this project looks great, but implementing it as a Gradle plugin would be pretty nice instead of having to execute a maven wrapper from a gradle task to run this plugin.

There was no reaction execute on windows if no vmArgs config

Package seams fine,but run the xx.exe nothing occurred,it works fine with the vmArgs config, it seams the issues of module settings.

<dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11.0.2</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>1.2.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <mainClass>top.topsoft.test.App</mainClass>
                            <bundleJre>true</bundleJre>
                            <platform>windows</platform>
                            <generateInstaller>true</generateInstaller>
                            <vmArgs>
                                <vmArg>--module-path=D:\dev\jfx\javafx-sdk-11.0.2\lib</vmArg>
                                <vmArg>--add-modules=javafx.fxml,javafx.controls,javafx.graphics,javafx.media</vmArg>
                            </vmArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Can not bundle my own fat jar

Can not bundle my own fat jar

Please don't care about errors, if there are some (I'm french).

I've tried to bundle my own fat jar using <runnableJar>, but the plugin can't found my jar. (The logs shows me : 'Application jar does not exists'). I don't know if my path is wrong, or if I need to add the extension .jar. I tried to indicate the position of the jar from the project's root.

With an absolute path, it seems to work, it founds the jar, but the log indicates that the output file couldn't be opened after launch4j "Linking" operation.

Hope it's clear (and it helps) !

0.8.9 package problem

[ERROR] net.sf.launch4j.BuilderException: Invalid data: Product version, should be 'x.x.x.x'

File description exception during build

Hi,
my configuration for windows looks like this

<plugin> <groupId>fvarrui.maven</groupId> <artifactId>javapackager</artifactId> <version>0.8.8</version> <executions> <execution> <phase>package</phase> <goals> <goal>package</goal> </goals> <configuration> <mainClass>my.package.MyMainClass</mainClass> <bundleJre>false</bundleJre> <platform>windows</platform> <generateInstaller>true</generateInstaller> <administratorRequired>false</administratorRequired> <iconFile>${basedir}/packager/icon.png</iconFile> </configuration> </execution> </executions> </plugin>

And I get a strange exception during build on windows. Any tips for that?

[ERROR] net.sf.launch4j.BuilderException: Enter: File description at net.sf.launch4j.Builder.build (Builder.java:76) at com.akathist.maven.plugins.launch4j.Launch4jMojo.doExecute (Launch4jMojo.java:432) at com.akathist.maven.plugins.launch4j.Launch4jMojo.execute (Launch4jMojo.java:321) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:119) at fvarrui.maven.plugin.javapackager.PackageMojo.createWindowsApp (PackageMojo.java:540) at fvarrui.maven.plugin.javapackager.PackageMojo.execute (PackageMojo.java:238) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:567) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

Thank you and have a nice day

Main class invalid or missing

<plugin> <groupId>io.github.fvarrui</groupId> <artifactId>javapackager</artifactId> <version>0.9.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>package</goal> </goals> <configuration> <mainClass>Drivers.Driver</mainClass> <bundleJre>true</bundleJre> </configuration> </execution> </executions> </plugin>

Drivers.Driver is a valid class and I can access it from jars, but javapackager can't seem to find it

MacOS startup file format issue

Hi Fran,

thank you for this plugin.
I started experimenting with it with MacOS Mojave 10.14.6 under Netbeans 11.2 and JDK 13.0.1 and JDK 1.8.0_77 and have some problems:

  1. The first one is that I cannot start the app because the script <appName.sh>/Contents/MacOS/startup contains DOS/Windows newlines (with (hidden) ^M). After opening the script in vi and issuing the command ":set fileformat=unix" and resaving it the application starts.

  2. When I embed a JDK the code signing doesn't work, it gives an error:
    [info] Executing command: codesign --force --deep --sign - /Users/marco/Developer/phPatcher/target/app/phPatcher.app
    [error] /Users/marco/Developer/phPatcher/target/app/phPatcher.app: bundle format unrecognized, invalid, or unsuitable
    [error] In subcomponent: /Users/marco/Developer/phPatcher/target/app/phPatcher.app/Contents/PlugIns/jre/Contents/Home/legal/java.management.rmi

  3. By correcting the script as described on point 1 and by not embedding the JDK I can run the app by executing the script on CLI, but if I double click the App on the GUI it opens for a second and then it closes again. Still figuring out what the problem can be. I'll let you know.

Plugin fails to initialize because of Java version

When I use JDK 13 to build my project (which should triggers the ignore-missing-deps flag, I need it because of optionnal dependencies in my dependencies), I get a StringIndexOutOfBoundsException.

...
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2
    at java.lang.String.checkBoundsBeginEnd (String.java:3720)
    at java.lang.String.substring (String.java:1909)
    at org.apache.commons.lang.SystemUtils.getJavaVersionAsFloat (SystemUtils.java:1122)
    at org.apache.commons.lang.SystemUtils.<clinit> (SystemUtils.java:818)
    at fvarrui.maven.plugin.javapackager.PackageMojo.execute (PackageMojo.java:159)
...

From what I saw in the code, it's because of commons-lang, which is not playing nicely with java version parsing (unlike commons-lang3).

Custom Info.plist template not used

I created a <project-root>/assets/macosx/Info.plist.vtl file (based on the default velocity template), and it's not getting picked up. Is this expected?

I'm probably reading the code wrong, but it looks like the velocity templates are just pulled from the plugin classpath.

Mac bundle is successful exported but it closes when trying to open

Hi there, first of all, congrats for the project is really cool!!

I'm trying to generate the mac bundle for a java project, I follow the configuration in the documentation, it builds perfectly and all the files are generated. However, when I try to run the .app, the application closes itself. Without any error message.

I have the following XML plugin configuration.

        <plugin>
              <groupId>io.github.fvarrui</groupId>
	       <artifactId>javapackager</artifactId>
		<version>1.1.0</version>
		<executions>
		        <execution>
			        <phase>package</phase>
			        <goals>
			                <goal>package</goal>
			        </goals>
			        <configuration>
			                <!-- mandatory -->
			                <mainClass>com.navi.agenslib.AgensLib</mainClass>
			                <!-- optional -->
			                <bundleJre>true</bundleJre>
			                <generateInstaller>true</generateInstaller>        
			                <administratorRequired>true</administratorRequired>
			                <platform>mac</platform>
			                <iconFile>assets/mac/AgensLib.icns</iconFile>
			                <macConfig>
			               		<!-- general properties -->
			               		<generateDmg>true</generateDmg>
						<generatePkg>true</generatePkg>
						<backgroundImage>assets/mac/background.png</backgroundImage>
						<windowWidth>540</windowWidth>
						<windowHeight>360</windowHeight>
						<iconSize>128</iconSize>
						<textSize>16</textSize>
						<iconX>52</iconX>
						<iconY>116</iconY>
						<appsLinkIconX>360</appsLinkIconX>
						<appsLinkIconY>116</appsLinkIconY>
						<volumeIcon>assets/mac/AgensLib.icns</volumeIcon>
						<volumeName>${displayName}</volumeName>
				        </macConfig>
			        </configuration>
			</execution>
                </executions>
	</plugin>

The final console output after the maven package command line, is the following:

[info]     Generating Mac OS X installer package ...
[info]         Executing command: /bin/sh -c cd '/Users/van/Documents/AgensLib_Desktop/.' && 'pkgbuild' --install-location /Applications --component /Users/van/Documents/AgensLib_Desktop/target/AgensLib/AgensLib.app /Users/van/Documents/AgensLib_Desktop/target/AgensLib_0.0.1.pkg
[info]         pkgbuild: Adding component at /Users/van/Documents/AgensLib_Desktop/target/AgensLib/AgensLib.app
[info]         pkgbuild: Wrote package to /Users/van/Documents/AgensLib_Desktop/target/AgensLib_0.0.1.pkg
[info]     Mac OS X installer package generated in /Users/van/Documents/AgensLib_Desktop/target/AgensLib_0.0.1.pkg!
[info]     
[info] Installers generated! [/Users/van/Documents/AgensLib_Desktop/target/AgensLib_0.0.1.dmg, /Users/van/Documents/AgensLib_Desktop/target/AgensLib_0.0.1.pkg]
[info] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  28.972 s
[INFO] Finished at: 2020-08-29T00:49:50-05:00
[INFO] ------------------------------------------------------------------------

problem

Hi Fran, I have problem with the new 0.9.1 version. Can openjfx13 be used?

Error at start on Windows

Hello,

I probably miss something but when i try to execute my generate exe it not start.
After i start it in a powershell shell it says it can’t find my main class but the fat jar build start without trouble with a :

java -jar mydot.jar

This is my relevant pom part :

            <plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>1.1.0</version>
                <executions>
                    <execution>
                        <id>windows</id>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            
                            <mainClass>com.mytestcompany.mytestproject.Main</mainClass>
                            
                            <bundleJre>false</bundleJre>
                            <runnableJar>target/mydot.jar</runnableJar>
                            <copyDependencies>false</copyDependencies>
                            <generateInstaller>true</generateInstaller>        
                            <administratorRequired>true</administratorRequired>
                            
                            <platform>windows</platform>
                            <winConfig>
                                <generateSetup>true</generateSetup>
                                <generateMsi>true</generateMsi>
                                <headerType>console</headerType>
                            </winConfig>
                    </configuration>
                    </execution>
               </executions>
           </plugin>

For the record my main javafx class is already in a wrapper java main class.

Mac app bundle does not open: LSOpenURLsWithRole() failed with error -10810

The generated xxx.app bundle does not open.

When double-clicked in Finder, icon bounces a few times in the dock then disappears with no error message displayed.
When launched from a terminal with "open xxx.app", I get the following error:
LSOpenURLsWithRole() failed with error -10810 for the file xxx.app

Here's the plugin config:

                   <plugin>
                        <groupId>io.github.fvarrui</groupId>
                        <artifactId>javapackager</artifactId>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>package</goal>
                                </goals>
                                <configuration>
                                    <description>${app.description}</description>
                                    <displayName>${app.name}</displayName>
                                    <name>${app.name}</name>
                                    <organizationName>${app.copyright}</organizationName>
                                    <mainClass>${app.runnableMainClass}</mainClass>
                                    <runnableJar>${project.build.directory}/${app.runnableJar}</runnableJar>
                                    <copyDependencies>false</copyDependencies>
                                    <bundleJre>true</bundleJre>
                                    <jrePath>${java.home}</jrePath>
                                    <generateInstaller>true</generateInstaller>
                                    <macConfig>
                                        <!-- FIXME dmg temporarily disabled because it fails on Travis-CI -->
                                        <generateDmg>false</generateDmg>
                                        <generatePkg>true</generatePkg>
                                    </macConfig>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

Running macOS Catalina 10.15.5.

dmg generation fails on macos catalina

When running mvn packager I get the following error:

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <maven.compiler.target>11</maven.compiler.target>
        <maven.compiler.source>11</maven.compiler.source>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>0.9.7</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <!-- mandatory -->
                            <mainClass>main.java.DebateAppMain</mainClass>
                            <!-- optional -->
                            <bundleJre>true</bundleJre>
                            <generateInstaller>true</generateInstaller>
                            <administratorRequired>false</administratorRequired>
                            <platform>auto</platform>
                            <organizationUrl>https://github.com/tajetaje</organizationUrl>
                            <url>https://github.com/tajetaje/DebateApp</url>
                            <!-- Must provide JRE for macOS: -->
                            <jrePath>${basedir}/../Libraries/Java/jdk-11.0.7-full.jdk</jrePath>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <groupId>tajetaje</groupId>
    <artifactId>DebateApp</artifactId>
    <version>2.0.0</version>
    <dependencies>
        <dependency>
            <groupId>org.jfxtras</groupId>
            <artifactId>jmetro</artifactId>
            <version>11.6.12</version>
        </dependency>
        <dependency>
            <groupId>org.controlsfx</groupId>
            <artifactId>controlsfx</artifactId>
            <version>11.0.1</version>
        </dependency>
        <!--        Will put these back in when I implement DOCX support-->
        <!--        <dependency>-->
        <!--            <groupId>org.docx4j</groupId>-->
        <!--            <artifactId>docx4j-core</artifactId>-->
        <!--            <version>11.1.7</version>-->
        <!--        </dependency>-->
        <!--        <dependency>-->
        <!--            <groupId>net.sf.jtidy</groupId>-->
        <!--            <artifactId>jtidy</artifactId>-->
        <!--            <version>r938</version>-->
        <!--        </dependency>-->
    </dependencies>
</project>

mvn -e clean packager output:

[INFO] --- javapackager:0.9.7:package (default) @ DebateApp ---
[INFO] Packaging app for mac
[info] Removing folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp]
[INFO] License file found: /Volumes/Tag's Drive/Development/DebateApp/LICENSE
[info] Copying resource [/mac/default-icon.icns] to file [/Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp.icns]
[info] Copying stream to file [/Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp.icns]
[INFO] Creating runnable JAR...
[INFO] Building jar: /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp-2.0.0-runnable.jar
[INFO] Creating Mac OS X app bundle...
[INFO] Creating and setting up the bundle directories
[INFO] Copying dependencies to Java folder
[INFO] Copying all dependencies to DebateApp folder ...
[INFO] Copying jmetro-11.6.12.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/jmetro-11.6.12.jar
[INFO] Copying javafx-controls-11.0.2-win.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-controls-11.0.2-win.jar
[INFO] Copying javafx-controls-11.0.2-mac.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-controls-11.0.2-mac.jar
[INFO] Copying javafx-base-11.0.2-win.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-base-11.0.2-win.jar
[INFO] Copying javafx-base-11.0.2-mac.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-base-11.0.2-mac.jar
[INFO] Copying javafx-graphics-11.0.2-win.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-graphics-11.0.2-win.jar
[INFO] Copying javafx-graphics-11.0.2-mac.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-graphics-11.0.2-mac.jar
[INFO] Copying controlsfx-11.0.1.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/controlsfx-11.0.1.jar
[INFO] Copying javafx-base-11.0.2.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-base-11.0.2.jar
[INFO] Copying javafx-web-11.0.2.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-web-11.0.2.jar
[INFO] Copying javafx-web-11.0.2-mac.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-web-11.0.2-mac.jar
[INFO] Copying javafx-graphics-11.0.2.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-graphics-11.0.2.jar
[INFO] Copying javafx-controls-11.0.2.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-controls-11.0.2.jar
[INFO] Copying javafx-swing-11.0.2.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-swing-11.0.2.jar
[INFO] Copying javafx-swing-11.0.2-mac.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-swing-11.0.2-mac.jar
[INFO] Copying javafx-media-11.0.2.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-media-11.0.2.jar
[INFO] Copying javafx-media-11.0.2-mac.jar to /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java/libs/javafx-media-11.0.2-mac.jar
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp-2.0.0-runnable.jar] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources/Java]
[INFO] Bundling JRE ... with /Library/Java/JavaVirtualMachines/liberica-jdk-11-full.jdk/Contents/Home
[INFO] Embedding JRE from /Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk
[info] Copying folder content [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying folder [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/man] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._man] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/LICENSE] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._LICENSE] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying folder [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/bin] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._bin] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying folder [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/include] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._include] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/release] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._release] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying folder [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/lib] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._lib] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/readme.txt] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._readme.txt] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying folder [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/conf] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._conf] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying folder [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/jmods] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/../Libraries/Java/jdk-11.0.7-full.jdk/._jmods] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home]
[info] Removing folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/PlugIns/jre/Contents/Home/legal]
[INFO] Creating startup file
[INFO] Copying icon file to Resources folder
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp.icns] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources]
[INFO] Writing the Info.plist file
[INFO] Copying additional resources
[info] Copying file [LICENSE] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app/Contents/Resources]
[info] Executing command: /bin/bash -c codesign --force --deep --sign - /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/DebateApp.app
[INFO] Generating DMG disk image file
[INFO] Creating Applications link
[info] Creating symbolic link [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/Applications] to [/Applications]
[INFO] Copying background image
[info] Copying resource [/mac/background.png] to file [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/.background/background.png]
[info] Copying stream to file [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/.background/background.png]
[INFO] Copying icon file: /Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp.icns
[info] Copying file [/Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp.icns] to folder [/Volumes/Tag's Drive/Development/DebateApp/target/DebateApp/.VolumeIcon.icns]
[INFO] Creating image: /Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp_2.0.0.dmg
[info] Executing command: /bin/bash -c hdiutil create -srcfolder /Volumes/Tag's Drive/Development/DebateApp/target/DebateApp -volname DebateApp -fs HFS+ -format UDRW /Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp_2.0.0.dmg
[error] hdiutil: create failed - No such file or directory
[INFO] Mounting image: /Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp_2.0.0.dmg
[info] Executing command: /bin/bash -c hdiutil attach -readwrite -noverify -noautoopen /Volumes/Tag's Drive/Development/DebateApp/target/assets/DebateApp_2.0.0.dmg
[error] /bin/bash: -c: line 0: unexpected EOF while looking for matching `''
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:24 min
[INFO] Finished at: 2020-06-05T20:45:26-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.github.fvarrui:javapackager:0.9.7:package (default) on project DebateApp: Execution default of goal io.github.fvarrui:javapackager:0.9.7:package failed: No value present -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.github.fvarrui:javapackager:0.9.7:package (default) on project DebateApp: Execution default of goal io.github.fvarrui:javapackager:0.9.7:package failed: No value present
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal io.github.fvarrui:javapackager:0.9.7:package failed: No value present
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.util.NoSuchElementException: No value present
    at java.util.Optional.get (Optional.java:148)
    at io.github.fvarrui.javapackager.PackageMojo.generateDmgImage (PackageMojo.java:931)
    at io.github.fvarrui.javapackager.PackageMojo.execute (PackageMojo.java:347)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

rpm generation fails

rpm package generation fails sometimes. In addition, alien command requires root privileges to convert the deb package to rpm, and also it has to generate deb package first. Try alternative method: rpm-maven-plugin.

Application installed with MSI does not run

Hello,

First, FANTASTIC tool. I've been using java off and on for years and deploying with a JRE has always seemed to be black art. I'm working on a project to be deployed at a clients site and this tools is ever so close to fitting my needs very well. I've been able to create an MSI and the installed product seems to have all the application dependencies in the libs folder.

The only problem so far is the runnable jar doesn't seem to run. In my testing the installed application fails to run with no error message. I then attempted to run the "Runnable jar" file from the command line with no success.

Here is my configuration file so far:

<plugin>
	<groupId>io.github.fvarrui</groupId>
	<artifactId>javapackager</artifactId>
	<version>1.1.0</version>		
	<executions>					
		<execution>						
			<phase>package</phase>
			<goals>
				<goal>package</goal>
			</goals>
			<configuration>							
				<name>SmartCableTool</name>
				<mainClass>com.company1.app.SfdqGui</mainClass>
				<bundleJre>true</bundleJre>
				<customizedJre>true</customizedJre>
				<assetsDir></assetsDir>
				<organizationName>Client X</organizationName>
				<copyDependencies>true</copyDependencies>
				<winConfig>
					<headerType>gui</headerType>
					<companyName>${organizationName}</companyName>
					<fileVersion>1.0.0.0</fileVersion>
					<txtFileVersion>${project.version}</txtFileVersion>
					<productVersion>1.0.0.0</productVersion>
					<txtProductVersion>${version}</txtProductVersion>
					<fileDescription>${description}</fileDescription>
					<copyright>${organizationName} 2020</copyright>
					<productName>${name}</productName>
					<internalName>${name}</internalName>
					<originalFilename>${name}.exe</originalFilename>
					<!-- installer generation properties -->
					<disableDirPage>false</disableDirPage>
					<disableProgramGroupPage>false</disableProgramGroupPage>
					<disableFinishedPage>false</disableFinishedPage>
					<createDesktopIconTask>true</createDesktopIconTask>
					<generateSetup>false</generateSetup>
					<generateMsi>true</generateMsi>
				</winConfig>
			</configuration>
		</execution>
	</executions>
</plugin>

If I run my "with dependencies" the application executes fine:

PS C:\Users\rhaley.SPE\Sfdq_Java_App_39789\target> .\SmartCableTool-0.1.13-SNAPSHOT-jar-with-dependencies.jar
<application starts>

or

PS C:\Users\rhaley.SPE\Sfdq_Java_App_39789\target> java -jar .\SmartCableTool-0.1.13-SNAPSHOT-jar-with-dependencies.jar
<application starts>

But the same with the runnable jar:

PS C:\Users\rhaley.SPE\starfish\Sfdq_Java_App_39789\target> .\SmartCableTool-0.1.13-SNAPSHOT-runnable.jar
<nothing!>
PS C:\Users\rhaley.SPE\starfish\Sfdq_Java_App_39789\target> java -jar .\SmartCableTool-0.1.13-SNAPSHOT-runnable.jar
Error: Could not find or load main class com.company1.app.SfdqGui
Caused by: java.lang.ClassNotFoundException: com.company1.app.SfdqGui
PS C:\Users\rhaley.SPE\starfish\Sfdq_Java_App_39789\target>

I've converted the file SmartCableTool-0.1.13-SNAPSHOT-runnable.jar to a zip file and can confirm the file com\starfishmedical\sfdq\app\SfdqGui.class exists. Any idea what I've missed?

Regards,
Russ

Allow packaging for different OS than host

Instead of automatically packaging for the host OS, I would like to be able to specify which OS to build for. I've used a Windows host to build both a .exe and a Mac .app bundle. You can build more than one package with multiple executions of the plugin.

I've committed some code to do this on my fork:
https://github.com/ElderResearch/JavaPackager/commit/96bf664ba0764c0161dd9a280d0a16a1e1d3cbe0

This introduces a new platform configuration, one of:
auto (the default- current behavior)
mac
linux
windows

Let me know if you want me to open a PR

special jreFolder name and launch4j fileVersion

Thank you very much for developing such a useful plug-in for us!I have two issues
1、Allow a configurable folder name for jreFolder,the defalut is "jre" ,but I want to call that "runtime"γ€β€œmini-jre”......, like the https://github.com/openjfx/javafx-maven-plugin/
2、Allow more configurable options for launch4j,
like fileVersion,txtFileVersion,productVersion,txtProductVersion....

Null pointer on macos with jdk 13

Hi,
I get null pointer exception from javapackager when trying to build a package with bundled jre on mac os x.

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal fvarrui.maven:javapackager:0.8.8:package (default) on project MyRealProject: Execution default of goal fvarrui.maven:javapackager:0.8.8:package failed. at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:567) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal fvarrui.maven:javapackager:0.8.8:package failed. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:567) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull (Objects.java:222) at java.util.Arrays$ArrayList.<init> (Arrays.java:4344) at java.util.Arrays.asList (Arrays.java:4331) at fvarrui.maven.plugin.javapackager.PackageMojo.bundleJre (PackageMojo.java:703) at fvarrui.maven.plugin.javapackager.PackageMojo.createMacApp (PackageMojo.java:371) at fvarrui.maven.plugin.javapackager.PackageMojo.execute (PackageMojo.java:195) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:567) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

My configuration in pom.xml looks like this

<plugin> <groupId>fvarrui.maven</groupId> <artifactId>javapackager</artifactId> <version>0.8.8</version> <executions> <execution> <phase>package</phase> <goals> <goal>package</goal> </goals> <configuration> <mainClass>my.real.package.MainClass</mainClass> <bundleJre>true</bundleJre> <jrePath>${basedir}/jwrapper/jwrapperJREs/macos64/jdk-13.jdk</jrePath> <customizedJre>true</customizedJre> <generateInstaller>true</generateInstaller> <administratorRequired>false</administratorRequired> <iconFile>${basedir}/jwrapper/image.png</iconFile> </configuration> </execution> </executions> </plugin>

Any tips what might be wrong with my configuration?
When I disable jre bundling everything works fine.

Missing jarFile in macOS-app

When generating the Program.app the jarFile is not included, neither it is listed in the Info.plist nor is it copied to the lib folder. Therefore, the generated Program.app cannot run with macOS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.