@@ -31,7 +31,15 @@ props.startTime = startTime.format("yyyyMMdd.HHmmss.SSS")
3131println (" \n ** Build start at $props . startTime " )
3232
3333// initialize build
34- initializeBuildProcess(args)
34+ try {
35+ initializeBuildProcess(args)
36+ } catch ( AssertionError e ) {
37+ String errorMsg = e. getMessage()
38+ println (errorMsg)
39+ props. error = " true"
40+ buildUtils. updateBuildResult(errorMsg :errorMsg)
41+ finalizeBuildProcess(start :startTime, 0 )
42+ }
3543
3644// create build list
3745List<String > buildList = new ArrayList ()
@@ -57,13 +65,21 @@ else {
5765 scriptPath = script
5866 // Use the ScriptMappings class to get the files mapped to the build script
5967 def buildFiles = ScriptMappings . getMappedList(script, buildList)
60- if (buildFiles. size() > 0 ) {
61- if (scriptPath. startsWith(' /' ))
62- runScript(new File (" ${ scriptPath} " ), [' buildList' :buildFiles])
63- else
64- runScript(new File (" languages/${ scriptPath} " ), [' buildList' :buildFiles])
68+ try {
69+ if (buildFiles. size() > 0 ) {
70+ if (scriptPath. startsWith(' /' ))
71+ runScript(new File (" ${ scriptPath} " ), [' buildList' :buildFiles])
72+ else
73+ runScript(new File (" languages/${ scriptPath} " ), [' buildList' :buildFiles])
74+ }
75+ processCounter = processCounter + buildFiles. size()
76+ } catch (BuildException | AssertionError e ) {
77+ String errorMsg = e. getMessage()
78+ println (errorMsg)
79+ props. error = " true"
80+ buildUtils. updateBuildResult(errorMsg :errorMsg)
81+ finalizeBuildProcess(start :startTime, count :processCounter)
6582 }
66- processCounter = processCounter + buildFiles. size()
6783 }
6884 } else if (props. scanLoadmodules && props. scanLoadmodules. toBoolean()){
6985 println (" ** Scanning load modules." )
@@ -77,10 +93,6 @@ if (processCounter == 0)
7793
7894finalizeBuildProcess(start :startTime, count :processCounter)
7995
80- // if error occurred signal process error
81- if (props. error)
82- System . exit(1 )
83-
8496// end script
8597
8698
@@ -96,10 +108,17 @@ def initializeBuildProcess(String[] args) {
96108
97109 // print and store property dbb toolkit version in use
98110 def dbbToolkitVersion = VersionInfo . getInstance(). getVersion()
99- props. dbbToolkitVersion = dbbToolkitVersion
100111 def dbbToolkitBuildDate = VersionInfo . getInstance(). getDate()
101- if (props. verbose) println " ** zAppBuild running on DBB Toolkit Version ${ dbbToolkitVersion} ${ dbbToolkitBuildDate} "
112+ props. dbbToolkitVersion = dbbToolkitVersion
113+ props. dbbToolkitBuildDate = dbbToolkitBuildDate
102114
115+ File versionFile = new File (" ${ props.zAppBuildDir} /version.properties" )
116+ if (versionFile. exists()) {
117+ props. load(versionFile)
118+ if (props. zappbuild_version) println " ** Running zAppBuild Version ${ props.zappbuild_version} "
119+ }
120+ if (props. verbose) println " ** Running DBB Toolkit Version ${ dbbToolkitVersion} ${ dbbToolkitBuildDate} "
121+
103122 // verify required dbb toolkit
104123 buildUtils. assertDbbBuildToolkitVersion(props. dbbToolkitVersion, props. requiredDBBToolkitVersion)
105124
@@ -329,6 +348,8 @@ def populateBuildProperties(def opts) {
329348 // need to support IDz user build parameters
330349 if (opts. srcDir) props. workspace = opts. srcDir
331350 if (opts. wrkDir) props. outDir = opts. wrkDir
351+
352+ // assert workspace
332353 buildUtils. assertBuildProperties(' workspace,outDir' )
333354
334355 // load build.properties
@@ -641,7 +662,8 @@ def createBuildList() {
641662 }
642663
643664 // Perform analysis and build report of external impacts
644- if (props. reportExternalImpacts && props. reportExternalImpacts. toBoolean()){
665+ // Prereq: Metadatastore Connection
666+ if (metadataStore && props. reportExternalImpacts && props. reportExternalImpacts. toBoolean()){
645667 if (buildSet && changedFiles) {
646668 println " ** Perform analysis and reporting of external impacted files for the build list including changed files."
647669 reportingUtils. reportExternalImpacts(buildSet. plus(changedFiles))
@@ -653,7 +675,8 @@ def createBuildList() {
653675 }
654676
655677 // Document and validate concurrent changes
656- if (props. reportConcurrentChanges && props. reportConcurrentChanges. toBoolean()){
678+ // Prereq: Workspace containing git repos. Skipped for --userBuild build type
679+ if (! props. userBuild && props. reportConcurrentChanges && props. reportConcurrentChanges. toBoolean()){
657680 println " ** Calculate and document concurrent changes."
658681 reportingUtils. calculateConcurrentChanges(buildSet)
659682 }
@@ -670,7 +693,6 @@ def createBuildList() {
670693 return buildList
671694}
672695
673-
674696def finalizeBuildProcess (Map args ) {
675697 println " ***************** Finalization of the build process *****************"
676698
@@ -722,7 +744,10 @@ def finalizeBuildProcess(Map args) {
722744 buildResult. setProperty(" filesProcessed" , String . valueOf(args. count))
723745 buildResult. setState(buildResult. COMPLETE )
724746
725-
747+ // add zAppBuild and DBB toolkit version info
748+ if (props. zappbuild_version) buildResult. setProperty(" zAppBuildVersion" , props. zappbuild_version)
749+ buildResult. setProperty(" DBBToolkitVersion" , " ${ props.dbbToolkitVersion} ${ props.dbbToolkitBuildDate} " )
750+
726751 // store build result properties in BuildReport.json
727752 PropertiesRecord buildReportRecord = new PropertiesRecord (" DBB.BuildResultProperties" )
728753 def buildResultProps = buildResult. getPropertyNames()
@@ -769,6 +794,10 @@ def finalizeBuildProcess(Map args) {
769794 if (props. preview) println (" ** Build ran in preview mode." )
770795 println (" ** Total files processed : ${ args.count} " )
771796 println (" ** Total build time : $duration \n " )
797+
798+ // if error occurred signal process error
799+ if (props. error)
800+ System . exit(1 )
772801}
773802
774803
0 commit comments