Apache NetBeans - building and installation

NetBeans is now an Apache Foundation project, but (as of today) we lost the possibility to download a specific release (Java only, PHP, C/C++, ...), the standard version available (release 9+) is only built with Java support. I have created a very simple script that build Apache NetBeans including support for various programming languages (PHP included), getting sources from the latest tree hosted on GitHub. Paste the following script in a file (ie: ~/build-netbeans.sh), make the file executable, change SRCDIR and DESTDIR to absolute directory paths of your choice, launch the script. If everything goes well you have a working installation of Apache NetBeans. Remeber to install, before trying the building process, JDK or OpenJDK.
#!/bin/sh

# where to store Apache Netbeans sources , don't add trailing /
SRCDIR="/usr/src/netbeans"

# where to install Apache Netbeans binaries , don't add trailing /
DESTDIR="/home/user/netbeans"

# set to 1 to preserve last Apache Netbeans binary installation
DOBACKUP=1

ANT=$(which ant)
GIT=$(which git)

if [ "$ANT" = "" ]; then
	echo "ANT not found, install ANT 1.9+"
	exit 1
fi

if [ "$GIT" = "" ]; then
	echo "GIT not found"
	exit 1
fi

if [ ! -e $SRCDIR ]; then
	mkdir -p $SRCDIR 2>/dev/null >/dev/null
	if [ ! -e $SRCDIR ]; then
		echo "Unable to create $SRCDIR"
		exit 1
	fi
fi

cd $SRCDIR

[ ! -e incubator-netbeans ] && $GIT clone https://github.com/apache/incubator-netbeans.git
[ -e buildok ] && rm buildok

cd incubator-netbeans && \
git pull && \
LANG=en $ANT -Dcluster.config=full && \
touch ../buildok

if [ ! -e ../buildok ]; then
	echo "Unable to build Apache Netbeans"
	exit 1
fi

if [ -e $DESTDIR ]; then
	if [ "$DOBACKUP" = "1" ]; then
		BACKUPDIR=${DESTDIR}-$(date +%s)
		mv $DESTDIR $BACKUPDIR
		if [ "$?" != "0" ]; then
			echo "Unable to create backup in $BACKUPDIR"
			exit 1
		fi
	else
		rm -rf $DESTDIR
		if [ "$?" != "0" ]; then
			echo "Uname to remove old installation in $DESTDIR"
			exit 1
		fi
	fi
	mkdir $DESTDIR
	if [ "$?" != "0" ]; then
	    echo "Unable to create $DESTDIR"
	    exit 1
	fi
else
    mkdir $DESTDIR
    if [ "$?" != "0" ]; then
	echo "Unable to create $DESTDIR"
	exit 1
    fi
fi

cd nbbuild/netbeans && \
cp -prf * $DESTDIR/ && \
echo "bin/netbeans" > $DESTDIR/netbeans && \
chmod +x ~/netbeans/netbeans

if [ ! -x $DESTDIR/netbeans ]; then
	echo "Unable to finalize installation in $DESTDIR"
	exit 1
fi

echo "Installation complete"
echo "Now you can launch Netbeans using $DESTDIR/netbeans"
echo ""

exit 0