java - Bulding an multi-platform SWT application using Ant -


i'm writing swt application can used on windows (32/64 bit) , mac osx (32/64 bit).

apart jre rely on swt library found here. can find 4 versions of swt library depending upon target platforms (as mentioned above).

when building application, how can compile using correct swt jar? if possible, i'd try , avoid hard-coding jar version, platform , architecture. swt jars named this:

  • swt-win32-x86_64.jar
  • swt-win32-x86_32.jar
  • swt-macosx-x86_32.jar
  • swt-macosx-x86_64.jar

(my project open source project. i'd people able download source , build , therefore i've thought of including 4 versions of swt jars in source distribution. hope correct approach of publishing code relying on third-part libraries.)

thanks everyone.

i've tried accomplish this: i've installed ant contrib tasks because supports if statements. i've modified build file use detect os platform , architecture.

when compiling, uses 4 swt jars lib.dir after compilation, copies on necessary swt jar build directory. guess keep size of final zip smaller keeping 4 jars.

<target name="copy" depends="compile">     <if>     <os family="windows"/>     <then>         <exec dir="." executable="cmd" outputproperty="command.ouput">             <arg line="/c set programfiles(x86)"/>         </exec>         <if>             <contains string="${command.ouput}" substring="program files (x86)"/>             <then>                 <copy file="${lib.dir}/swt-win32-x86_64.jar" tofile="${jar.dir}/swt.jar"/>             </then>             <else>                 <copy file="${lib.dir}/swt-win32-x86_32.jar" tofile="${jar.dir}/swt.jar"/>             </else>         </if>     </then>     <elseif>         <os family="unix"/>         <then>             <exec dir="." executable="/bin/sh" outputproperty="command.ouput">                 <arg line="/c uname -m"/>             </exec>             <if>                 <contains string="${command.ouput}" substring="_64"/>                 <then>                     <copy file="${lib.dir}/swt-macosx-x86_64.jar" tofile="${jar.dir}/swt.jar"/>                 </then>                 <else>                     <copy file="${lib.dir}/swt-macosx-x86_32.jar" tofile="${jar.dir}/swt.jar"/>                 </else>             </if>         </then>     </elseif>     </if> </target> 

this seems work far. i'll test more , add comment.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -