简体   繁体   English

从Ivy依赖中定义Ant任务

[英]Definning Ant task from Ivy dependency

I'm using IvyDE to manage my project dependencies and Ant to build my project and perform some other tasks. 我正在使用IvyDE来管理我的项目依赖项和Ant来构建我的项目并执行其他一些任务。

So my ivy.xml file looks like this: 所以我的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>

I want to define a new task in my build.xml file, something like this: 我想在build.xml文件中定义一个新任务,如下所示:

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

Where the class com.Generator is packed in the ivy dependency. 类com.Generator包含在常春藤依赖项中。

Now the taskdef declaration would not compiled, this is because I did not set the classpath for the class. 现在taskdef声明不会编译,这是因为我没有为类设置classpath

My question is, if it is possible to refer to the ivy dependency from the build.xml file so I can define the new task ? 我的问题是,如果可以从build.xml文件中引用ivy依赖项,那么我可以定义新任务吗?

Thank you Gilad 谢谢吉拉德

Yes you can: 是的你可以:

The best way is to add an own configuration and its dependency for the task in your ivy.xml file: 最好的方法是在ivy.xml文件中为任务添加自己的配置及其依赖项:

<configuration>
  <conf name="generator" visibility="private"/>
</configuration>

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

Then you can use it in your build.xml : 然后你可以在build.xml使用它:

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

You need the ivy task defined to do so! 您需要定义的常春藤任务才能这样做!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM