The final step of building our java application (using ANT script) involves Inno Setup to package everything in a nice windows installer.
We are now upgrading our ANT script to generate both a 32-bit and a 64-bit version of our application. Our question is thus: how can we parametrize our Inno Setup config file so that it can generate both a x86 and a x64 version (it would thus be called 2x by the ANT script, with a parameter indicating the x86/x64).
In the Inno Setup config file, there is only 1 line that needs to be changed based on this parameter:
ArchitecturesInstallIn64BitMode=x64
And this is how we call Inno Setup command line from ANT:
<exec executable="C:\Program Files (x86)\Inno Setup 5\iscc.exe">
<arg value="/cc" />
<arg value="${dir.create_setup}/CreateSetup.iss" />
</exec>
Any help / hint on how to do this would be greatly appreciated !
Thanks,
Thomas
Use copy task with filtering, may be used for other dynamic values also.
your iss configfile template has :
ArchitecturesInstallIn64BitMode=#32or64#
your build.xml has :
<filter token="32or64" value="${32or64}"/>
<copy file="foobar.iss" tofile="foobaz.iss" filtering="true" overwrite="true"/>
<exec executable="C:\Program Files (x86)\Inno Setup 5\iscc.exe">
<arg value="/cc" />
<arg value="foobaz.iss" />
</exec>
then start your ant file with userproperty 32or64 like that :
ant -f build.xml -D32or64=x64
or
ant -f build.xml -D32or64=x86
copy task with filtering will replace the token #32or64# with the value of userproperty 32or64, so foobaz.iss has either :
ArchitecturesInstallIn64BitMode=x64
or
ArchitecturesInstallIn64BitMode=x86
Related
I got a simple ant target :
<target name="doxygen">
<exec executable="doxygen" dir="${basedir}/doxygen">
<arg value="Doxyfile" />
</exec>
</target>
I'm on Windows Seven.
When i try the same command line ( doxygen Doxyfile ) in the Windows console, it works perfectly. The doxygen executable can by found because i added the good path in my PATH environment variable.
But ANT juste can't find the doxygen executable and i get the following error :
build.xml:83: Execute failed: java.io.IOException: Cannot run program "doxygen.exe" : CreateProcess error=2
How can i make ANT to use the Windows PATH environment variable ?
I already tried the searchpath property, but i don't works.
You want to find where Doxygen is currently installed on your system. Then make a property with that value, so it can be overridden by people that installed doxygen somewhere else.
<property name="doxygen.path" location="C:\Program Files\Doxygen"/>
<target name="doxygen">
<exec executable="${doxygen.path}/doxygen" dir="${basedir}/doxygen">
<arg value="Doxyfile" />
</exec>
</target>
I know the automation of signature for blackberry app, as "java -jar ..signaturetool.jar....",
when I am building using hudson, i have to give at project config page by calling execute windows batch command ant task.
But am writing a build which is common for different clients, that time i want to include
this automation of signing within the build,as my app name will be changed according to the client's name and the path will be changed, so i want to execute this command line within the build, i tried this, but not working, its not executing the exec ant task.
Can anyone help me where am missing, this is the code:
<property name="signpath" location="C:/Program Files/Research In Motion/BlackBerry JDE 5.0.0/bin/SignatureTool.jar"/>
<exec executable ="cmd" os="Windows XP" >
<arg line="java -jar ${signpath} -a -c -p pswd ${codfilepath}/${uid}/${uName}_${version}_${server}.cod"/>
</exec>
I use the following ANT target for signing. It requires the use of bb_ant_tools (which seems to be an industry standard, at least among stackoverflow users).
<target name="sign" depends=""
description="Signs the final COD file by calling the BlackBerry signing server. The password is stored in the common.properties file." >
<sigtool
codfile="${cod.output.dir}/${project.output}.cod"
jdehome="${sigtool.jde}"
password="${sigtool.password}"
/>
</target>
All the parameters are stored in various properties files (I recommend keeping your signature password in a separate properties file to the rest of your project settings).
I would recommend this approach, since bb_ant_tools offers many useful features.
As to why the exec isn't working, I have had problems with exec when putting all parameters in one tag.
Try something like:
<exec executable="java" >
<arg value="-jar" />
<arg value="${signpath}" />
<arg value="-a" />
<arg value="-c" />
<arg value="-p" />
<arg value="pswd " />
<arg value="${codfilepath}/${uid}/${uName}_${version}_${server}.cod" />
</exec>
In my experience, each "space" character in the command line means you need to add a new <arg value="...." /> line to the script. ymmv.
So I'm building a project with maven, and in this maven pom we have a reference to an ant build script. The maven pom triggers this ant build to build a project (an install of alfresco with mysql database and tomcat server packed up with it).
The issue seems to be when you try to set up a database for alfresco to use through the ant build. This is the part of the ant build.
<target name="createDatabase">
<exec spawn="false" executable="${mysql.home}/bin/mysql" failonerror="true">
<arg value="-u" />
<arg value="root" />
<arg value="-e" />
<arg value="source ${alfresco.home}\mysql\db_setup.sql" />
</exec>
</target>
I'm getting 'unknown command '\U' sent back to me as an error on this. Of course you can install the DB manually but I want it as part of this ant script. SOmeone I work with runs this successfully on XP, but I'm getting that error on win7. Any ideas?
I'm developing an ant script which is calling another ant script using the <ant> task. This ant script is an installer a Java product and is to be used by our customers, who will have ant installed separately.
The script being called uses the antlr task <antlr:ant-antlr3>. To do this I must place the ant-antlr3.jar file in the ant lib directory, as well as adding antlr-3.2.jar to the classpath.
But I don't want to have this dependency of having ant-antl3.jar file in the client's own installed version of ant.
Is there a way of providing the equivalent to ant's command-line '-lib' option to specify other paths for jars to be added to antlib using the <ant> task itself?
I've taken a look at the online docs and there doesn't seem to be a way.
Thanks
I believe the accepted way to do this is to manually set up your classpath in the build file rather than implicitly including it via the global ant lib directory. i.e.
<path id="master-classpath">
<fileset dir="${lib}" />
<fileset file="${findbugs-base}/lib/annotations.jar" />
<pathelement location="${build-classes}" />
</path>
You can then use this path element in any task that can accept classpath args such as javac
<javac
destdir="${out}"
source="1.5"
target="1.5"
debug="true">
<src path="${src}" />
<classpath refid="master-classpath" />
</javac>
This way, the global ant set up isn't a dependency, and you can specify any files you might need for any build, as specifically as you need to (down to a given call or target).
Obviously, this is all to be carried out in the build file you're calling from the clients' build file. This way, when you call out to yours, the classpath will be set up exactly as you desire.
Another far less idiomatic possibility would be to literally shell out with the Exec Task and call ant that way. Obviously, with the provision of the Ant task, the developers of ant don't recommend you doing that. It is an option, nonetheless.
Tim's answer gives most of the story, but in order to run Ant and set JVM options, you'd need to invoke it via the java task.
There is an example of running this way in the Ant docs, here slightly modified to include -lib:
<java
classname="org.apache.tools.ant.launch.Launcher"
fork="true"
failonerror="true"
dir="${sub.builddir}"
timeout="4000000"
taskname="startAnt"
>
<classpath>
<pathelement location="${ant.home}/lib/ant-launcher.jar"/>
</classpath>
<arg value="-lib"/>
<arg value="${path.to.your.antlr.jar}"/>
<arg value="-buildfile"/>
<arg file="${sub.buildfile}"/>
<arg value="${sub.target}"/>
</java>
<target name="results">
<echo message="Calculating QI" />
<java jar="jmt.jar" fork="true" failonerror="true" maxmemory="1024m" classpath="jmt/jmt">
<arg value="-name:KIS"/>
<arg value="-results:CONSOLE"/>
<arg value="../allJavas.jar"/>
</java>
</target>
i want from folder tmp run jar file in folder jmt/jmt. It must be run inside jmt/jmt folder becouse of dependencies files.
i can run it like <java jar="jmt/jmt/jmt.jar" but then dependencies files are not ok. I try to use classpath but not working. What i am doing wrong?
Use the dir="jmt/jmt" attribute to specify the folder to launch the java process in, and use jar="jmt/jmt/jmt.jar" to specify the jar. You probably don't need to classpath attribute at all.
See http://ant.apache.org/manual/Tasks/java.html
The java ant task takes an option parameter dir="jmt/jmt" that will tell the forked VM where to execute.