Friday, July 18, 2008

Building netbeans with python

I was playing around with trying to automate the process of checking out and building my development netbeans. First I thought i would write a shell script. Thats when it hit me, Can I preform the whole process using python.
Prerequisites:
Steps:
  • Open the script
  • change the antpath variable to where you have ant installed
  • run the script
Script:
download script
#! /usr/bin/python

import os
# set ant path here
antpath = "/home/alley/app/ant1.7.0"

hgpull = "hg pull -u"
hgclone = "hg clone http://hg.netbeans.org/main"
if(os.path.isdir("netbeans"):
os.rmdir("netbeans")
if(os.path.isdir("main")):
os.chdir("main")
os.system(hgpull)
else:
os.system(hgclone)
os.chdir("main")

os.putenv("ANT_OPTS", "-Xmx196m")
f = open("nbbuild/user.build.properties", "w")
f.write("build.compiler=extJavac\n")
f.write("javac.compilerargs=-J-Xmx512m")
f.close()
os.system(antpath + "/bin/ant -f nbbuild/build.xml")

os.system("cp -R nbbuild/netbeans " + os.getcdw())

os.system(antpath + "/bin/ant -f nbbuild/build.xml clean")

No comments: