Skip to content

Instantly share code, notes, and snippets.

@nigjo
Last active June 9, 2018 11:51
Show Gist options
  • Save nigjo/c7b0c6c5a2895d7b0bcc27cbf1587897 to your computer and use it in GitHub Desktop.
Save nigjo/c7b0c6c5a2895d7b0bcc27cbf1587897 to your computer and use it in GitHub Desktop.
A brainstorming to introduce Ant extension-points to the NetBeans platform build system

The aim is to introduce <extension-point/> elements to the NetBeans Ant build scripts. Extension points are introduced to Apache Ant in version 1.8. This is the minimum version to perform the build of the NetBeans Platform itself.

Analyze build

The build of a NetBeans Platform Module and a NetBeans Platform based module with Ant is a little bit different. The Platform itself uses the nbbuild-folder, the RCP Modules are using the harness folder. There is one script file, common.xml, which both have in common. The other files are in nbbuild or in apisupport.harness/release. Both build should work after the introduction of entry points.

Entry points do behave like normal targets to some extend. They have to be empty and thus can not contain any task itself. But their depends-list is auto-extended by implemented extensionOf-targets. Every target extending the extention point is appended to the depends-list of the extension point. The order is not defined and must be determinated by the dependency list of the extending target.

It is possible to override an <extension-point/> with a normal <target/>, but I did not test what this means to the extensions.

Current Target Call List

I am focusing to build a RCP Module. To build a platform module the systematic should be the same or similar.

The "heaviest" ("single") target for a module is "nbm". This will call compile, jar and release and some other related targets before creating the modules installation package. The full call is this:

taskdefs
-build-dir-init
-convert-old-project
common-init
-jdk-pre-preinit
-jdk-preinit
-jdk-warn
-jdk-presetdef-basic
-jdk-default
-jdk-init
projectized-common.basic-init
basic-init
-release.dir
-release.files
files-init
nbm-license-init
build-init
-javac-init-nbjdk
-javac-init-bootclasspath-prepend
-javac-init-no-bootclasspath-prepend
-javac-init
init
up-to-date
compile
jar-prep
jar
netbeans-extra
javahelp
module-auto-deps
release
-init-startlevel
module-xml-regular
module-xml-autoload
module-xml-eager
-init-executables
chmod-executables
verify-class-linkage
-validate-layers
-verify-apichanges
-netbeans
netbeans
-nbm-prompt-for-storepass
nbm

In a (strict) reduced form this could be:

init
compile
jar
release
nbm

Possible extension points

If we add one "pre-" and a "post-" extension point to every target of the reduced list we are getting 10 extra elements in the ant build scripts.

<extension-point name="-pre-init"/>
<extension-point name="-post-init" depends="-pre-init,init"/>
<target name="init" depends="-pre-init"/>

To achieve the "post"-target to be executed correctly we need one extra "do-"-item:

<extension-point name="-pre-init"/>
<extension-point name="-post-init" depends="-pre-init,-do-init"/>
<target name="init" depends="-pre-init,-do-init,-post-init"/>
<target name="-do-init" depends="-pre-init">
  <!-- add tasks here -->
</target>

In the end there are 15 new Items. The "do"-Item is the complete replacement of the old target with an extra dependency on the "-pre"-Item. The "-pre"-Item will inherit all dependencies of the old target. The other to items are more or less "copy&paste" for all old target entries.

May be we should add some extension points to some of the other "init"-targets as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment