beryx / badass-jlink-plugin

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

Can you help me complete the build? #164

Closed xfmyh closed 3 years ago

xfmyh commented 3 years ago

gradle and badass-jlink-plugin Really complicated tool

I am building now <spring boot 2.4 + gradle 6.7.1> web application

My current module is as follows

https://github.com/xfmyh/sisglobal-eai.git

Can you help me finish building jpackage

Need to add module-info.java

Thank you

siordache commented 3 years ago

It's difficult to modularize a Spring-Boot application. It took me a week to modularize the Spring PetClinic. So, don't do it. Instead, use the Badass Runtime Plugin. Put this in your application/build.gradle:


plugins {
    id 'com.sisglobal.eai.java-application-conventions'
    id 'org.springframework.boot' version '2.4.0'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id "org.beryx.runtime" version "1.11.4"
}

dependencies {
    implementation project(":web")
    implementation 'org.springframework.boot:spring-boot-starter'
}

application {
    // Define the main class for the application.
    mainClass = 'com.sisglobal.eai.EaiApplication'
}

runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    additive = true
    modules = ['java.naming', 'java.desktop', 'java.management', 'java.security.jgss']
    jpackage {
        installerOptions += ['--resource-dir', "src/main/resources"]
        def os = org.gradle.internal.os.OperatingSystem.current()
        if(os.windows) {
            imageOptions += ['--win-console']
            installerOptions += ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-shortcut']
        }
    }
}

Then, you can run ./gradlew runtime or ./gradlew jpackage.