【问题标题】:Definning Ant task from Ivy dependency从 Ivy 依赖中定义 Ant 任务
【发布时间】:2013-11-25 02:56:22
【问题描述】:

我正在使用 IvyDE 来管理我的项目依赖项,并使用 Ant 来构建我的项目并执行一些其他任务。

所以我的ivy.xml 文件如下所示:

<ivy-module version="2.0">
<info organisation="test" module="test" revision="0-RELEASE"/>
<dependencies>
    <dependency org="com.generator" name="Generator" rev="2.0-RELEASE" />
</dependencies>
</ivy-module>

我想在我的build.xml 文件中定义一个新任务,如下所示:

<taskdef name="generate" classname="com.Generator" />

com.Generator 类封装在 ivy 依赖项中。

现在taskdef 声明不会编译,这是因为我没有为类设置classpath

我的问题是,是否可以从 build.xml 文件中引用 ivy 依赖项,以便我可以定义新任务?

谢谢 吉拉德

【问题讨论】:

    标签: java ant ivy build.xml


    【解决方案1】:

    是的,你可以:

    最好的方法是在您的ivy.xml 文件中为任务添加自己的配置及其依赖项:

    <configuration>
      <conf name="generator" visibility="private"/>
    </configuration>
    
    <dependencies>
      …
      <dependency org="com.generator" 
          name="Generator" rev="2.0-RELEASE" 
          conf="generator->default"/>
    </dependencies>
    

    然后你可以在你的build.xml中使用它:

    <ivy:cachepath pathid="generator.classpath" 
        conf="generator" log="quiet"/>
    <taskdef name="generate" 
        classname="com.Generator" 
        classpathref="generator.classpath"/>
    

    您需要为此定义的 ivy 任务!

    【讨论】:

      猜你喜欢
      • 2011-05-14
      • 2012-10-25
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 2011-02-22
      • 1970-01-01
      • 1970-01-01
      • 2011-12-11
      相关资源
      最近更新 更多