Skip to content

Commit

Permalink
issue #84: Val Cannot be Reassigned
Browse files Browse the repository at this point in the history
  • Loading branch information
siordache committed May 22, 2021
1 parent 1696344 commit 9047502
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 31 deletions.
4 changes: 2 additions & 2 deletions doc/user_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ runtime {
runtime {
...
launcher {
jvmArgs.addAll(listOf(
jvmArgs = listOf(
"-Dlog4j.debug=true", "-Dlog4j.configurationFile={{BIN_DIR}}/log4j2.xml",
"-DdbHost", "{{PGHOST}}"
))
)
unixScriptTemplate = file("unixStartScript.txt")
windowsScriptTemplate = file("windowsStartScript.txt")
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/groovy/org/beryx/runtime/RuntimeTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.beryx.runtime.data.LauncherData
import org.beryx.runtime.data.RuntimeTaskData
import org.beryx.runtime.data.TargetPlatform
import org.beryx.runtime.impl.RuntimeTaskImpl
import org.gradle.api.GradleException
import org.gradle.api.execution.TaskExecutionGraph
import org.gradle.api.file.Directory
import org.gradle.api.tasks.*
Expand Down Expand Up @@ -87,7 +86,7 @@ class RuntimeTask extends BaseTask {

void configureStartScripts(boolean asRuntimeImage) {
project.tasks.withType(CreateStartScripts) { CreateStartScripts startScriptTask ->
startScriptTask.defaultJvmOpts = launcherData.jvmArgs
startScriptTask.defaultJvmOpts = launcherData.jvmArgsOrDefault
startScriptTask.doLast {
startScriptTask.unixScript.text = startScriptTask.unixScript.text.replace('{{BIN_DIR}}', '$APP_HOME/bin')
startScriptTask.unixScript.text = startScriptTask.unixScript.text.replace('{{HOME_DIR}}', '$HOME')
Expand Down
27 changes: 17 additions & 10 deletions src/main/groovy/org/beryx/runtime/data/JPackageData.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ class JPackageData {
@Input
String outputDir = 'jpackage'

@Internal
File imageOutputDir

@Internal
String imageName

@Input
Expand All @@ -60,8 +62,10 @@ class JPackageData {
@Input @Optional
String installerType

@Internal
File installerOutputDir

@Internal
String installerName

@Input @Optional
Expand All @@ -70,13 +74,16 @@ class JPackageData {
@Input
List<String> installerOptions = []

private List<String> args = []
@Internal
List<String> args = []

private List<String> jvmArgs = []
@Internal
List<String> jvmArgs = []

@Input @Optional
String mainJar

@Internal
String mainClass

JPackageData(Project project, LauncherData launcherData) {
Expand All @@ -86,36 +93,36 @@ class JPackageData {
}

@Input
List<String> getArgs() {
List<String> getArgsOrDefault() {
this.@args ?: Util.getDefaultArgs(project)
}

@Input
List<String> getJvmArgs() {
this.@jvmArgs ?: launcherData.jvmArgs
List<String> getJvmArgsOrDefault() {
this.@jvmArgs ?: launcherData.jvmArgsOrDefault
}

@Input
String getMainClass() {
String getMainClassOrDefault() {
this.@mainClass ?: Util.getMainClass(project)
}
@Input
String getImageName() {
String getImageNameOrDefault() {
this.@imageName ?: project.name
}

@Input
String getInstallerName() {
String getInstallerNameOrDefault() {
this.@installerName ?: project.name
}

@OutputDirectory
File getImageOutputDir() {
File getImageOutputDirOrDefault() {
this.@imageOutputDir ?: project.file("$project.buildDir/$outputDir")
}

@OutputDirectory
File getInstallerOutputDir() {
File getInstallerOutputDirOrDefault() {
this.@installerOutputDir ?: project.file("$project.buildDir/$outputDir")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ class JPackageTaskData {
JPackageData jpackageData

void configureAppImageDir() {
final def imageOutputDir = jpackageData.getImageOutputDir()
final def imageName = jpackageData.getImageName()
final def appImagePath = "${imageOutputDir}${File.separator}${imageName}"
final def imgOutDir = jpackageData.imageOutputDirOrDefault
final def imageName = jpackageData.getImageNameOrDefault()
final def appImagePath = "${imgOutDir}${File.separator}${imageName}"
appImageDir = new File(appImagePath)

if (OperatingSystem.current().macOsX) {
if (!appImageDir.directory) {
def currImagePath = "${appImagePath}.app"
if (!new File(currImagePath).directory) {
throw new GradleException("Unable to find the application image in ${imageOutputDir}")
throw new GradleException("Unable to find the application image in ${imgOutDir}")
}
appImageDir = new File(currImagePath)
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/groovy/org/beryx/runtime/data/LauncherData.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import org.gradle.api.tasks.Optional
class LauncherData {
private final Project project

private List<String> jvmArgs = []
@Internal
List<String> jvmArgs = []

LauncherData(Project project) {
this.project = project
Expand All @@ -50,7 +51,7 @@ class LauncherData {
File windowsScriptTemplate

@Input
List<String> getJvmArgs() {
List<String> getJvmArgsOrDefault() {
this.@jvmArgs ?: Util.getDefaultJvmArgs(project)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class JPackageImageTaskImpl extends BaseTaskImpl<JPackageTaskData> {
}

def jpd = td.jpackageData
def outputDir = jpd.imageOutputDir
def outputDir = jpd.imageOutputDirOrDefault
project.delete(outputDir)

def jpackageExec = "${jpd.getJPackageHomeOrDefault()}/bin/jpackage$EXEC_EXTENSION"
Expand All @@ -65,16 +65,16 @@ class JPackageImageTaskImpl extends BaseTaskImpl<JPackageTaskData> {
final def resourceDir = jpd.getResourceDir()
final def resourceOpts = resourceDir == null ? [] : [ '--resource-dir', resourceDir ]

final def jvmArgs = (jpd.jvmArgs ? jpd.jvmArgs.collect{[ '--java-options', adjustArg(it) ]}.flatten() : [])
final def args = (jpd.args ? jpd.args.collect{['--arguments', adjustArg(it)]}.flatten() : [])
final def jvmArgs = (jpd.jvmArgsOrDefault ? jpd.jvmArgsOrDefault.collect{['--java-options', adjustArg(it) ]}.flatten() : [])
final def args = (jpd.argsOrDefault ? jpd.argsOrDefault.collect{['--arguments', adjustArg(it)]}.flatten() : [])

commandLine = [jpackageExec,
'--type', 'app-image',
'--input', "$td.distDir${File.separator}lib",
'--main-jar', jpd.mainJar ?: Util.getMainDistJarFile(project).name,
'--main-class', jpd.mainClass,
'--main-class', jpd.mainClassOrDefault,
'--dest', outputDir,
'--name', jpd.imageName,
'--name', jpd.imageNameOrDefault,
*versionOpts,
'--runtime-image', td.jreDir,
*resourceOpts,
Expand Down
15 changes: 9 additions & 6 deletions src/main/groovy/org/beryx/runtime/impl/JPackageTaskImpl.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ class JPackageTaskImpl extends BaseTaskImpl<JPackageTaskData> {
return
}

if (jpd.getImageOutputDir() != jpd.getInstallerOutputDir()) {
project.delete(project.files(jpd.getInstallerOutputDir()))

def imgOutDir = jpd.imageOutputDirOrDefault
def installerOutDir = jpd.installerOutputDirOrDefault
if (imgOutDir != installerOutDir) {
project.delete(project.files(installerOutDir))
}
packageTypes.each { packageType ->
if (jpd.getImageOutputDir() != jpd.getInstallerOutputDir()) {
def subdirs = jpd.getInstallerOutputDir().listFiles({ f -> f.directory } as FileFilter)
if (imgOutDir != installerOutDir) {
def subdirs = installerOutDir.listFiles({ f -> f.directory } as FileFilter)
if(subdirs) project.delete(subdirs)
}
def result = project.exec {
Expand All @@ -73,8 +76,8 @@ class JPackageTaskImpl extends BaseTaskImpl<JPackageTaskData> {

commandLine = [jpackageExec,
'--type', packageType,
'--dest', jpd.getInstallerOutputDir(),
'--name', jpd.installerName,
'--dest', jpd.getInstallerOutputDirOrDefault(),
'--name', jpd.installerNameOrDefault,
*versionOpts,
'--app-image', td.appImageDir,
*resourceOpts,
Expand Down

0 comments on commit 9047502

Please sign in to comment.