Gravity Grave
Gravity Grave

Reputation: 2862

How to bundle extra files with jlink image

I'm using Gradle with the Badass JLink Plugin to distribute my software. Unfortunately, I can't figure out how to include certain files in the image (e.g. README.md, some test input, etc.). I assume it requires some work in build.gradle, but I've so far not been able to figure it out.

It's easy to do this using the application plugin's distZip functionality by following these instructions, but I prefer to distribute using a jlink image so users don't need to have Java installed.

Is this even possible to do with jlink? If not, it seems like a huge drawback.

Upvotes: 2

Views: 1130

Answers (2)

Vincent
Vincent

Reputation: 11

Thanks for this, it really helped. For me, I was trying to add to installer. I had to do the following:

def JLINK_DIR = "$buildDir/jpackage/MyApp"

tasks.jpackage.doFirst {
    copy {
        from("/config") {
            include "config.properties"
        }
        into JLINK_DIR + "/config"
    }
}

Upvotes: 1

Gravity Grave
Gravity Grave

Reputation: 2862

Thanks to the useful comments from @VGR, I was able to come up with this solution to my problem in build.gradle:

def JLINK_DIR = "$buildDir/myApp"

tasks.jlink.doLast {
    copy {
        from("/") {
            include "README.md", "LICENSE"
        }
        into JLINK_DIR + "/docs"
    }
    copy {
        includeEmptyDirs = false
        from("/path/to/sample/input") {
            include "sample_input_1/*"
            include "sample_input_2/*"
            exclude "output"
        }
        into JLINK_DIR + "/sample_input"
    }
}

The Gradle Docs on copy and the Badass JLink Plugin examples were especially helpful.

Upvotes: 3

Related Questions