PDA

View Full Version : Laszlo and ANT


blakely
11-05-2004, 06:05 AM
Heya Everyone!

I'm in process of starting two major development efforts with Laszlo--I'll post the URLs when there's more interesting stuff to see besides the UI widget POC's.

Anyway, I'm using eclipse (with XML buddy) and ANT for the build process. I have the ANT all configured to do everything I need, from building to my local dev machine, all the way to remote builds and incremental releases. So that's no trouble.

For both these projects, I have a need to occasionally use Laszlo to create a "standalone" SWF. I know how do do that with the ?lzt=swf thing. Has anyone done this from ANT? I read somewhere on here about a tool called "lzc", but it isn't in my laszlo distribution and I can't find that thread any more.

Basically, in the build process, I want to copy the LZX file to the right place, "compile" it, and then have the output somewhere easily accessible--all from ANT.

I appreciate any help in advance. I can do things in an hour with Laszlo that would take me personally *days* of fidgeting with Flash itself, so this would be a major time saver.

-Blake

rajubitter
11-22-2005, 03:26 AM
Hi Blake,

The code you would have to use in Ant should be similar to this:


<property name="lzc.args" value="--runtime=swf7"/>
<property name="openlaszlo.home" value="D:/openlaszlo-3.1" />

<!-- CLASSPATH für Laszlo Compiler -->
<path id="laszlo.compiler.classpath">
<pathelement location="${openlaszlo.home}/WEB-INF/lps/server/build"/>
<pathelement location="${openlaszlo.home}/WEB-INF/classes"/>
<fileset dir="${LPS_HOME}/3rd-party/jars/dev" includes="**/*.jar"/>
<fileset dir="${openlaszlo.home}/WEB-INF/lib" includes="**/*.jar"/>
</path>

<target name="SOLO-compile-file" depends="init" description="Compile some file to SWF">
<echo message="Compiling ${file}"/>
<echo message="arg: ${lzc.args} ${file}"/>
<echo message="Using LPS_HOME: ${openlaszlo.home}"/>
<java classpathref="laszlo.compiler.classpath"
classname="org.openlaszlo.compiler.Main"
fork="yes"
>
<jvmarg value="-DLPS_HOME=${openlaszlo.home}"/>
<arg line="${lzc.args} ${file}"/>
</java>
</target>


You still would have to define the file which has to be compiled. Important: The jvmarg (args for VM) only work, if you set the attribute fork="yes" on the java element.

Best, Raju

kolchanov
12-07-2005, 05:15 AM
Thank you rajubitter,

Your task SOLO-compile-file is very usefull.
I have added my own target to define file to compile.

<target name="SOLO-compile-all-files">
<foreach target="SOLO-compile-file" param="file">
<fileset dir="${lzx.dir}" includes="**/*.lzx">
<depend targetdir="${swf.dir}">
<mapper type="glob" from="*.lzx" to="*.swf"/>
</depend>
</fileset>
</foreach>
</target>

I got foreach task from ant-contrib package (http://ant-contrib.sourceforge.net/)

I hope this target would be also usefull.

Andrey

rajubitter
12-14-2005, 04:02 AM
Good idea to use a foreach element to process all lzx files. Works fine for me.

Here's the code:


<target name="solo-compile-all-files">
<echo message="Compiling all LZX files to SWF"/>
<foreach target="solo-compile-file" param="file">
<path>
<fileset dir="${solo.dir}/targetdir1" includes="*.lzx" />
<fileset dir="${solo.dir}/targetdir2" includes="*.lzx"/>
</path>
</foreach>
</target>

<target name="solo-compile-file" description="Compile the file handed to this target by solo-compile-all-files">
<echo message="Compiling ${file}"/>
<echo message="arg: ${lzc.args} ${file}"/>
<echo message="Using LPS_HOME: ${openlaszlo.home}"/>
<java classpathref="laszlo.compiler.classpath" classname="org.openlaszlo.compiler.Main" fork="yes">
<jvmarg value="-DLPS_HOME=${openlaszlo.home}"/>
<arg line="${lzc.args} ${file}"/>
</java>
</target>



Had to put the filesets inside a path element within the foreach, though.

Raju