-1

I am building a setup file with InnoSetup 5.5.6 and I am also using maven to automatically build the installer. Maven is using exec-maven-plugin, so this method is eqvivalent to running iscc.exe on commandline.

What I am basically trying to do is inject a version number as a command line argument, so I can use that version number inside the setup.iss file.

Here is the command line argument (more detail below):

ISCC.exe setup.iss /d"MyAppVersion=1.0.0"

Here is the relevant code snippet from the .iss file. I've been trying with this but it is not working. If I hardcode the version, everything works fine.

[Files]
Source: "..\..\..\target\jars\my-java-project-{#MyAppVersion}.jar"; DestDir: "{app}"; DestName: "my-java-project.jar"; Flags: external

And I would like to evaluate the file as:

my-java-project-1.0.0.jar

Not sure whether it is even possible, but thanks for the help in advance.

(EDIT1)

Thank you everyone who put in effort to resolve this issue.

I think my case is not trivial, and I tried to skip not relevant information, to keep things simple, but I think I should share more info about the build.

When I manually type into cmd the command which is inside exec-maven-plugin

iscc.exe setup.iss /d"VersionText=1.0.0-SNAPSHOT" /d"VersionNumeric=1.0.0" /d"BalanceAgentVersion=1.0.0-SNAPSHOT"

then the jar file still gets omitted from the packaged exe installer.

The relevant maven codes:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
    <execution>
    <id>generate-installer</id>
    <goals>
        <goal>exec</goal>
    </goals>
    <phase>package</phase>
</execution>
</executions>
<configuration>
    <executable>${project.basedir}/src/main/resources/issc_executables/ISCC.exe</executable>

    <workingDirectory>${project.basedir}/src/main/innosetup/</workingDirectory>
    <arguments>
        <argument>${project.basedir}/src/main/innosetup/setup.iss</argument>
        <argument>/d"VersionText=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${parsedVersion.qualifier}"</argument>
        <argument>/d"VersionNumeric=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</argument>
        <argument>/d"MyAppVersion=${my-app.version}"</argument>


    </arguments>
</configuration>

maven properties:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <dependency-plugin.version>2.10</dependency-plugin.version>
    <my-app.version.version>1.0.0-SNAPSHOT</balance-agent.version>
</properties>
Chase
  • 106
  • 1
  • 9
  • 1
    Looks good. Any problem? – Martin Prikryl Mar 04 '19 at 19:05
  • The problem might lie in {#MyAppVersion} since it is a maven variable passing as argument with exec-maven-plugin. Maven gets it by parsing the version of the project. Since you are an expert, and you say this grammar is correct, I think I must check the passing variable first, because it might be off. But that means, the filename is incorrect, and Inno cannot find the file and put into the packaged installer. Usually when Inno cannot find a file with a given name, then inno gives a compile error, but not when we pass these with this {#constant} grammar. This is a bit confusing. – Chase Mar 07 '19 at 16:10
  • 1
    So what error do you get in this case? Did you try using `SaveToFile` to see what code get generated? See https://stackoverflow.com/q/3328375/850848 – Martin Prikryl Mar 07 '19 at 16:15
  • Also you wrote that the problem might be with Maven. But your question claims that you test it with `ISCC.exe setup.iss /d"MyAppVersion=1.0.0"` - so does it work or not from Windows command line? – Martin Prikryl Mar 07 '19 at 18:06
  • Installer generation was successful when I hardcoded the version in the [Files] section of the .iss file. When I used "my-java-project-{#MyAppVersion}.jar" in the .iss file, then the installer was built with no visible errors and warnings (looking at maven logs), but the actual jar file was missing from the installer. I suspect the problem is that maven passed an incorrect version to innosetup (with maven-exec-plugin), and innosetup silently just skipped the jar file because it didn't find any matching jars with the wrongly passed version. I will update what I find soon. Thanks for the help. – Chase Mar 07 '19 at 18:53
  • 1
    You have `Flags: external` - With that flag, the compiler does not check anything, because the file is processed on **install time**, not on compile time -- Is this actually what you want, isn't that a mistake? --- Also, you still didn't answer my question: Does your installer work, if you compile it manually using the command `ISCC.exe setup.iss /d"MyAppVersion=1.0.0"`? – Martin Prikryl Mar 07 '19 at 19:20
  • No, it doesn't work when I manually run `ISCC.exe setup.iss /d"MyAppVersion=1.0.0"` on the command line. The jar file gets skipped from when packaging the installer exe. The version number fits the actual jar file. Maven passes correct version. – Chase Mar 08 '19 at 20:36
  • Removing the external flag solved my problem. @MartinPrikryl If you would like one more accepted answer here on Stackoverflow I will wait 24 hours to write it, and I will accept it. Otherwise I will answer my own question. Thank you for the help. – Chase Mar 08 '19 at 21:09
  • Please delete your question. It hardly helps anyone else, as your problem just a mistake. – Martin Prikryl Mar 09 '19 at 05:51

2 Answers2

0

Try remove the quotations like this:

ISCC.exe setup.iss /dMyAppVersion=1.0.0
Osher Shuman
  • 213
  • 3
  • 7
0

Removing the external flag solved the problem. The external flag was a mistake. InnoSetup documentation:

When the flag external is specified, Source must be the full pathname of an existing file (or wildcard) on the distribution media or the user's system (e.g. "{src}\license.ini").

Constants may only be used when the external flag is specified, because the compiler does not do any constant translating itself.

I thought the {#MyAppVersion} is a constant, but it is not.

The correct code is:

[Files]
Source: "..\..\..\target\jars\my-java-project-{#MyAppVersion}.jar"; DestDir: "{app}"; DestName: "my-java-project.jar";

Thanks for Martin Prikryl, he pointed out the mistake in the comments.

Chase
  • 106
  • 1
  • 9