How to remove useless module dependencies in a NetBeans Platform Application

In my company NetBeans Platform based application we have hundreds of modules, each module has dependencies on other modules and they are stored in a file called project.xml .

As the project grows bigger some dependencies are added and others are removed, and some become obsolete. How to remove the unused ones?
There used to be an ANT target that did this automatically: for each dependency the script removed it, then it tried to build the module, and if the build failed it restored the removed dependency.

In 2016, when we moved to NetBeans 8.1, I discovered that this script was not working as expected anymore, it seemed to do nothing!!! I did not investigate the reason but I was very disappointed by this issue.

These days, I found a way to make the script work again as it used to, and I discovered that the default behavior did only update the dependencies to the NetBeans module versions.

To make the ANT target work you have to edit common.xml inside the netbeans/harness/ folder, find this line

<fixdependencies antfile="../../build.xml" buildtarget="netbeans" cleantarget="clean" failonerror="true" sanitycheck="false" moduleFilter="${fix.dependencies.modules}" strip="false">

And set strip and sanitycheck to true.
To run the ANT target:

  • Expand the module node
  • Expand the Important Files node
  • Right-click on the Build Script Node
  • Select Run Target
  • Click on fix-dependencies
  • The module will be rebuilt multiple times

And voilà!

Background vector created by starline – www.freepik.com

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.