我刚刚使用我的 NetBeans 7.0 项目完成了这个练习。我能够做的是从我的 Windows 系统上的 .netbeans\7.0 目录中复制我的 build.properties 文件,并为我的构建服务器创建一个 server.properties 文件。这并不难,因为每个开发人员的 build.properties 可能会有所不同,因此需要为服务器提供另一个文件。然后,我整理了一个简单的 server-build.xml 文件,该文件引用了该文件,并且只执行了 init、compile、dist 和 clean 的基本操作。我将这两个文件提交到我的项目目录顶层的 CVS 存储库,因为它们不与其他项目文件冲突,并且在需要更新的情况下用作提醒。现在我可以使用“ant -f server-build.xml”在我的 CI 服务器上构建我的项目,一切正常。
我的整个初始化部分看起来像这样,优先考虑我的服务器路径,但包括来自 NetBeans 项目属性的必要信息。
<target name="init">
<property file="server.properties"/>
<property file="nbproject/project.properties"/>
</target>
在为我的嵌套项目定义 ant 任务时,我还必须做类似的事情:
<target name="compile">
<ant antfile="${project.MyProj-common}/build.xml" inheritall="false" target="jar">
<property location="${build.dir}" name="dist.ear.dir"/>
<property file="server.properties"/>
<property file="${project.MyProj-common}/nbproject/project.properties"/>
</ant>
...
</target>
我必须将 j2ee.platform.classpath 从 project.properties 复制到我的 server.properties 文件,以确保根据需要解析对 j2ee.server.home 的引用。我没想到必须这样做,但否则类路径是错误的,导致构建失败。
感谢您提供有关此问题的信息,因为它帮助指导我找到此解决方案。