#! /usr/bin/python
#
# Build the entire ISAAC Project
#
#
#

import subprocess
import os
import sys

projects = ['va-ochre',
			'va-isaac-metadata',
			'va-isaac-mojo',
			'va-newtons-cradle',
			'va-logic',
			'va-query-service',
			'va-isaac-gui',
			'va-solor-goods',
			'va-expression-service',
			'va-isaac-gui-pa']


args = ['-e', 'clean']

def mvn(*args):
	print("Running " )
	print(args)
	print(" in " + os.getcwd())
	mvnLocation = "C:\\Program Files\\Maven\\bin\\mvn.bat"
	return print("Output: " + subprocess.check_call([mvnLocation] + list(args)))

for project in projects:
        if os.path.isdir(os.getcwd() + project)== False:
                cwd = os.getcwd()
                print("In: " + cwd + " Entering project " + project)
                print("Enviorment: " + os.environ['JAVA_HOME'])
                os.chdir(project)       
                        
                if project == 'va-expression-service' or project == 'va-isaac-gui-pa':
                        args.extend(['package'])
                else:
                        args.extend(['install'])

                if(len(sys.argv) > 1):
                        if(str(sys.argv[1]) == 'skipTest'):
                                args.extend(['-DskipTests'])
                print ("Build Argument")
                print (args)

                #This fails the build, if it results in a non-0 exit status
                mvn(args)
                
                os.chdir(os.pardir)
        else:
                 print(project + " folder does not exists in " + os.getcwd())

#! /usr/bin/python
#
# Build the entire ISAAC Project
#
#
#

import subprocess
import os
import sys

projects = ['va-isaac-parent',
			'va-ochre',
			'va-isaac-metadata',
			'va-isaac-mojo',
			'va-newtons-cradle',
			'va-logic',
			'va-query-service',
			'va-isaac-gui',
			'va-solor-goods',
			'va-expression-service',
			'va-isaac-gui-pa']


defaultArgs = ['-e', 'clean']

def mvn(args):
	return subprocess.check_call(['mvn'] + args)

for project in projects:
	cwd = os.getcwd()
	print("In: " + cwd + " Entering project " + project)
	os.chdir(project)

	args = defaultArgs[:]
	if project == 'va-expression-service' or project == 'va-isaac-gui-pa':
		args.extend(['package'])
	else:
		args.extend(['install'])

	print ("Build Argument")
	print (args)

	#This fails the build, if it results in a non-0 exit status
	mvn(args)
	
	os.chdir(os.pardir)
Revert "Fixed a windows bug that prevented run locating the Maven batch file to run mvn commands. This will need to be modified to run on Linux"
Revert "Fixed a windows bug that prevented run locating the Maven batch file to run mvn commands. This will need to be modified to run on Linux"

This reverts commit b9dfad50415d6f7d90d66da30a1a55cbe62a07ef.
