Thorn
Thorn

Reputation: 4057

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. I believe most of the delay is caused by the build script deleting and re-creating the entire /lib directory. This includes over 20 MB of jar files that remain unchanged for my project.

How to I modify the ANT build task so that this lib folder does not get re-created every time I build the project? 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. 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.

Is there a way to run the project from the .class files in the build directory instead of needing to run from /dist ?

Here are the netbeans generated build files:

Upvotes: 3

Views: 1526

Answers (2)

jewelsea
jewelsea

Reputation: 159536

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. For packaging production applications you will want to use different settings.

How to get a quick build for JavaFX under NetBeans

  1. Invest in a solid state drive.
  2. Follow thekbb's suggestion of having the library files local to your machine.
  3. Use NetBeans 7.4 + Java 8 and create a standard Java project rather than a JavaFX project.
  4. Under Project Properties | Libraries uncheck:
    • Build projects on Classpath
  5. Under Project Properties | Build | Packaging uncheck:
    • Compress JAR file
    • Build JAR after Compiling
    • 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.
  7. Under Project Properties | Application | Web Start uncheck:
    • Enable 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).

My Build Experiences with NetBeans

A standard NetBeans JavaFX project builds and runs JavaFX projects very quickly for me (no more than a second or two). 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. 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).

If a project is signed, the signing process takes a few seconds per library jar.

Upvotes: 2

thekbb
thekbb

Reputation: 7924

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/

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. This would allow you to shed those binaries from source control.

What reasons prevent you from building locally?

Upvotes: 5

Related Questions