dev@glassfish.java.net

checkout/build gf

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Thu, 19 Aug 2010 09:38:56 -0400

This has come up every now and then, but with the MS4 deadline people may want to check out a fresh workspace and I thought I'd share this. This is the script I use to checkout and build GF, though you can give another subversion repository as a command line argument to co/build something else.

It works on any platform (*), and it compensates for svn issues by doing a checkout, then update over and over until it succeeds. Since I can't attach .py files, you'll have to copy/paste. Then just run 'python gf.py'. Then go get some coffee or something.

(*) If you're running Windows, you may have to download Python. Or just add the Python plugin to your NetBeans installation and you'll get Jython automagically.

Cheers,
Bobby

--- begin gf.py ---

import os
import sys
import time

print "First let's make sure everything is on your path:"
os.system('svn --version')
os.system('mvn --version')
print 'Ok, here we go...'

# by default, do GFv3
wsloc = 'https://svn.dev.java.net/svn/glassfish-svn/trunk/v3'
if len(sys.argv) == 2:
  wsloc = sys.argv[1]
if wsloc.endswith('/'):
  wsloc = wsloc[0:-1]

coworked = False
updatecount = 0
updateendtimes = {}

def timestamp():
  'Returns GMT'
  return time.asctime(time.gmtime())

# try to check out
svncocommand = 'svn co ' + wsloc
print 'running:', svncocommand
costarttime = timestamp()
res = os.system(svncocommand)
if res == 0:
  coworked = True
costoptime = timestamp()

# now update and update and update
targetdir = wsloc.split('/')[-1]
if not os.path.exists(targetdir):
  exit("Checkout really failed. Can't find: " + targetdir)
print 'Changing to directory', targetdir
os.chdir(targetdir)
svnupcommand = 'svn up'
print 'running:', svnupcommand
while True:
  updatecount = updatecount + 1
  res = os.system(svnupcommand)
  updateendtimes[updatecount] = timestamp()
  if res == 0:
    break

# now build. comment out the 'phase1' stuff for other workspaces
buildstarttime = timestamp()
mvncommand = 'mvn -Prelease-phase1 install'
print 'runnint:', mvncommand
os.system(mvncommand)
mvncommand = 'mvn install'
print 'runnint:', mvncommand
os.system(mvncommand)
buildendtime = timestamp()

# print results
print '\n\nAll times are GMT. At least one update is always run.'
print 'Checkout started:', costarttime
print 'Checkout ended:', costoptime
print 'Checkout worked:', coworked
print 'Number of updates run:', updatecount
for key in updateendtimes.keys():
  print 'Update', key, 'ended:', updateendtimes[key]
print 'Started building:', buildstarttime
print 'Ended building:', buildendtime

--- end ---