【发布时间】:2025-12-19 08:10:17
【问题描述】:
我的情况有点有趣。我正在尝试使用 Ant 制作一个 jar 文件。但是,我不希望编译每个 java 文件。我的源代码有这样的结构:
src
-Contact.Java
-Contact.hbm.xml
-AnotherClass.Java
所以,我想在我的 jar 文件中包含以下内容:
myjar.jar
-com
--me
---Contact.Class
---Contact.hbm.xml
我不希望 AnotherClass.Class 在那里。
Ant 可以做到这一点吗?
我想出的最好的是这样的:
<target name="condition-hibernate" description="check if there is a java and hbm file then call for compile-hibernate">
<condition property="condition">
<available file="**/*.hbm.xml" />
</condition>
<antcall target="condition-hibernate-part2"/>
</target>
<target name="condition-hibernate-part2" description="check if there is a java and hbm file then call for compile-hibernate">
<javac srcdir="${source.dir}" destdir="${hibernate.dir}">
</target>
我不认为我可以使用 Ant 来解决我的问题,因为我不能告诉 Ant 编译什么和不编译什么(我可以使用排除和包含)但我想告诉 Ant 只编译具有*.hbm.xml 文件。
【问题讨论】:
-
也许你应该稍微改一下你的问题。假设您只需要具有相应 .hbm.xml 文件的 Java 类。
标签: ant compilation target javac conditional-statements