build.xml 和 build-impl.xml 之间的区别

difference between build.xml and build-impl.xml

我正在研究用 java 编写的已经构建且运行良好的 运行 网络应用程序的代码。在那个项目中,我找到了两个文件,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.

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

之外部署

鉴于 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 ?

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

  1. who uses those files and when and how ?

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

  1. what exact information does they contain ?

我已经提供了 link 关于 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.

好吧,netbeans IDE 使用这两个文件来根据您的项目首选项强制执行特定行为。现在回答你的问题...

1) build.xml 包括对 build-impl.xml 的引用。这用于使用 build-impl.xml 行为覆盖 build.xml。如文件中所述,build.xml 仅由 Clean and Build 命令使用。正如 build.xml (If you delete it and reopen the project it will be recreated.) 中所述。 build.xml 不是那么重要。重要的文件是build-impl.xml.

2) build-impl.xml 是必需的,因为它包含对 JVM、IDE 调试器、编译器、ant 部署工具等的说明...

3) Build.xml 仅供 Clean and Build 使用。如果项目的 Compile on Save 功能关闭,运行、Debug 和 Test 等命令仅使用此构建脚本。 build-impl.xml 由上一点所述的组件使用。

4) 上面回答

5) 两者都是由 IDE 自动生成的。您可以编辑 build.xml 但不能编辑 build-impl.xml(您不必这样做,因为它是由 IDE 自动生成的)。

更新: 这两个文件的范围都严格针对 Netbeans IDE。要在 netbeans 之外部署项目,您只需要获取提取的 jar 或 war(如果是 Web 应用程序)并将它们直接部署到容器中。

据我所知,使用 Netbeans 创建的项目与使用 Eclipse 创建的项目之间没有直接关系。