Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

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:

 

harness.dir=${nbplatform.active.dir}/harness

nbplatform.active.dir=${suite.dir}/netbeans701
bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/netbeans/harness/tasks.jar
autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/catalog.xml.gz

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

 

autoupdate.catalog.url1=url1
autoupdate.catalog.url2=url2
.
.
.
autoupdate.catalog.urln=urln

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">
        <and>
            <isset property="bootstrap.url"/>
            <isset property="autoupdate.catalog.url"/>
        </and>
    </condition>
    
    <condition property="download.harness.required">
        <and>
            <not>
                <available file="${harness.dir}/suite.xml"/>
            </not>
            <isset property="download.enabled"/>
        </and>
    </condition>
    
    <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"/>
        </autoupdate>
    </target>
    
    <target name="download" depends="init-netbeans, init-hudson" if="download.enabled">
        <pathconvert pathsep="|" property="download.clusters">
            <mapper type="flatten"/>
            <path path="${cluster.path}"/>
        </pathconvert>
        <property name="disabled.modules" value=""/>
        <pathconvert property="module.includes" pathsep="">
            <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
            <path>
                <filelist files="${disabled.modules}" dir="."/>
            </path>
        </pathconvert>
        <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">
            <sequential>
                <echo message="Attempting to download plug-ins from ${autoupdate.catalog.@{url}}" />
                <download-platform url="${autoupdate.catalog.@{url}}"/>
            </sequential>
        </for>
        <mkdir dir="${nbplatform.active.dir}/extra"/>
        <autoupdate todir="${nbplatform.active.dir}/extra">
            <nbms dir="../netbeans">
                <include name="*.nbm"/>
            </nbms>
            <modules includes=".+"/>
        </autoupdate>
    </target>
    
    <macrodef name="download-platform">
        <attribute name="url"/>
        <sequential>
            <autoupdate installdir="${nbplatform.active.dir}" updatecenter="@{url}">
                <modules includes="${module.includes}.*" clusters="${download.clusters}"/>
                <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
            </autoupdate>
        </sequential>
    </macrodef>
</project>

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!

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}