我怎样才能排除在一个蚂蚁javac任务来源是什么? [英] How can I exclude sources in a javac task in ant?

查看:202
本文介绍了我怎样才能排除在一个蚂蚁javac任务来源是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的build.xml如下:

I have the following in my build.xml:

<target name="compile.baz" depends="init">
   <javac destdir="${build.dir}/classes" debug="on">
      <compilerarg value="-Xlint:deprecation"/>
      <src>
         <pathelement location="${src.dir}/com/foo/bar/baz/" />
         <pathelement location="${src.dir}/com/foo/bar/quux/" />
         <!-- Need to exclude ${src.dir}/com/foo/bar/quux/dontwant/ -->
      </src>
      <classpath refid="classpath.jars" />
   </javac>
   ...
</target>

这主要是我想要做什么,但(作为注释说)我的的希望结果文件
  $ {}对于src.dir / COM /富/酒吧/ QUUX / dontwant / 来进行此任务(编译但我想的一切的在 $ {}对于src.dir / COM /富/酒吧/ QUUX / 在这个任务中进行编译)。

This mostly does what I want, except that (as the comment says) I do not want the files in
${src.dir}/com/foo/bar/quux/dontwant/ to be compiled by this task (but I do want everything else under ${src.dir}/com/foo/bar/quux/ to be compiled in this task).

我是一个完整的蚂蚁的n00b,该文档一直没有太大的帮助我。我看到几个地方,它说有各种各样的排除/排除元素/属性,但每一个变化我能想到的或者具有类似以下这样的错误没有效果或结果的等等的不支持'排除属性。

I'm a complete ant n00b, and the documentation hasn't been much help to me. I see several places where it says there are various exclude/excludes elements/attributes, but every variation I can think of either has no effect or results in an error like "blah doesn't support the 'exclude' attribute".

推荐答案

一,两个人使用建议&LT;&排除GT; 。这并没有与指定我的任务的方式工作。 trashgod的答案链接到上给了我怎么一个想法,这个页面第六例调整自己的工作规范。

A couple of people suggested using <exclude>. This didn't work with the way my task was specified. trashgod's answer linked to the sixth example on this page which gave me an idea of how to restructure my task specification.

它看起来像我的问题是有关我被指定源文件的方式。而不是使用&LT; pathelement&GT; 中的元素一个&LT; SRC&GT; ,就像这样:

It looks like my problem was related to the way I was specifying the source files. Rather than using <pathelement> elements in a <src>, like this:

<src>
   <pathelement location="${src.dir}/com/foo/bar/baz/" />
   <pathelement location="${src.dir}/com/foo/bar/quux/" />
</src>

我切换到使用单个&LT; SRC&GT; 与路径,然后是一组&LT;包括&GT; 元素,例如:

I switched to using a single <src> with a path and then a set of <include> elements, like this:

<src path="${src.dir}" />
<include name="com/foo/bar/baz/**" />
<include name="com/foo/bar/quux/**" />

这似乎是功能相同,但与使用&LT兼容排除&GT;

This appears to be functionally identical, but is compatible with the use of <exclude>:

<exclude name="${src.dir}/com/foo/bar/quux/dontwant/**"/>

(事实上,我很惊讶,什么摆在首位在那里所有的工作。)

(Actually, I'm surprised that what was there in the first place worked at all.)

这篇关于我怎样才能排除在一个蚂蚁javac任务来源是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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