How can I have my application compiled in a specific version of the platform ?

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

Now the platform can be downloaded on demand! Just update your platform.properties files as follows:

# NOTE: You must remove the nbplatform.default line which might already exist in this file.
# Also note that editing the properties of your suite via the suite customizer (dialog)
# can add that line back in, so you'll need to watch for this and delete it again in this case.
nbplatform.active=custom
nbplatform=7.2

# Where the suite is located; you don't need to change this.  It exists
# to allow us to use relative paths for the other values
suite.dir=${basedir}

# Classpath-like list of absolute or relative paths to individual clusters
# against which you want your suite to build; Note that you can use
# "bare", i.e. not numbered cluster names, which simplifies later transitions
# to newer version of the platform. E.g: ${nbplatform.active.dir}/nb
cluster.path=\
    ${nbplatform.active.dir}/extra:\
    ${nbplatform.active.dir}/ide:\
    ${nbplatform.active.dir}/nb:\
    ${nbplatform.active.dir}/platform:\
    ${nbplatform.active.dir}/sappy
# Path to the build harness you want to use. This is typically in the
# harness subdirectory of your platform, but you could point to a directory
# containing customized build scripts if you want to.
harness.dir=${nbplatform.custom.netbeans.dest.dir}/harness

nbplatform.custom.netbeans.dest.dir=${suite.dir}/netbeans_platform_${nbplatform}
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/${nbplatform}/uc/final/distribution/catalog.xml.gz

All the magic is done by the new platform.xml file that has been recently added. In cases where you need to get updates from other URL’s I made the following changes to the platform.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project name="platform" default="download" basedir="..">
    <import file="../preparation.xml"/>

    <fileset dir="${nbplatform.custom.netbeans.dest.dir}" id="platform.path"/>
    <mkdir dir="${nbplatform.custom.netbeans.dest.dir}"/>
    <pathconvert refid="platform.path"
                 property="platform.notempty"
                 setonempty="false"/>

    <condition property="download.enabled">
        <and>
            <isset property="bootstrap.url"/>
            <isset property="autoupdate.catalog.url"/>
            <not>
                <isset property="platform.notempty"/>
            </not>
        </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>
        <echo>Installing plug-ins from ../netbeans</echo>
        <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>

Here’s the imported preparation.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="MSM-Preparation" basedir=".">
    <description>Prepares the environment to build the module suite MSM.</description>
    <!--Don't modify this file unless you know what you are doing-->
    <property name="ant-contrib-filename" value="ant-contrib-1.0b3.jar"/>
    <property file="nbproject/project.properties"/>
    <property file="nbproject/platform.properties"/>
    <property name="platform.dir" value="../netbeans/"/>
    <property name="lib.dir" value="${suite.dir}/../Simple Libs/tools"/>

    <scriptdef name="substring" language="javascript">
        <attribute name="text" />
        <attribute name="start" />
        <attribute name="end" />
        <attribute name="property" />
     <![CDATA[
       var text = attributes.get("text");
       var start = attributes.get("start");
       var end = attributes.get("end") || text.length;
       project.setProperty(attributes.get("property"), text.substring(start, end));
     ]]>
    </scriptdef>

    <target name="-check-env" depends="-getAntContribJar">
        <condition property="isNetbeans">
            <not>
                <isset property="Hudson"/>
            </not>
        </condition>
        <property name="xmltasks-loc" value="${lib.dir}/xmltask.jar"/>
        <available file="${xmltasks-loc}" property="xmltasks.present"/>
        <fail unless="xmltasks.present" message="The xmltasks jar doesn't exist at: ${xmltasks-loc}, can't build. Check your settings!" />
        <taskdef name="xmltask"
                 classname="com.oopsconsultancy.xmltask.ant.XmlTask">
            <classpath>
                <pathelement location="${xmltasks-loc}"/>
            </classpath>
        </taskdef>
    </target>

    <target name="-getAntContribJar">
        <fileset id="ant-contrib-jar" dir="${lib.dir}">
            <include name="ant-contrib-*.jar" />
        </fileset>
        <pathconvert property="ant-contrib-jar" refid="ant-contrib-jar" pathsep="," />
        <basename property="ant-contrib-filename" file="${ant-contrib-jar}"/>
    </target>

    <target name="-init-netbeans" depends="-check-env" if="isNetbeans">
        <echo>Configuring ant-contrib for Netbeans use...</echo>
        <property name="ant-contrib-loc" value="${lib.dir}/${ant-contrib-filename}"/>
        <available file="${ant-contrib-loc}" property="ant-contrib.present"/>
        <fail unless="ant-contrib.present" message="The ant-contrib jar doesn't exist at: ${ant-contrib-loc}, can't build. Check your settings!" />
        <!--We are in not Hudson-->
        <taskdef resource="net/sf/antcontrib/antcontrib.properties">
            <classpath>
                <pathelement location="${ant-contrib-loc}"/>
            </classpath>
        </taskdef>
    </target>

    <target name="-init-hudson" depends="-check-env" unless="isNetbeans">
        <echo>Configuring ant-contrib for Hudson use...</echo>
        <!--Import Hudson environment variables-->
        <property environment="env"/>
        <property name="ant-contrib-loc" value="${env.ANT_HOME}/lib/${ant-contrib-filename}"/>
        <available file="${ant-contrib-loc}" property="ant-contrib.present"/>
        <fail unless="ant-contrib.present" message="The ant-contrib jar doesn't exist at: ${ant-contrib-loc}, can't build. Check your settings!" />
        <!--Define it. For some reason the approach in -init-netbeans doesn't work in Hudson.-->
        <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask">
            <classpath>
                <pathelement location="${ant-contrib-loc}"/>
            </classpath>
        </taskdef>
        <taskdef name="propertyregex" classname="net.sf.antcontrib.property.RegexTask">
            <classpath>
                <pathelement location="${ant-contrib-loc}"/>
            </classpath>
        </taskdef>
        <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask">
            <classpath>
                <pathelement location="${ant-contrib-loc}"/>
            </classpath>
        </taskdef>
        <taskdef name="math" classname="net.sf.antcontrib.math.MathTask">
            <classpath>
                <pathelement location="${ant-contrib-loc}"/>
            </classpath>
        </taskdef>
        <taskdef name="var" classname="net.sf.antcontrib.property.Variable">
            <classpath>
                <pathelement location="${ant-contrib-loc}"/>
            </classpath>
        </taskdef>
        <taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach">
            <classpath>
                <pathelement location="${ant-contrib-loc}"/>
            </classpath>
        </taskdef>
    </target>

    <target name="module-fix-dependencies">
        <ant antfile= "${suite.dir}/versions.xml" target="fix"/>
    </target>

    <!-- iterate finds all build files, excluding this one and invokes the named target -->
    <macrodef name="iterate">
        <attribute name="target"/>
        <sequential>
            <subant target="@{target}">
                <fileset dir="."
                         includes="**/*/build.xml"
                         excludes="build.xml"/>
            </subant>
        </sequential>
    </macrodef>
</project>

After this you can add alternate update centers and it’ll look for nbms on those sites as well. Just add the additional URLS in the platform.properties as follows:

autoupdate.catalog.url1=url1
autoupdate.catalog.url2=url2
.
.
.
autoupdate.catalog.urlx=urlx