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

Added support for adding default launch arguments #446

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

bleuthoot-sven
Copy link

Adds support for launching an application with default arguments.

NOTE: This currently only works for MacOS and Linux. I was unable to get it to work for Windows. I have tried editing both the startup.vbs.vtl to apply the arguments or editing the ini.vtl file to apply the arguments, but it doesn't seem to work. I have no idea what the correct way to do this would be.

I would need some help for fixing this issue so that default arguments also work on Windows before this can be merged.

startup.vbs.vtl attempt
#set ($appArgs = $StringUtils.join($info.appArgs, " "))
' Windows startup script generated by JavaPackager plugin

' Runs an executable file (exe, bat, cmd, ...)
Function Run(file, arguments)
    If FileExists(file) Then
        Set WshShell = CreateObject("WScript.Shell")
        WshShell.Run Chr(34) & Chr(34) & Chr(34) & file & Chr(34) & Chr(34) & Chr(32) & arguments & Chr(34), 0
        Set WshShell = Nothing
    End If
End Function

' Checks if a file exists
Function FileExists(FilePath)
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(FilePath) Then
        FileExists=CBool(1)
    Else
        FileExists=CBool(0)
    End If
End Function

#if ($info.bootstrapFile)
' Runs bootstrap script if exists
Run "scripts\\${info.bootstrapFile.name}"
#end

' Runs app executable
Run "${info.executable.name}", "${appArgs}"
ini.vtl attempt
main.class=${info.mainClass}
log.level=error
ini.override=true
classpath.1=libs\*.jar
classpath.2=${info.jarFile.name}
#set ($classpathCounter=3)
#foreach ($cp in $info.classpaths)
classpath.${classpathCounter}=$!{cp}
#set ($classpathCounter=$classpathCounter+1)
#end
#if ($info.bundleJre)
vm.location=${info.jreDirectoryName}\\${info.winConfig.vmLocation}
#else
vm.location=%JAVA_HOME%\bin\client\jvm.dll|%JAVA_HOME%\bin\server\jvm.dll
#end
#if (!$info.bundleJre && $info.jreMinVersion)
vm.version.min=${info.jreMinVersion}
#end
#if ($info.useResourcesAsWorkingDir)
working.directory=.
#end
#set ($vmArgsCounter=1)
#foreach ($vmArg in $info.vmArgs)
vmarg.${vmArgsCounter}=$!{vmArg}
#set ($vmArgsCounter=$vmArgsCounter+1)
#end
#set ($appArgsCounter=1)
#foreach ($appArg in $info.appArgs)
arg.${appArgsCounter}=$!{appArg}
#set ($appArgsCounter=$appArgsCounter+1)
#end

[ErrorMessages]
java.not.found=A suitable version of Java could not be found on your system. Please contact ${info.organizationName}.
java.failed=Java failed to startup successfully. Please contact ${info.organizationName}.

Closes #305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant