0

I'm using IvyDE to manage my project dependencies and Ant to build my project and perform some other tasks.

So my ivy.xml file looks like this:

<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:

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

Where the class com.Generator is packed in the ivy dependency.

Now the taskdef declaration would not compiled, this is because I did not set the classpath for the class.

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 ?

Thank you Gilad

4

1 回答 1

2

是的你可以:

最好的方法是在文件中为任务添加自己的配置及其依赖项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 任务!

于 2013-11-12T20:44:52.993 回答