我正在研究用 Java 编写的已构建且运行良好的 Web 应用程序的代码。在那个项目中,我找到了两个文件,build.xml 和build-impl.xml,里面包含了项目可以采取的操作相关的不同信息。我无法理解
1) 为什么需要两个不同的文件 build.xml 和 build-impl.xml?
2) 以上两个文件中哪个是强制性的?
3) 谁使用这些文件,何时以及如何使用?
4) 它们包含哪些确切信息?
5) 它们是自动生成的还是必须手动创建?
最佳答案
- 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 thebuild-impl.xml
file. On the other hand, thebuild.xml
file is the Ant script where you will customize, where necessary, your application's build process.
- which of above two files are mandatory ?
它们都不是强制性的。如果您有多个类文件(或资源),那么您应该构建您的应用程序。此外,如果您想在您的环境之外部署您的应用程序,则可以使用构建 jar 文件。后者默认存在于任何 NetBeans Java 应用程序中。
- who uses those files and when and how ?
上面已经回答了。不要深入何时,它只是用于构建您的应用程序。当您使用 Ant(命令行)手动构建您的应用程序时,您会知道什么时候!
- what exact information does they contain ?
我在上面提供了关于 Ant 和构建的 NetBeans 教程的链接。去参观那个。这涵盖了 build.xml 和 build-impl.xml 中包含的信息。
- are they auto-generated or they have to be created manually ?
不,默认情况下您同时拥有 build.xml
和 build-impl.xml
(使用 NetBeans 应用程序时自动生成)。而且,您永远不需要更改 build-impl.xml.
关于java - build.xml 和 build-impl.xml 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33772118/