Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to distribute JRE into a separate directory? #122

Open
Ali-RS opened this issue Feb 19, 2022 · 4 comments
Open

How to distribute JRE into a separate directory? #122

Ali-RS opened this issue Feb 19, 2022 · 4 comments
Labels
question Further information is requested

Comments

@Ali-RS
Copy link

Ali-RS commented Feb 19, 2022

Hi

The runtime and runtimeZip tasks add JRE binaries into the "lib" directory where my app jars are. Also, a "conf" and "legal" directory is created inside the app directory. How can I change this so all JRE-related stuff gets moved into a single directory named "jre" inside the app directory?

Regards

@Ali-RS
Copy link
Author

Ali-RS commented Feb 19, 2022

Looks like it copies Jre here.

@siordache is there a way to override it?

@Ali-RS
Copy link
Author

Ali-RS commented Feb 20, 2022

For now I could fix it with the below snippet but there should be a cleaner way to do it.

tasks.runtime.doLast {
    if(runtime.targetPlatforms) {
        runtime.getTargetPlatforms().get().values().forEach { platform ->
            File jreDir = new File(runtime.jreDir.get().asFile, "$project.name-$platform.name")
            File imageDir = new File(runtime.imageDir.get().asFile, "$project.name-$platform.name")
            createRuntime(jreDir, imageDir)
        }
    } else {
        createRuntime(runtime.jreDir.get().asFile, runtime.imageDir.get().asFile)
    }
}

void createRuntime(File jreDir, File imageDir) {
    project.delete(imageDir)
    copyJre(jreDir, imageDir)
    copyAppTo(imageDir)
}

void copyJre(File jreDir, File imageDir) {
    project.copy {
        from jreDir
        into new File(imageDir, "jre")
    }
}

void copyAppTo(File imageDir) {
    project.copy {
        from("$buildDir/install/$project.name")
        into imageDir
    }
}

@sunsteam
Copy link

sunsteam commented Jun 15, 2022

Reassign the runtime dir to another path is not a problem, you can

  1. create a task dependsOn build task, reassign runtime and remove it.
  2. Also, need add app.runtime=new jre path below [Application] in projectName.cfg in App Dir. There is no good way to amend this cfg easily, so I bakup one common cfg and cover it. Do not add version variable in project build.gradle, otherwise the content in cfg will change with version.
  3. The best way is plugin can offer a variable to set them auto, but haven't yet.
task afterBuildTask(dependsOn: jpackageImage) doLast {
    def raw = "${rootDir}/gem"
    def build = "${buildDir}/jpackage/gem"

    copy {
        from "${raw}/gemConfig"
        into "${build}/gemConfig"
        exclude 'config.json'
        exclude 'recipes.json'
        exclude 'dynamic.*'
    }
    copy {
        from "${raw}/appCfgBackup/gem.cfg"
        into "${build}/app"
    }
    copy {
        from "${raw}"
        into "${build}"
        include '*.dll'
        include 'UpdateLog.txt'
    }
    delete "${build}/runtime"
}
[Application]
app.classpath=$APPDIR\gem-all.jar
app.mainclass=com.juno.gem.Launcher
app.runtime=C:\Juno\runtime\jrt
[JavaOptions]
java-options=-Djpackage.app-version=1.0
java-options=-Djava.library.path=C:/Juno/runtime;$APPDIR\..

@hakanai
Copy link
Collaborator

hakanai commented Jan 15, 2023

I just did a test build here and the layout I see is nothing like what's described above.

I get:

  • non-modular-hello\
    • app\
    • runtime\
    • non-modular-hello.exe
    • non-modular-hello.ico

app then has the jars for the app, while runtime looks like the cut-down JRE.

This ticket is quite old, however, so it's quite possible the software is a completely different version now, or you were running on a much older JDK.

Is this issue still a problem? There's still no way to configure the layout, but the jre is at least in its own directory.

@hakanai hakanai added the question Further information is requested label Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants