简体   繁体   English

Netbeans中的JavaFX Ant构建脚本:如何提高构建速度?

[英]JavaFX Ant Build Script in Netbeans: How to improve build speed?

Building a JavaFX project from a directory on a networked drive is surprisingly slow. 从网络驱动器上的目录构建JavaFX项目的速度非常慢。 I believe most of the delay is caused by the build script deleting and re-creating the entire /lib directory. 我相信大部分延迟是由构建脚本删除并重新创建整个/ lib目录引起的。 This includes over 20 MB of jar files that remain unchanged for my project. 这包括超过20 MB的jar文件,对我的项目保持不变。

How to I modify the ANT build task so that this lib folder does not get re-created every time I build the project? 如何修改ANT构建任务,以便每次构建项目时都不会重新创建此lib文件夹? What else can be done to reduce the build time? 还有什么办法可以减少构建时间?

Another reason for the slow build time over my network is that the project always gets run from the /dist folder. 构建网络的时间较慢的另一个原因是项目始终从/ dist文件夹运行。 For a standard Java SE project, a project can run from the build directory, removing the need to create a new jar file in /dist every time the project runs. 对于标准Java SE项目,项目可以从构建目录运行,无需在每次项目运行时在/ dist中创建新的jar文件。

Is there a way to run the project from the .class files in the build directory instead of needing to run from /dist ? 有没有办法从构建目录中的.class文件运行项目而不需要从/ dist运行?

Here are the netbeans generated build files: 以下是netbeans生成的构建文件:

It would be helpful to see more of your build file, it is possible that the target dependency graph of whatever target your running could be changed. 查看更多的构建文件会很有帮助,可能会更改运行目标的目标依赖关系图。 Put another way, make a target that doesn't delete lib/ 换句话说, 制作一个不删除 lib/ 的目标

A much larger and cooler solution would be to use ivy to download these libs one time to ~/.ivy where they'd be cached and wouldn't need to be fetched every time you checked out. 一个更大更酷的解决方案是使用常春藤将这些库一次下载到~/.ivy ,在那里它们被缓存,每次签出时都不需要取出。 This would allow you to shed those binaries from source control. 这将允许您从源代码控制中删除这些二进制文件。

What reasons prevent you from building locally? 什么原因妨碍你在当地建设?

The suggestions below are only suggested for your development work based upon your description of slow build speeds in your environment. 以下建议仅针对您的开发工作建议,具体取决于您对环境中构建速度较慢的描述。 In general, if NetBeans JavaFX project development builds are already quick enough, the settings above should not be used. 通常,如果NetBeans JavaFX项目开发版本已经足够快,则不应使用上面的设置。 For packaging production applications you will want to use different settings. 对于包装生产应用程序,您将需要使用不同的设置。

How to get a quick build for JavaFX under NetBeans 如何在NetBeans下快速构建JavaFX

  1. Invest in a solid state drive. 投资固态硬盘。
  2. Follow thekbb's suggestion of having the library files local to your machine. 按照thekbb的建议,将库文件放在机器本地。
  3. Use NetBeans 7.4 + Java 8 and create a standard Java project rather than a JavaFX project. 使用NetBeans 7.4 + Java 8并创建标准Java项目而不是JavaFX项目。
  4. Under Project Properties | 在项目属性下| Libraries uncheck: 图书馆取消选中:
    • Build projects on Classpath 在Classpath上构建项目
  5. Under Project Properties | 在项目属性下| Build | 建立| Packaging uncheck: 包装取消选中:
    • Compress JAR file 压缩JAR文件
    • Build JAR after Compiling 编译后构建JAR
    • Copy Dependent Libraries 复制从属库
  6. Under Project Properties | 在项目属性下| Build | 建立| Deployment uncheck: 部署取消选中:
    • Enable Native Packaging Options in Project Menu 在项目菜单中启用本机包装选项
    • Keep JavaFX RT Artifacts on Compile Classpath if not present by default. 如果默认情况下不存在,则在编译类路径上保留JavaFX RT工件。
  7. Under Project Properties | 在项目属性下| Application | 应用| Web Start uncheck: Web Start取消选中:
    • Enable Web Start 启用Web Start

If you end up being unable to solve your build performance issues using NetBeans, you might want to try Intellij Idea (I have found it quite efficient at building JavaFX projects). 如果您最终无法使用NetBeans解决构建性能问题,您可能需要尝试Intellij Idea(我发现它在构建JavaFX项目时非常有效)。

My Build Experiences with NetBeans 我使用NetBeans构建体验

A standard NetBeans JavaFX project builds and runs JavaFX projects very quickly for me (no more than a second or two). 标准的NetBeans JavaFX项目可以非常快速地为我构建和运行JavaFX项目(不超过一两秒)。 That is even without applying most of the build speed suggestions above. 即使没有应用上面的大多数构建速度建议也是如此。 Projects which build in seconds reference over 75 libraries totaling more than 55MB of data. 在几秒钟内构建的项目可引用超过75个库,总计超过55MB的数据。 However, that build timing is when using local libraries, not when using libraries stored on a network. 但是,构建时间是在使用本地库时,而不是在使用存储在网络上的库时。 Also the quick builds are using a Macbook Air (which has an SSD). 快速构建也使用Macbook Air(具有SSD)。

If a project is signed, the signing process takes a few seconds per library jar. 如果项目已签名,则每个库jar的签名过程需要几秒钟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM