IzPack Support: Jar files and TAR approach - jar

I am working on bundling a product for distribution. It uses XML standards, JSON, JQuery, html, JavaScript, and contains multiple servers. It is not a pure-java application. I do not have any main classes. When I tried to create jar files, I couldn't open them. I got an error message that there is no main class for the jar file. As a work around, I am exporting a tar file instead. Is there a better approach?
Furthermore, I am using ant script to run the installation file. I am using:
<target name="install" depends="tarChmodCompilerListener">
<izpack input="install.xml"
output="IzPack-install.jar"
installerType="standard"
basedir="${basedir}"
izPackDir="${izPackDir}" />
</target>
When I try to run the ant program, it doesn't recognize the izpack tag (I got this block of code from the IzPack wiki). I think I need a jar file to recognize this, but I do not know which one or where to find it. How can I get the build.xml to run this block of code?
I am working in a Mac environment. I am using eclipse and shell scripting. I wanted to use IzPack because it's installation programs work for exporting to Windows, Linux, or Mac. Is there a different program I should use?

You must include the taskdef tag in your ant to be able to use the izpack tag.
It should be something like this:
<!-- IzPack Dependancies -->
<path id="build.classpath">
<fileset dir="${path.to.izpack.installation.folder}/IzPack">
<include name="lib/*.jar" />
</fileset>
</path>
<taskdef name="izpack" classpathref="build.classpath" classname="com.izforge.izpack.ant.IzPackTask" />
Now it should be able to recognize the izpack tag.
Cheers!

Related

WIX create directory upon multiple files installation

I'm working on installation package of an application with a few additional ones, required for it to work. Here's a structure I have so far:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle ...>
<BootstrapperApplicationRef ... />
<Chain>
<MsiPackage ... />
<ExePackage ... />
<MsiPackage ... />
</Chain>
</Bundle>
I need to create a few directories for one of the applications (these directories won't be used upon installation). But I have no idea how to accomplish this.
I've found a lot of examples of creating directories under <Product> section. But when I use <Directory> tag inside <Bundle>, it says, that: "The Bundle element contains an unexpected child element 'Directory'".
I'm new to this tool and might be missing some basic concept. Can anyone help me understand where am I wrong?
Bundles install packages and packages are what update the machine. So to create directories, do so in the application package.

How to derive a relative path using Ant

I'm using Ant and mxmlc to compile ActionScript classes and MXML into swfs, while maintaining the default organization of a Flex Builder (Flash Builder) project. Many of my ActionScript classes are in project subdirectories, so my project is organized like the following:
MyBigProject
-build-imports.xml
-build.xml
-bin-debug
--src
---flash
---app
----CoolWidget1.swf
---Main.swf
--test
-src
--flash
---app
----build-imports.xml
----build.xml
----CoolWidget1.as
--build-imports.xml
--build.xml
--Main.mxml
-test
This directory structure maintains the default directory structure of a Flash Builder project so I can perform push-button builds from the Flash Builder IDE. I've added the Ant build xml's to this project so I can also build from the command line. I'm trying to create portable ant build scripts that require the least changes to reuse in other projects. I have everything like I want except for deriving relative paths.
The build-imports.xml file at the root of the project contains the following:
<project name="project.root.imports">
<dirname property="project.root.dir" file="${ant.file.project.root.imports}"/>
</project>
While the sub project folders contain build-imports.xml with the following:
<project name="MyBigProject.src.flash.app.imports">
<import file="../build-imports.xml" />
</project>
Notice that sub project build-imports.xml walks up the directory hiearchy till it gets to the root build-imports.xml, and there I set the project.root.dir.
I can then use the ${project.root.dir}/bin-debug to specify where to place my binaries. The only problem I have, is I do not know how to create the same directory structure as what lies under my src folder. I need to be able to derive a relative path or perform some string manipulation to create new directorys.
Considering the above information, how do I take a known path like:
${project.root.dir}/src/app
and derive a directory path like:
${project.root.dir}/bin-debug/app
I've found some information about the Ant-contribu propertyregex task, which would allow some string manipulation, but I'm hoping there is an Ant guru out there that can point to a simple solution. I believe it's highly likely as an Ant novice, I'm simply overlooking the obvious.
My build files have evolved a bit since I posted, but I've resolved the problem. I believe the following would work correctly in the basic setup previously described:
Add this to the default target in the sub project's build.xml
<path id="build.path">
<pathelement location="." />
</path>
<pathconvert property="build.dir" refid="build.path">
<map from="${project.root.dir}" to="${project.root.dir}/bin-debug"/>
</pathconvert>

Compiling flex modules into swf with other mxml files in ant

I have a huge project with many mxml and as files and am trying to compile them all into one working swf file using ant. However, I'm having trouble compiling main.swf correctly in ant.
It doesn't seem to be pulling in the necessary modules, all of which are located in separate folders within the main src folder.
It will compile without error, but when I open the swf file, there is no content -- just a shell. However, if I compile using flex builder 3's compile button, it will create the swf correctly -- content and all.
Even when using a simple mxmlc command, it throws an error for any file associated with the modules saying there is an unknown type (meaning it's not pulling in the modules).
Is there a special way that modules should be dealt with when trying to compile them into a main.swf file using ant?
Did you include a library-path element in your Ant build file?
e.g.
<target ...>
<mxmlc output="...../file.swf"
....
file=".../main.mxml">
<library-path dir="..../" append="true">
<include name="...../someModule.swc"/>

How to execute an Ant task only when source files have been modified?

There must be an easy way to do this. I build a Flex app using ant that depends on a SWC library, which works fine except that it rebuilds the library whether it needs to or not. How do I tell ant to only run the task if any of the sources files of the library (*.as, *.mxml) are newer than the SWC?
I've looked at <dependset> but it only seems to delete files, not determine whether a task should be run or not. <depend> seems to expect a one-to-one relationship between the source and target files rather than a one-to-many relationship -- I have many input files and one output file, but no intermediate object files.
Thanks a lot,
Alex
You may use the Ant uptodate task to create a property, and execute your other target only if that property is set.
I don't know much about flex, but you probably want something like this:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="compile">
<target name="checkforchanges">
<uptodate property="nochanges">
<srcfiles dir="." includes="**/*.as"/>
<srcfiles dir="." includes="**/*.mxml"/>
<mapper to="applicaton.flex"/>
</uptodate>
</target>
<target name="compile" depends="checkforchanges" unless="nochanges">
...
</target>
</project>
The OutOfDate task from the ant contrib library is IMO much cleaner than the Ant uptodate option. The reason is that you have to define additional targets just to set the property.
The solution with Ant contrib (from their example page):
<outofdate>
<sourcefiles>
<pathelement path="build.xml"/>
<fileset dir="${lib.dir}"/>
</sourcefiles>
<targetfiles path="${jrun.file}"/>
<sequential>
<mkdir dir="${build.bin.dir}"/>
<echo file="${jrun.file}" message="java -cp ${jrun.path} $*"/>
<chmod file="${jrun.file}" perm="ugo+rx"/>
</sequential>
</outofdate>
Everything is kept nicely inside one single target.

How do I create a jar file, which includes xml and html files?

I am trying to create a jar file which includes some class and java files needed, but I also would like to include some extra xml, xsl, html, txt (README) files.
I am using Eclipse on Windows XP.
Is there an easy way for me to set up a directory structure and package all my files into a jar?
Add the files to a source folder and they can be included in the jar.
One common way is to have, at the root of your project, a src folder. Within that, folders for java files, and others. something like:
src/
css/
java/
html/
images/
Then you can make each of those subfolders a source folder (Right click, Use as Source Folder) and they should be available to add to the jar.
A .jar is nothing but a ZIP archive, so you can use any program capable of creating ZIPs. Just make sure that you include the manifest and all the class files.
I just added all the files into my Eclipse project (including the txt, html, xml, etc files).
Then I used Eclipse to File->Export->Jar File->Next
Check the "Export Java source files and resources" box.
Done.
If you're using Ant, you can use the jar task (see the examples section for how to include/exclude certain files, etc.)
If you move to an ANT (or Maven, for you Maven fans) then you can automate the Jar building very nicely, and also use it outside of Eclipse (e.g., in an automated build environment). All you need to do is copy the files from your src, jsp, foobar and resources locations into a build staging folder, then Jar the resulting files using ANT's Jar task.
<target name="makejar" depends="compile, copyfiles">
<jar destfile="${jars.dir}/myjarfile.jar" index="true" basedir="${build.dir}" />
</target>
One thing I look down on is including non-source (except package.html files for Javadoc) within the src folder. If you feel you have to do this to achieve something, then you are doing it wrong.

Resources