无法使用swtjar ant脚本 [英] Unable to make ant script with swtjar

查看:124
本文介绍了无法使用swtjar ant脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个跨平台使用SWT其GUI程序的的.jar。我偶然发现的this,并试图在自己的程序中使用它。我不是很有经验的Ant脚本,而这种方案有很多的构建路径等.jar文件,所以我用Eclipse来生成一个Ant构建脚本,我修改,以包括swtjar任务。然而,脚本运行,并得到了swtjar任务时,它失败,并说归档swtjar.jar不存在。我也试图使合法的构建文件较早,也得到了这个错误。有我丢失的东西?我已经包括在构建路径swtjar.jar,并在脚本的顶部的taskdef。

下面的脚本:

 <?XML版本=1.0编码=UTF-8独立=无&GT?;
<项目默认=create_run_jarNAME =创建项目kEllyIRClient运行的JAR>
<! - 这个文件是由Eclipse中运行的JAR导出向导创建 - >
<! - ANT 1.7是必需的 - ><的taskdef NAME =swtjar类名=org.swtjar.ant.SWTJarTask
                       CLASSPATH =./库/ swtjar.jar/><目标名称=create_run_jar>    <! - 使发布目录,如果不存在的话 - >
    < MKDIR DIR =./发布//>    <! - 创建的所有依赖临时jar文件(即libs文件夹) - GT;
    <罐子jar文件=./发布/ externalLibsTemp.jar>
      < zipgroupfileset DIR =./库/>
        <排除NAME =SWT / * SWT的* .jar/>
        <排除NAME =swtjar.jar/>
        <包括姓名=** / *罐子。/>
      < / zipgroupfileset>
    < /瓶>    <! - 包SWT - >
    < swtjar jar文件=./发布/ KEllyIRC.jartargetmainclass =shared.Initializerswtversion =3.7.1>
        <文件集DIR =./斌/>
        <! - 依赖JAR添加到罐子里,但不包括META-INF /清单的东西
        会导致螺钉东西了.-->
        < zipfileset排除=META-INF / * SFSRC =./发布/ externalLibsTemp.jar/>
        <文件集DIR =./库/ SWT /包括=SWT-win32-3.7.1.jar/>
    < / swtjar&​​GT;    <! - 删除临时文件 - >
    <删除文件=./发布/ externalLibsTemp.jar/>< /目标与GT;

这是错误:

  D:\\我的Dropbox \\的Java \\ kEllyIRClient \\ swtjar-buildV2.xml:24:归档swtjar.jar不存在


解决方案

我留下了评论,要求运行此ant目标的输出。

在此同时,你包括你的SWT罐子不正确和错误的名字。您正在使用:

 < zipfileset排除=META-INF / * SFSRC =./库/ swtjar.jar/>
< zipfileset排除=META-INF / * SFSRC =./库/ org.eclipse.swt.win32.win32.x86_3.7.1.v3738a.jar/>


  • 您并不需要包括swtjar - 目标会自动为你做到这一点。不过,我怀疑这是不是为你工作的步骤。

  • 您还需要命名格式为您的SWT罐子swt-<平台><位数> - 罐子。所以你的情况,你需要重命名org.eclipse.swt.win32.win32.x86_3.7.1.v3738a.jar到SWT-win32-3.7.1.jar。

  • 您不应该使用zipfileset包括SWT的jar

您更名为SWT的jar应包括如下:

 <! -  SWT罐 - >
<文件集DIR =./库包括=SWT-win32-3.7.1.jar/>

这其中大部分已经被覆盖在swtjar网站: http://mchr3k.github.com/swtjar/

I am attempting to make a cross platform .jar of a program that uses SWT for its GUI. I stumbled upon this and this, and have tried to use it in my own program. I am not very experienced with ant scripts, and this program has a lot of other .jars in its build path, so I used eclipse to generate an ant build script, which I modified to include the swtjar task. However, when the script runs and gets to the swtjar task, it fails and says that The archive swtjar.jar doesn't exist. I also tried to make a legitimate build file earlier and also got this error. Is there something I'm missing? I've included swtjar.jar in the build path, and the taskdef at the top of the script.

Here's the script:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project kEllyIRClient">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required-->

<taskdef name="swtjar" classname="org.swtjar.ant.SWTJarTask"
                       classpath="./libs/swtjar.jar"/>

<target name="create_run_jar">

    <!--make the release directory if it doesn't exist-->
    <mkdir dir="./release/"/>

    <!--Create a temporary jar file with all the dependencies (i.e. the libs folder)-->
    <jar jarfile="./release/externalLibsTemp.jar">
      <zipgroupfileset dir="./libs/">
        <exclude name="swt/*swt*.jar"/>
        <exclude name="swtjar.jar"/>
        <include name="**/*.jar"/>
      </zipgroupfileset>
    </jar>

    <!--package with swt-->
    <swtjar jarfile="./release/KEllyIRC.jar" targetmainclass="shared.Initializer" swtversion="3.7.1">
        <fileset dir="./bin"/>
        <!--Add the dependencies jar to the jar, but exclude the meta-inf/manifest stuff
        cause that screws stuff up.-->
        <zipfileset excludes="META-INF/*.SF" src="./release/externalLibsTemp.jar" />
        <fileset dir="./libs/swt/" includes="swt-win32-3.7.1.jar"/>
    </swtjar>

    <!--Delete temporary file-->
    <delete file="./release/externalLibsTemp.jar"/>

</target>

And this is the error:

D:\My Dropbox\Java\kEllyIRClient\swtjar-buildV2.xml:24: The archive swtjar.jar doesn't exist

解决方案

I have left a comment asking for the output from running this ant target.

In the mean time, you are including your swt jars incorrectly and with the wrong names. You are using:

<zipfileset excludes="META-INF/*.SF" src="./libs/swtjar.jar"/>
<zipfileset excludes="META-INF/*.SF" src="./libs/org.eclipse.swt.win32.win32.x86_3.7.1.v3738a.jar"/>

  • You don't need to include swtjar - the target will do that automatically for you. However, I suspect this is the step which isn't working for you.
  • You also need to name your swt jars in the format "swt-<platform><bitness>-.jar". So in your case you need to rename "org.eclipse.swt.win32.win32.x86_3.7.1.v3738a.jar" to "swt-win32-3.7.1.jar".
  • You shouldn't include the swt jars using zipfileset

Your renamed SWT jar should be included as follows.

<!-- SWT Jars -->
<fileset dir="./libs" includes="swt-win32-3.7.1.jar" />

Most of this is already covered on the swtjar site: http://mchr3k.github.com/swtjar/

这篇关于无法使用swtjar ant脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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