beryx-gist / badass-runtime-example-javafx

A small JavaFX application that shows how to use the Badass Runtime Plugin
Apache License 2.0
26 stars 3 forks source link

how to create a shortcut for mac ? #27

Closed ghost closed 3 years ago

ghost commented 3 years ago

For windows os. I use this code

    if(currentOs.windows) {
        installerOptions += ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-shortcut']
    }

For linux os. I use this code

    if(currentOs.linux){
    installerOptions += ['--linux-shortcut', '--verbose']
    }

But , How can I create a shortcut for mac ?

Srijan-Sengupta commented 3 years ago

Please try reading these docs carefully You will find a portion with mac specific options... Add those to the installerOptionsin this manner:

if(currentOs.macOsX){
installerOptions += .....
}
ghost commented 3 years ago

Please try reading these docs carefully You will find a portion with mac specific options... Add those to the installerOptionsin this manner:

if(currentOs.macOsX){
installerOptions += .....
}

I saw this docs.

But , I can't find that command for macos.

I saw the command for only linux and windows os.

But , I can't find the cammand for macos.

How can I solve this ?

ghost commented 3 years ago

will this code work ?

if (os.macOsX) {
 --installerOptions += ['--mac-package-name', 'hellofxml']
 }
Srijan-Sengupta commented 3 years ago

Please remove -- before installerOptions and it must work.. I am not much sure as I have never used MacOS but theoretically, I feel it must work. You may install a mac on your virtual box using vagrant.

larsroe commented 3 years ago

You might not want create a shortcut on OS X, as they aren't used the way they are on Windows. The default value for --mac-package-name should be the application name, so that also might not help you.

If you want to customize the icon, use the --icon option with a .icns file. More customization is available with --resource-dir, which use these default values: https://github.com/openjdk/jdk/tree/master/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources

Srijan-Sengupta commented 3 years ago

@larsroe your correct! I apologize for my misconception.

ghost commented 3 years ago

My Build.gradle

plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.9'
id 'org.beryx.runtime' version '1.11.3'
}

repositories {
 mavenCentral()
}

javafx {
modules = ['javafx.controls', 'javafx.fxml']
}

application {
  mainClassName = "org.example.hellofx.Launcher"
 applicationName = 'hellofx'
 }

  runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header- 
  files', '--no-man-pages']
   launcher {
   noConsole = true
    }
    jpackage {
    def currentOs = org.gradle.internal.os.OperatingSystem.current()
    def imgType = currentOs.windows ? 'ico' : currentOs.macOsX ? 'icns' : 'png'
    imageOptions += ['--icon', "src/main/resources/hellofx.$imgType"]
    installerOptions += ['--resource-dir', "src/main/resources"]
  installerOptions += ['--vendor', 'Acme Corporation']
  if(currentOs.windows) {
    installerOptions += ['--win-per-user-install', '--win-dir- 
chooser', '--win-menu', '--win-shortcut']
    }
if (os.macOsX) {
 installerOptions += ['--mac-package-name', 'hellofxml']
 }
}
}

I changed my build.gradle file.

will this work?

will this create a shortcut on mac os X?