classpath中的taskdef? [英] Classpath for taskdef?

查看:150
本文介绍了classpath中的taskdef?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义Ant中新任务。
我出口它作为一个罐子,并添加到我的构建文件:

I am defining a new task in Ant. I exported it as a jar and added to my buildfile:

<taskdef classname="X" classpath="Y.jar"/>

的问题是,这无法在运行。
它告诉我它没有找到类。
通过添加的jar到classpath,这是纠正。

The problem is that this fails at runtime. It tells me it didn't find the class. By adding the jar to the classpath, it is corrected.

我的问题是:有没有可以参考我从Ant构建我的罐子的一种方式,在不改变类路径

My question is: Is there a way that I can refer to my jar from the Ant buildfile, without changing the classpath?

推荐答案

如果你知道你的JAR的路径,ant脚本里面可以定义自己的任务的类路径。

If you know the path of your jar, inside ant script you can define the classpath for your own task.

<taskdef name="myTaskName" classname="com.myorg.myclass">
  <classpath>
    <pathelement location="pathToMyJar.jar"/>
  </classpath>
</taskdef>

这篇关于classpath中的taskdef?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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