Present parameters based on Java program output

Comments

2 comments

  • Avatar
    juanjo

    You can just call the Java program and return the result as the stdout. Then, you can populate the options using the <addChoiceOptionsFromText> action:

    <parameterList>
      <choiceParameter>
        <name>choice</name>
        <displayType>combobox</displayType>
        ...
      </choiceParameter>
    </parameterList>
    ...
    <runProgram>
       <program>${java_bin_dir}/java</program>
       <programArguments>-jar ${installdir}/yourprogram.jar</programArguments>
    </runProgram>
    <!-- Process the stdout to get the appropriate format -->
     ....
    <addChoiceOptionsFromText>
       <name>choice</name>
       <text>${processed_text}</text>
    </addChoiceOptionsFromText>
    

    Please note that if you want to configure the choice parameter before the installation stage you will need to use an <unpackFile> action to unpack the jar file and the Java runtime (if you are not using the one from the system).

    You can find some more details in the below links:

    Run Program after Install and present Choices

    Populating Parameters at runtime

  • Avatar
    wojciechka

    It is possible to run a Java JAR before installation is performed and based on its output or exit code perform certain actions - such as set whether parameter should be shown.

    Below is an example of finding Java, unpacking a JAR file, running it and setting if installdir parameter should be shown based on if exit code is 0:

    <preInstallationActionList>
      <autodetectJava>
        <promptUser>0</promptUser>
      </autodetectJava>
      <unpackFile>
        <component>myjar</component>
        <destination>${system_temp_directory}/myjar.jar</destination>
        <folder>myjar</folder>
        <origin>myjar.jar</origin>
      </unpackFile>
      <runProgram>
        <program>${java_executable}</program>
        <programArguments>-jar "${system_temp_directory}/myjar.jar"</programArguments>
      </runProgram>
      <deleteFile>
        <path>${system_temp_directory}/myjar.jar</path>
      </deleteFile>
      <if>
        <actionList>
          <setInstallerVariable>
            <name>project.parameter(installdir).show</name>
            <value>0</value>
          </setInstallerVariable>
        </actionList>
        <conditionRuleList>
          <compareValues>
            <logic>equals</logic>
            <value1>${program_exit_code}</value1>
            <value2>0</value2>
          </compareValues>
        </conditionRuleList>
        <elseActionList>
          <setInstallerVariable>
            <name>project.parameter(installdir).show</name>
            <value>1</value>
          </setInstallerVariable>
        </elseActionList>
      </if>
    </preInstallationActionList>
    

    It is also possible to populate choice parameter options using <addChoiceOptions> or <addChoiceOptionsFromText> actions.

    Based on what exactly you want to do, you can find additional information in our User Guide:

Please sign in to leave a comment.