java - build.xml 和 build-impl.xml 的区别

标签 java netbeans ant build.xml build-impl.xml

我正在研究用 Java 编写的已构建且运行良好的 Web 应用程序的代码。在那个项目中,我找到了两个文件,build.xml 和build-impl.xml,里面包含了项目可以采取的操作相关的不同信息。我无法理解

1) 为什么需要两个不同的文件 build.xml 和 build-impl.xml?

2) 以上两个文件中哪个是强制性的?

3) 谁使用这些文件,何时以及如何使用?

4) 它们包含哪些确切信息?

5) 它们是自动生成的还是必须手动创建?

最佳答案

  1. why two different files, build.xml and build-impl.xml are required ?

By default, Apache Ant(a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other.) uses build.xml as the name for a buildfile.

我们需要构建我们的应用程序的原因是,假设我们有几个类,如果有人想下载它们,那么不应该单独下载它们。因此,我们应该将我们的应用程序打包到一个 jar 文件中(一个可启动的 jar 文件可以满足此目的)。一旦您对您的应用程序正常工作感到满意,您就可以准备应用程序在您的系统/IDE/环境之外部署

然而,来自 Setting Up a NetBeans Platform Application :-

The build-impl.xml file gives you access to the NetBeans Platform infrastructure, such as its "run" target. You will never need to change the build-impl.xml file. On the other hand, the build.xml file is the Ant script where you will customize, where necessary, your application's build process.


  1. which of above two files are mandatory ?

它们都不是强制性的。如果您有多个类文件(或资源),那么您应该构建您的应用程序。此外,如果您想在您的环境之外部署您的应用程序,则可以使用构建 jar 文件。后者默认存在于任何 NetBeans Java 应用程序中。

  1. who uses those files and when and how ?

上面已经回答了。不要深入何时,它只是用于构建您的应用程序。当您使用 Ant(命令行)手动构建您的应用程序时,您会知道什么时候!

  1. what exact information does they contain ?

我在上面提供了关于 Ant 和构建的 NetBeans 教程的链接。去参观那个。这涵盖了 build.xml 和 build-impl.xml 中包含的信息。

  1. are they auto-generated or they have to be created manually ?

不,默认情况下您同时拥有 build.xmlbuild-impl.xml(使用 NetBeans 应用程序时自动生成)。而且,您永远不需要更改 build-impl.xml.

关于java - build.xml 和 build-impl.xml 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33772118/

相关文章:

android - 如何使用ant与android一起构建

ant - 如何从 Ant 构建创建的 .zip 解析 7-zip 的 'Warnings: Headers Error'?

java - 如何使用Smack API语音/视频聊天

java - Spring中JTA数据源java配置

java - 如何使用 OpenGL 扩展中的常量

java - String 方法 isEmpty 在 Android API Levels < 10 中真的不可用吗?

git - 使用 Netbeans 和 Git 的 SSH 问题

java - 如何以编程方式忽略多个失败的junit测试?

java - 日期总是得到不同的 getTime()

netbeans - 为什么我的托管 Bean 中不能有静态公共(public)字段?