beryx / badass-runtime-plugin

Create a custom runtime image of your non-modular application
https://badass-runtime-plugin.beryx.org
Apache License 2.0
161 stars 21 forks source link

[Question] How to set the icon image? [jpackage] #39

Closed KenobySky closed 4 years ago

KenobySky commented 4 years ago

Hi! This Gradle plugin is great and it really made my development easier and faster. Im just having one problem: I cant find a way to set the icon to the executable.

The JPackager mentions the --icon parameter, but the gradle plugin doesnt. Im new with Gradle so im finding this a bit confusing.

Would someone clarify? Thanks and this plugin should be in every javafx page.

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.8'
    id 'org.beryx.runtime' version '1.7.0'
    id "com.github.johnrengelman.shadow" version "5.1.0"

}

repositories {
    mavenCentral()
}

dependencies {

    compile 'org.openjfx:javafx-base:11:win'
    compile 'org.openjfx:javafx-controls:11:win'
    compile 'org.openjfx:javafx-fxml:11:win'
    compile 'org.openjfx:javafx-graphics:11:win'
    compile "org.controlsfx:controlsfx:11.0.0"
    compile "eu.hansolo:tilesfx:11.13"
    compile "com.jfoenix:jfoenix:9.0.9"
    compile "org.apache.httpcomponents:httpclient:4.5.9"
    compile "org.json:json:20180813"
    compile "mysql:mysql-connector-java:8.0.17"
    compile "org.jasypt:jasypt:1.9.3"
    compile "com.mchange:c3p0:0.9.5.4"
    compile "com.sun.mail:javax.mail:1.6.2"
    compile "commons-validator:commons-validator:1.6"

}

javafx {
    version = "13"
    modules = [ 'javafx.controls','javafx.graphics', 'javafx.fxml'  ]
}

mainClassName = 'Main'

runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']

    jpackage {
        jpackageHome = 'C:/Program Files/Java/openjdk-14-jpackage+1-49_windows-x64_bin/'

        if(org.gradle.internal.os.OperatingSystem.current().windows) {
            installerType = 'msi'
            //"src/main/resources/images/logo.png"
            //--icon
            //imageOptions = ['--icon src/main/resources/images/logo.png']
            installerOptions = ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-shortcut']
        }
    }

}

compileJava {
    doFirst {
        options.compilerArgs = [
                '--module-path', classpath.asPath,
                '--add-modules', 'javafx.controls,javafx.fxml'
        ]
    }
}

run {
    doFirst {
        jvmArgs = [
                '--module-path', classpath.asPath,
                '--add-modules', 'javafx.controls,javafx.fxml'
        ]
    }
}

group = 'br.redacted'
version = '0.1'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

https://badass-runtime-plugin.beryx.org/releases/latest/#_the_jpackage_script_block

DJViking commented 4 years ago

You can set --icon with the imageOptions. For Windows this needs to be an ICO file.

KenobySky commented 4 years ago

You can set --icon with the imageOptions. For Windows this needs to be an ICO file.

It worked greatly! Thanks!

May I ask one additional question? Is it possible to change the msi installer default language? Im in Brazil and the current setup installation is in en-us. It might be a *problem for some users.

DJViking commented 4 years ago

WiX supports building localized installers through the use of language files that include localized strings. However I don't think this can be customized with jpackage. Definitely a needed improvement to jpackage. I can check with the team working on jpackage if it is planned to support localization.

KenobySky commented 4 years ago

I would love if you could do that. Should I close this issue? Its been solved. Your plugin is really amazing. I was using maven and was having many issues, plus the building time was longer.

Thanks a lot!

KenobySky commented 4 years ago

@DJViking Hi! I noticed this ticker regarding localization: https://bugs.openjdk.java.net/browse/JDK-8232136

Hopefully they will implement it.

DJ, Might I ask you if theres anyway to request/add some kind of splash screen while the .exe loads when the user opens the program?

siordache commented 4 years ago

@KenobySky You may take a look at the badass-jlink-example-richtextfx application. It uses the badass-jlink-plugin, but the same approach should also work with the badass-runtime-plugin.