Reputation: 401
I create a set of installers with install4j, and would like a quick way to check the version info of the installer executable
Traditionally, this would involve calling something like installer-name.sh --version
Ideally, this would work without needing to unpack the bundled JRE, but I notice that even the -h
help for install4j installers unpacks the JRE, so I am assuming that is not an option...
What I'd like to know is:
-h
, which do one task (like print version info), and then exit gracefullycontext.getExtraCommandLineArguments()
, is there a way to successfully exit an installation after a certain action runs, without needing to force a "Quit on failure".
--version
and then the rest of my installation in a conditional group.==============
To be clear what I mean by the last point is that I would like a solution like (framing install4j installation actions as a Java function):
if(versionRequested){
printVersion();
return;
}
//all the rest of my installation actions
rather than:
if(versionRequested){
printVersion();
}
else{
//all the rest of my installation actions
}
Upvotes: 1
Views: 398
Reputation: 48070
In the "Startup" node of the installer, add a "Run script" action with the script
if (Arrays.asList(context.getExtraCommandLineArguments()).contains("--version")) {
System.out.println("Version " + context.getCompilerVariable("sys.version"));
context.finish(0);
}
return true;
On Windows, System.out.println
will not print to the console, because the installer is a GUI application, so you would have to call
Util.showMessage("Version " + context.getCompilerVariable("sys.version"));
which also behaves correctly in console mode.
Upvotes: 1