BULDING使用Ant多平台的SWT应用程序 [英] Bulding an multi-platform SWT application using Ant

查看:325
本文介绍了BULDING使用Ant多平台的SWT应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写这可以在Windows(32/64位)和Mac OSX(32/64位)。

I'm writing an SWT application which can be used on Windows (32/64 bit) and Mac OSX (32/64 bit).

除了JRE我靠SWT库中发现的此处。我能找到这取决于我的目标平台的SWT库的四个版本(如上所述)。

Apart from the JRE I rely on the SWT library found here. I can find four versions of the SWT library depending upon my target platforms (as mentioned above).

在构建我的应用程序,我怎么能编译使用正确的SWT罐?如果可能的话,我想尽量避免硬编码的Jar版本,平台和体系结构。 SWT的罐子被命名为这样的:

When building my application, how can I compile using the correct SWT Jar? If possible, I'd like to try and avoid hard-coding the Jar version, platform and architecture. The SWT Jars are named like this:


  • SWT-Win32的x86_64.jar

  • SWT-Win32的x86_32.jar

  • SWT-MacOSX的-x86_32.jar

  • SWT-MacOSX的-x86_64.jar

(我的项目将是一个开源项目,我希望人们能下载源代码并构建它,所以我想过包括在源代码分发所有的SWT罐的四个版本。我希望这是出版code依靠第三方零件库的正确的做法。)

(My project will be an open source project. I'd like people to be able to download the source and build it and therefore I've thought of including all the four versions of the SWT Jars in the source distribution. I hope this is the correct approach of publishing code relying on third-part libraries.)

谢谢大家。

推荐答案

我试过来完成它:因为它支持我已经安装了的Ant任务的Contrib 如果语句。我修改使用来检测操作系统平台和架构我生成的文件。

I've tried to accomplish it like this: I've installed the Ant Contrib tasks because it supports if statements. I've modified my build file to use to detect the OS platform and architecture.

编译时,过来只是必要的SWT罐到我的生成目录使用所有4 SWT瓶从我的 lib.dir ,但编译后,它拷贝。我想这将让我的我最后的ZIP的大小不是让所有四个JAR文件小得多。

When compiling, it uses all the 4 SWT Jars from my lib.dir but after compilation, it copies over only the necessary SWT Jar to my build directory. I guess this would keep my size of my final ZIP much smaller than keeping all four 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 to work so far. I'll test it some more and add a comment.

这篇关于BULDING使用Ant多平台的SWT应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆