Question

I'm using the maven-antrun-plugin with install4j to build installers for my application. It doesn't work if java is not on the (system) path. Since it's forking a new java process to run the task, there must be a way I can pass it environment variables, but I can't figure it out.

Install4J will use EXE4J_JAVA_HOME to select a java installation. I want to pass that to ant via the antrun-plugin. I can think of a few hackish ways of doing it, but there's got to be something simple I'm overlooking. For reference, here is my antrun config:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>

    <executions>
        <execution>
            <phase>package</phase>

            <goals>
                <goal>run</goal>
            </goals>

            <configuration>
                <target>
                    <!--suppress MavenModelInspection -->
                    <taskdef name="install4j" classname="com.install4j.Install4JTask"
                        classpath="${install4j.ant.path}"/>

                    <install4j projectfile="itma-assembly-client-swing.install4j" buildids="62">
                        <variable name="verbose.version.number" value="${verbose-version-number}"/>
                        <variable name="media.file.prefix" value="${media-file-prefix}"/>
                        <variable name="main.class" value="${itma-client-swing-bootstrap-main-class}"/>
                    </install4j>
                </target>
            </configuration>
        </execution>
    </executions>
</plugin> 
Was it helpful?

Solution

Interesting question ... I did some research on it and found the property-Task for Ant which did sound promising first but it allows only read-access on environment variables. These sources on jguru and coderanch claim that an is the only way to pass environment variables from inside Ant. It's not the nicest way but perhaps you can exec the com.install4j.Install4JTask from the command-line aka via exec - perhaps that's one of your hackish ways ... :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top