Over a million developers have joined DZone.

Extending the Downloadable NetBeans Platform for ANT Builds Feature

DZone's Guide to

Extending the Downloadable NetBeans Platform for ANT Builds Feature

· Java Zone ·
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

I saw the great article by Toni Epple and got really interested in the Downloadable NetBeans Platform for ANT builds feature. I already wondered what the platform.download task was since NetCat 7.1. So I had some questions: How will this work with custom platforms? For example my project works with the NB platform and some additional projects? Anyway, I wrote a couple of issues around that:


Please vote on them if interested.

Sadly issue 207738 is already rejected. So I had to work around it on my own.

If you read the issue, it basically asks for this feature to be more flexible by allowing configuration to download other plugins as well. (Right now you can use one update catalog).

So I ended up with this approach: Following Toni's article I added the following properties to my suite's platform.properties file:




And then follow up with the alternate urls to get updates from.



Basically the following modified platform.xml file will try to download the plug-ins from all those urls so you just need to add one that covers all the added plugins.

<?xml version="1.0" encoding="UTF-8"?>
<project name="platform" default="download" basedir="..">
    <import file="../preparation.xml"/>
    <condition property="download.enabled">
            <isset property="bootstrap.url"/>
            <isset property="autoupdate.catalog.url"/>
    <condition property="download.harness.required">
                <available file="${harness.dir}/suite.xml"/>
            <isset property="download.enabled"/>
    <target name="download-harness" if="download.harness.required">
        <mkdir dir="${harness.dir}"/>
        <autoupdate installdir="${nbplatform.active.dir}" updatecenter="${autoupdate.catalog.url}">
            <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
    <target name="download" depends="init-netbeans, init-hudson" if="download.enabled">
        <pathconvert pathsep="|" property="download.clusters">
            <mapper type="flatten"/>
            <path path="${cluster.path}"/>
        <property name="disabled.modules" value=""/>
        <pathconvert property="module.includes" pathsep="">
            <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
                <filelist files="${disabled.modules}" dir="."/>
        <property file="nbproject/platform.properties" prefix="urls."/>
        <propertyselector property="urls" match="urls.autoupdate.catalog\.(.*)" select="\1"/>

        <property file="nbproject/platform.properties"/>
        <echo message="Downloading clusters ${download.clusters}"/>
        <property name="tasks.jar" location="${java.io.tmpdir}/tasks.jar"/>
        <get src="${bootstrap.url}" dest="${tasks.jar}" usetimestamp="true" verbose="true"/>
        <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${tasks.jar}"/>
        <antcall target="download-harness"/>
        <for list="${urls}" param="url">
                <echo message="Attempting to download plug-ins from ${autoupdate.catalog.@{url}}" />
                <download-platform url="${autoupdate.catalog.@{url}}"/>
        <mkdir dir="${nbplatform.active.dir}/extra"/>
        <autoupdate todir="${nbplatform.active.dir}/extra">
            <nbms dir="../netbeans">
                <include name="*.nbm"/>
            <modules includes=".+"/>
    <macrodef name="download-platform">
        <attribute name="url"/>
            <autoupdate installdir="${nbplatform.active.dir}" updatecenter="@{url}">
                <modules includes="${module.includes}.*" clusters="${download.clusters}"/>
                <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>

Note: this script uses the ant-contrib library, so make sure to have it defined. Also I would suggest having the NetBeans url last so it gets all other dependencies.

Hope you find it useful!

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}