From 58a25367d389d2424f642ba669b2c6f6ea0ece7e Mon Sep 17 00:00:00 2001 From: airsquared <36649395+airsquared@users.noreply.github.com> Date: Sun, 24 Sep 2023 02:33:22 -0700 Subject: [PATCH] Do not require mainClass and moduleName to be set in secondaryLauncher (#213) --- .../groovy/org/beryx/jlink/data/SecondaryLauncherData.groovy | 4 ++-- src/main/groovy/org/beryx/jlink/impl/JlinkTaskImpl.groovy | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/org/beryx/jlink/data/SecondaryLauncherData.groovy b/src/main/groovy/org/beryx/jlink/data/SecondaryLauncherData.groovy index a823739b..780b15c5 100644 --- a/src/main/groovy/org/beryx/jlink/data/SecondaryLauncherData.groovy +++ b/src/main/groovy/org/beryx/jlink/data/SecondaryLauncherData.groovy @@ -35,8 +35,8 @@ class SecondaryLauncherData extends LauncherData { @CompileDynamic void check() { - ["name", "moduleName", "mainClass"].each { - if(!this."$it") throw new GradleException("Property '$it' not set in 'secondaryLauncher' block") + if (!this.name) { + throw new GradleException("Property 'name' not set in 'secondaryLauncher' block") } } } diff --git a/src/main/groovy/org/beryx/jlink/impl/JlinkTaskImpl.groovy b/src/main/groovy/org/beryx/jlink/impl/JlinkTaskImpl.groovy index b8c5b459..f0e13c3f 100644 --- a/src/main/groovy/org/beryx/jlink/impl/JlinkTaskImpl.groovy +++ b/src/main/groovy/org/beryx/jlink/impl/JlinkTaskImpl.groovy @@ -181,7 +181,9 @@ class JlinkTaskImpl extends BaseTaskImpl { def generator = new LaunchScriptGenerator(project, td.moduleName, td.mainClass, td.launcherData) generator.generate("$imageDir/bin") td.secondaryLaunchers.each { launcher -> - def secondaryGenerator = new LaunchScriptGenerator(project, launcher.moduleName, launcher.mainClass, launcher) + def moduleName = launcher.moduleName ? launcher.moduleName : td.moduleName + def mainClass = launcher.mainClass ? launcher.mainClass : td.mainClass + def secondaryGenerator = new LaunchScriptGenerator(project, moduleName, mainClass, launcher) secondaryGenerator.generate("$imageDir/bin") } }