diff --git a/BUILD.md b/BUILD.md index c8f75727..b2e92d28 100644 --- a/BUILD.md +++ b/BUILD.md @@ -55,7 +55,7 @@ $DBB_HOME/bin/groovyz build.groovy --workspace /u/build/repos --application app1 ## Common User Build Invocation Examples **Build one program** -Build a single program in a user build context. Does not require a repository client connection to the DBB WebApp. +Build a single program in a user build context. Does not require use of the MetadataStore (filesystem or Db2) ``` $DBB_HOME/bin/groovyz build.groovy --workspace /u/build/repos --application app1 --outDir /u/build/out --hlq BUILD.APP1 --userBuild app1/cobol/epsmpmt.cbl ``` @@ -136,12 +136,12 @@ build options: -re,--reportExternalImpacts Flag to activate analysis and report of external impacted files within DBB collections -web application credentials - -url,--url DBB repository URL - -id,--id DBB repository id - -pw,--pw DBB repository password - -pf,--pwFile Absolute or relative (from workspace) path to - file containing DBB password +Db2 MetadataStore configuration options + -url,--url Db2 JDBC URL for the MetadataStore. + Example: jdbc:db2: + -id,--id Db2 user id for the MetadataStore + -pw,--pw Db2 password (encrypted with DBB Password Utility) for the MetadataStore + -pf,--pwFile Absolute or relative (from workspace) path to file containing Db2 password IDz/ZOD User Build options -u,--userBuild Flag indicating running a user build @@ -173,7 +173,7 @@ utility options Build a single program in the application. -By leveraging `--userBuild` zAppBuild does not connect to the repositoryClient to the DBB WebApp and also does not store a build result. +By leveraging `--userBuild` zAppBuild does not intialize the MetadataStore and also does not store a build result. ``` groovyz dbb-zappbuild/build.groovy --workspace /var/dbb/dbb-zappbuild/samples --hlq USER.ZAPP.CLEAN.MASTER --workDir /var/dbb/out/MortgageApplication --application MortgageApplication --logEncoding UTF-8 --userBuild --verbose MortgageApplication/cobol/epsnbrvl.cbl diff --git a/build-conf/README.md b/build-conf/README.md index afc04541..96ce5b6b 100644 --- a/build-conf/README.md +++ b/build-conf/README.md @@ -49,10 +49,10 @@ documentDeleteRecords | Option determine if the build framework should document generateDb2BindInfoRecord | Flag to control the generation of a generic DBB build record for a build file to document the configured db2 bind information (application-conf/bind.properties). Default: false ** Can be overridden by a file property. dbb.file.tagging | Controls compile log and build report file tagging. Default: true. dbb.LinkEditScanner.excludeFilter | DBB configuration property used by the link edit scanner to exclude load module entries -dbb.RepositoryClient.url | DBB configuration property for web application URL. ***Can be overridden by build.groovy option -url, --url*** -dbb.RepositoryClient.userId | DBB configuration property for web application logon id. ***Can be overridden by build.groovy option -id, --id*** -dbb.RepositoryClient.password | DBB configuration property for web application logon password. ***Can be overridden by build.groovy option -pw, --pw*** -dbb.RepositoryClient.passwordFile | DBB configuration property for web application logon password file. ***Can be overridden by build.groovy option -pf, --pf*** +metadataStoreType | DBB MetadataStore Type configuration property. Valid options are 'file' or 'db2'. Default: file +metadataStoreFileLocation | DBB File MetadataStore location. Default: $USER +metadataStoreDb2Url | DBB configuration property for Db2 URL. ***Can be overridden by build.groovy option -url, --url*** +metadataStoreDb2ConnectionConf | DBB configuration property for Db2 configuration properties file. ### dependencyReport.properties Properties used by the impact utilities to generate a report of external impacted files diff --git a/build-conf/build.properties b/build-conf/build.properties index e86183e0..b4c19930 100644 --- a/build-conf/build.properties +++ b/build-conf/build.properties @@ -126,29 +126,22 @@ createBuildOutputSubfolder=true # Default : false documentDeleteRecords=false +# MetadataStore configuration properties: -# -# default DBB Repository Web Application authentication properties -# can be overridden by build.groovy script options - -# build.groovy option -url, --url -dbb.RepositoryClient.url= +# select MetadataStore configuration (either 'file' or 'db2') +metadataStoreType=file -# build.groovy option -id, --id -dbb.RepositoryClient.userId=ADMIN +# location of file metadata store. Default is $USER +#metadataStoreFileLocation= -# build.groovy option -pw, --pw -dbb.RepositoryClient.password= +# Db2 metadata server url +# build.groovy option -url, --url +#metadataStoreDb2Url=jdbc:db2: -# build.groovy option -pf, --pf -dbb.RepositoryClient.passwordFile=${zAppBuildDir}/utilities/ADMIN.pw +# Db2 connection configuration property file +# Sample is povided at $DBB_HOME/conf/db2Connection.conf +#metadataStoreDb2ConnectionConf= -# Use dbb.RepositoryClient.sslProtocols to specify one or more SSL protocols used -# to communication between DBB toolkit and server. Use a comma as separator for more -# than one protocol. Requires toolkit PTF UI72423 or version 1.1.0 or higher -# examples -# dbb.RepositoryClient.sslProtocols=TLSv1.2 -# dbb.RepositoryClient.sslProtocols=TLS,TLSv1.2 # The dbb.gateway.type property determines which gateway type is used for the entire build process # Possible values are 'legacy' and 'interactive. Default if not indicated is 'legacy' diff --git a/build.groovy b/build.groovy index d546bace..42ae74fe 100644 --- a/build.groovy +++ b/build.groovy @@ -1,6 +1,6 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* import com.ibm.dbb.dependency.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.build.* import com.ibm.dbb.build.report.* import com.ibm.dbb.build.html.* @@ -20,7 +20,7 @@ import groovy.cli.commons.* @Field String hashPrefix = ':githash:' @Field String giturlPrefix = ':giturl:' @Field String gitchangedfilesPrefix = ':gitchangedfiles:' -@Field RepositoryClient repositoryClient +@Field MetadataStore metadataStore // start time message def startTime = new Date() @@ -64,7 +64,7 @@ else { } } else if(props.scanLoadmodules && props.scanLoadmodules.toBoolean()){ println ("** Scanning load modules.") - impactUtils.scanOnlyStaticDependencies(buildList, repositoryClient) + impactUtils.scanOnlyStaticDependencies(buildList) } } @@ -88,8 +88,8 @@ if (props.error) def initializeBuildProcess(String[] args) { if (props.verbose) println "** Initializing build process . . ." - // build properties initial set - populateBuildProperties(args) + def opts = parseArgs(args) // parse incoming options and arguments + populateBuildProperties(opts) // build properties initial set // print and store property dbb toolkit version in use def dbbToolkitVersion = VersionInfo.getInstance().getVersion() @@ -103,31 +103,79 @@ def initializeBuildProcess(String[] args) { // verify required build properties buildUtils.assertBuildProperties(props.requiredBuildProperties) - // create a repository client for this script - if (props."dbb.RepositoryClient.url" && !props.userBuild) { - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - println "** Repository client created for ${props.getProperty('dbb.RepositoryClient.url')}" + // create metadata store for this script + if (!props.userBuild) { + if (props.metadataStoreType == 'file') + metadataStore = MetadataStoreFactory.createFileMetadataStore(props.metadataStoreLocation) + else if (props.metadataStoreType == 'db2') { + // Get ID + String id + if (opts.id) + id = opts.id + + //Get password file or encrypted password from command line + String password + File passwordFile + if (opts.pf) + passwordFile = new File(opts.pf) + else if (opts.pw) + password = opts.pw + + if (props.metadataStoreDb2ConnectionConf) { // Db2 Configuration properties file + + // Check if the configuration properties file exists + File propertiesFile = new File(props.metadataStoreDb2ConnectionConf) + if (!propertiesFile.exists()) { + println("Db2 Connection Configuration property file does not exist: ${propertiesFile.getAbsolutePath()}\nPlease verify that the provided path is correct") + System.exit(1) + } + // Load properties file into Properties object + Properties db2ConnectionProps = new Properties() + db2ConnectionProps.load(propertiesFile) + + // Call correct Db2 MetadataStore constructor + if (passwordFile) + metadataStore = MetadataStoreFactory.createDb2MetadataStore(id, passwordFile, db2ConnectionProps) + else + metadataStore = MetadataStoreFactory.createDb2MetadataStore(id, password as String, db2ConnectionProps) + } + else { // Not using Db2 Config Properties file + + // Assert URL property is defined + if (!props.metadataStoreDb2Url) { + println("For Db2 MetadataStore, please define the metadataStoreDb2Url build property or pass '-url jdbc:db2:' on the command line." ) + System.exit(1) + } + + /// Call correct Db2 MetadataStore constructor + if (passwordFile) + metadataStore = MetadataStoreFactory.createDb2MetadataStore(props.metadataStoreDb2Url, id, passwordFile) + else + metadataStore = MetadataStoreFactory.createDb2MetadataStore(props.metadataStoreDb2Url, id, password as String) + } + + } + else { + println("Invalid MetadataStore Type: ${props.metadataStoreType}.\nOnly valid options for 'metadataStoreType' are 'file' and 'db2'.") + System.exit(1) + } + + if (props.verbose) println "** ${props.metadataStoreType.capitalize()} MetadataStore initialized" } // handle -r,--reset option if (props.reset && props.reset.toBoolean()) { println("** Reset option selected") - if (props."dbb.RepositoryClient.url") { - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - println("* Deleting collection ${props.applicationCollectionName}") - repositoryClient.deleteCollection(props.applicationCollectionName) - println("* Deleting collection ${props.applicationOutputsCollectionName}") - repositoryClient.deleteCollection(props.applicationOutputsCollectionName) + println("* Deleting collection ${props.applicationCollectionName}") + metadataStore.deleteCollection(props.applicationCollectionName) - println("* Deleting build result group ${props.applicationBuildGroup}") - repositoryClient.deleteBuildResults(props.applicationBuildGroup) - } - else { - println("*! No repository client URL provided. Unable to reset!") - } + println("* Deleting collection ${props.applicationOutputsCollectionName}") + metadataStore.deleteCollection(props.applicationOutputsCollectionName) + println("* Deleting build result group ${props.applicationBuildGroup}") + metadataStore.deleteBuildResults(props.applicationBuildGroup) + System.exit(0) } @@ -138,22 +186,21 @@ def initializeBuildProcess(String[] args) { // initialize build report BuildReportFactory.createDefaultReport() - // initialize build result (requires repository connection) - if (repositoryClient) { - def buildResult = repositoryClient.createBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) + // initialize build result (requires MetadataStore) + if (metadataStore) { + def buildResult = metadataStore.createBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) buildResult.setState(buildResult.PROCESSING) if (props.scanOnly) buildResult.setProperty('scanOnly', 'true') if (props.fullBuild) buildResult.setProperty('fullBuild', 'true') if (props.impactBuild) buildResult.setProperty('impactBuild', 'true') if (props.topicBranchBuild) buildResult.setProperty('topicBranchBuild', 'true') if (props.buildFile) buildResult.setProperty('buildFile', XmlUtil.escapeXml(props.buildFile)) - buildResult.save() - props.buildResultUrl = buildResult.getUrl() - println("** Build result created for BuildGroup:${props.applicationBuildGroup} BuildLabel:${props.applicationBuildLabel} at ${props.buildResultUrl}") + + println("** Build result created for BuildGroup:${props.applicationBuildGroup} BuildLabel:${props.applicationBuildLabel}") } // verify/create/clone the collections for this build - impactUtils.verifyCollections(repositoryClient) + impactUtils.verifyCollections() } /* @@ -181,7 +228,7 @@ options: cli.i(longOpt:'impactBuild', 'Flag indicating to build only programs impacted by changed files since last successful build.') cli.b(longOpt:'baselineRef',args:1,'Comma seperated list of git references to overwrite the baselineHash hash in an impactBuild scenario.') cli.m(longOpt:'mergeBuild', 'Flag indicating to build only changes which will be merged back to the mainBuildBranch.') - cli.r(longOpt:'reset', 'Deletes the dependency collections and build result group from the DBB repository') + cli.r(longOpt:'reset', 'Deletes the dependency collections and build result group from the MetadataStore') cli.v(longOpt:'verbose', 'Flag to turn on script trace') // scan options @@ -191,10 +238,10 @@ options: cli.sa(longOpt:'scanAll', 'Flag indicating to scan both source files and load modules for application without building anything') // web application credentials (overrides properties in build.properties) - cli.url(longOpt:'url', args:1, 'DBB repository URL') - cli.id(longOpt:'id', args:1, 'DBB repository id') - cli.pw(longOpt:'pw', args:1, 'DBB repository password') - cli.pf(longOpt:'pwFile', args:1, 'Absolute or relative (from workspace) path to file containing DBB password') + cli.url(longOpt:'url', args:1, 'Db2 JDBC URL for the MetadataStore. Example: jdbc:db2:') + cli.id(longOpt:'id', args:1, 'Db2 user id for the MetadataStore') + cli.pw(longOpt:'pw', args:1, 'Db2 password (encrypted with DBB Password Utility) for the MetadataStore') + cli.pf(longOpt:'pwFile', args:1, 'Absolute or relative (from workspace) path to file containing Db2 password') // IDz/ZOD User build options cli.u(longOpt:'userBuild', 'Flag indicating running a user build') @@ -249,10 +296,8 @@ options: * populateBuildProperties - loads all build property files, creates properties for command line * arguments and sets calculated propertied for he build process */ -def populateBuildProperties(String[] args) { +def populateBuildProperties(def opts) { - // parse incoming options and arguments - def opts = parseArgs(args) def zAppBuildDir = getScriptDir() props.zAppBuildDir = zAppBuildDir @@ -356,11 +401,6 @@ def populateBuildProperties(String[] args) { props.scanLoadmodules = 'true' } - if (opts.url) props.url = opts.url - if (opts.id) props.id = opts.id - if (opts.pw) props.pw = opts.pw - if (opts.pf) props.pf = opts.pf - // set debug flag if (opts.d) props.debug = 'true' @@ -381,11 +421,9 @@ def populateBuildProperties(String[] args) { // set buildframe options if (opts.re) props.reportExternalImpacts = 'true' - // set DBB configuration properties - if (opts.url) props.'dbb.RepositoryClient.url' = opts.url - if (opts.id) props.'dbb.RepositoryClient.userId' = opts.id - if (opts.pw) props.'dbb.RepositoryClient.password' = opts.pw - if (opts.pf) props.'dbb.RepositoryClient.passwordFile' = opts.pf + // set Db2 URL configuration properties + if (opts.url) props.metadataStoreDb2Url = opts.url + // db2 id, password, and passwordFile are no longer properties // set IDz/ZOD user build options if (opts.e) props.errPrefix = opts.e @@ -461,19 +499,19 @@ def createBuildList() { // check if impact build else if (props.impactBuild) { println "** --impactBuild option selected. $action impacted programs for application ${props.application} " - if (repositoryClient) { - (buildSet, changedFiles, deletedFiles, renamedFiles, changedBuildProperties) = impactUtils.createImpactBuildList(repositoryClient) } + if (metadataStore) { + (buildSet, changedFiles, deletedFiles, renamedFiles, changedBuildProperties) = impactUtils.createImpactBuildList() } else { - println "*! Impact build requires a repository client connection to a DBB web application" + println "*! Impact build requires a Filesystem or Db2 MetadataStore" } } else if (props.mergeBuild){ println "** --mergeBuild option selected. $action changed programs for application ${props.application} flowing back to ${props.mainBuildBranch}" - if (repositoryClient) { + if (metadataStore) { assert (props.topicBranchBuild) : "*! Build type --mergeBuild can only be run on for topic branch builds." - (buildSet, changedFiles, deletedFiles, renamedFiles, changedBuildProperties) = impactUtils.createMergeBuildList(repositoryClient) } + (buildSet, changedFiles, deletedFiles, renamedFiles, changedBuildProperties) = impactUtils.createMergeBuildList() } else { - println "*! Merge build requires a repository client connection to a DBB web application" + println "*! Merge build requires a Filesystem or Db2 MetadataStore" } } @@ -541,7 +579,7 @@ def createBuildList() { // we do not need to scan them again if (!props.impactBuild && !props.userBuild && !props.mergeBuild) { println "** Scanning source code." - impactUtils.updateCollection(buildList, null, null, repositoryClient) + impactUtils.updateCollection(buildList, null, null) } // Loading file/member level properties from member specific properties files @@ -551,26 +589,21 @@ def createBuildList() { } // Perform analysis and build report of external impacts - if (props.reportExternalImpacts && props.reportExternalImpacts.toBoolean() && repositoryClient){ - - if (buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.3")) { // validate minimum dbbToolkitVersion - if (buildSet && changedFiles) { - println "** Perform analysis and reporting of external impacted files for the build list including changed files." - impactUtils.reportExternalImpacts(repositoryClient, buildSet.plus(changedFiles)) - } - else if(buildSet) { - println "** Perform analysis and reporting of external impacted files for the build list." - impactUtils.reportExternalImpacts(repositoryClient, buildSet) - } - } else{ - println "*! Perform analysis and reporting of external impacted files requires at least IBM Dependency Based Build Toolkit version 1.1.3." + if (props.reportExternalImpacts && props.reportExternalImpacts.toBoolean()){ + if (buildSet && changedFiles) { + println "** Perform analysis and reporting of external impacted files for the build list including changed files." + impactUtils.reportExternalImpacts(buildSet.plus(changedFiles)) + } + else if(buildSet) { + println "** Perform analysis and reporting of external impacted files for the build list." + impactUtils.reportExternalImpacts(buildSet) } } // Document and validate concurrent changes - if (repositoryClient && props.reportConcurrentChanges && props.reportConcurrentChanges.toBoolean() && repositoryClient){ + if (props.reportConcurrentChanges && props.reportConcurrentChanges.toBoolean()){ println "** Calculate and document concurrent changes." - impactUtils.calculateConcurrentChanges(repositoryClient, buildSet) + impactUtils.calculateConcurrentChanges(buildSet) } // document deletions in build report @@ -593,8 +626,8 @@ def finalizeBuildProcess(Map args) { def buildResult = null // update repository artifacts - if (repositoryClient) { - buildResult = repositoryClient.getBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) + if (metadataStore) { + buildResult = metadataStore.getBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) // add git hashes for each build directory List srcDirs = [] @@ -618,7 +651,7 @@ def finalizeBuildProcess(Map args) { // document changed files - Git compare link if (props.impactBuild && props.gitRepositoryURL && props.gitRepositoryCompareService){ String gitchangedfilesKey = "$gitchangedfilesPrefix${buildUtils.relativizePath(dir)}" - def lastBuildResult= buildUtils.retrieveLastBuildResult(repositoryClient) + def lastBuildResult= buildUtils.retrieveLastBuildResult() if (lastBuildResult){ String baselineHash = lastBuildResult.getProperty(key) String gitchangedfilesLink = props.gitRepositoryURL << "/" << props.gitRepositoryCompareService <<"/" << baselineHash << ".." << currenthash @@ -637,8 +670,7 @@ def finalizeBuildProcess(Map args) { buildResult.setProperty("filesProcessed", String.valueOf(args.count)) buildResult.setState(buildResult.COMPLETE) - // save updates - buildResult.save() + // store build result properties in BuildReport.json PropertiesRecord buildReportRecord = new PropertiesRecord("DBB.BuildResultProperties") @@ -646,6 +678,10 @@ def finalizeBuildProcess(Map args) { buildResultProps.each { buildResultPropName -> buildReportRecord.addProperty(buildResultPropName, buildResult.getProperty(buildResultPropName)) } + // def buildResultProps = buildResult.getProperties() + // buildResultProps.each { name, value -> + // buildReportRecord.addProperty(name, value) + // } buildReport.addRecord(buildReportRecord) } @@ -660,25 +696,22 @@ def finalizeBuildProcess(Map args) { // create build report html file def htmlOutputFile = new File("${props.buildOutDir}/BuildReport.html") println "** Writing build report to ${htmlOutputFile}" - def htmlTemplate = null // Use default HTML template. - def css = null // Use default theme. - def renderScript = null // Use default rendering. - def transformer = HtmlTransformer.getInstance() - transformer.transform(jsonOutputFile, htmlTemplate, css, renderScript, htmlOutputFile, buildReportEncoding) + buildReport.generateHTML(htmlOutputFile) // attach build report & result - if (repositoryClient) { + if (metadataStore) { buildReport.save(jsonOutputFile, buildReportEncoding) + // Save build report & build report data buildResult.setBuildReport(new FileInputStream(htmlOutputFile)) buildResult.setBuildReportData(new FileInputStream(jsonOutputFile)) - println "** Updating build result BuildGroup:${props.applicationBuildGroup} BuildLabel:${props.applicationBuildLabel} at ${props.buildResultUrl}" - buildResult.save() + println "** Updating build result BuildGroup:${props.applicationBuildGroup} BuildLabel:${props.applicationBuildLabel}" } // print end build message def endTime = new Date() def duration = TimeCategory.minus(endTime, args.start) + //buildResult.setProperty("buildDuration", duration.toString()) def state = (props.error) ? "ERROR" : "CLEAN" println("** Build ended at $endTime") println("** Build State : $state") diff --git a/languages/Assembler.groovy b/languages/Assembler.groovy index f64f4774..b47bb896 100644 --- a/languages/Assembler.groovy +++ b/languages/Assembler.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -11,12 +11,7 @@ import com.ibm.dbb.build.report.records.* @Field BuildProperties props = BuildProperties.getInstance() @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) @Field def impactUtils= loadScript(new File("${props.zAppBuildDir}/utilities/ImpactUtilities.groovy")) -@Field RepositoryClient repositoryClient - -@Field def resolverUtils -// Conditionally load the ResolverUtilities.groovy which require at least DBB 1.1.2 -if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { - resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy"))} +@Field def resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy")) println("** Building files mapped to ${this.class.getName()}.groovy script") @@ -33,23 +28,16 @@ List sortedList = buildUtils.sortBuildList(argMap.buildList, 'assembler_ sortedList.each { buildFile -> println "*** Building file $buildFile" - // configure dependency resolution and create logical file - def dependencyResolver - LogicalFile logicalFile - - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && props.assembler_dependencySearch && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { // use new SearchPathDependencyResolver - String dependencySearch = props.getFileProperty('assembler_dependencySearch', buildFile) - dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) - logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) - } else { // use deprecated DependencyResolver - String rules = props.getFileProperty('assembler_resolutionRules', buildFile) - dependencyResolver = buildUtils.createDependencyResolver(buildFile, rules) - logicalFile = dependencyResolver.getLogicalFile() - } + // Configure dependency resolution + String dependencySearch = props.getFileProperty('assembler_dependencySearch', buildFile) + def dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) - // copy build file and dependency files to data sets + // Copy build file and dependency files to data sets buildUtils.copySourceFiles(buildFile, props.assembler_srcPDS, 'assembler_dependenciesDatasetMapping', null ,dependencyResolver) + // Create logical file + LogicalFile logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) + // create mvs commands String member = CopyToPDS.createMemberName(buildFile) File logFile = new File( props.userBuild ? "${props.buildOutDir}/${member}.log" : "${props.buildOutDir}/${member}.asm.log") @@ -75,7 +63,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The assembler sql translator return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { // Store db2 bind information as a generic property record in the BuildReport String generateDb2BindInfoRecord = props.getFileProperty('generateDb2BindInfoRecord', buildFile) @@ -93,7 +81,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The assembler cics translator return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } } @@ -106,7 +94,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The assembler return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { // if this program needs to be link edited . . . @@ -119,15 +107,15 @@ sortedList.each { buildFile -> String errorMsg = "*! The link edit return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { // only scan the load module if load module scanning turned on for file if(!props.userBuild){ String scanLoadModule = props.getFileProperty('assembler_scanLoadModule', buildFile) - if (scanLoadModule && scanLoadModule.toBoolean() && getRepositoryClient()) { + if (scanLoadModule && scanLoadModule.toBoolean()) { String assembler_loadPDS = props.getFileProperty('assembler_loadPDS', buildFile) - impactUtils.saveStaticLinkDependencies(buildFile, assembler_loadPDS, logicalFile, repositoryClient) + impactUtils.saveStaticLinkDependencies(buildFile, assembler_loadPDS, logicalFile) } } } @@ -370,9 +358,3 @@ def createLinkEditCommand(String buildFile, LogicalFile logicalFile, String memb return linkedit } -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - return repositoryClient -} - diff --git a/languages/BMS.groovy b/languages/BMS.groovy index b8c9e7f8..f8482f1a 100644 --- a/languages/BMS.groovy +++ b/languages/BMS.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -9,8 +9,6 @@ import groovy.transform.* @Field BuildProperties props = BuildProperties.getInstance() @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) -@Field RepositoryClient repositoryClient - println("** Building files mapped to ${this.class.getName()}.groovy script") // verify required build properties @@ -50,7 +48,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The build return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } } @@ -148,12 +146,6 @@ def createLinkEditCommand(String buildFile, String member, File logFile) { return linkedit } -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} diff --git a/languages/Cobol.groovy b/languages/Cobol.groovy index d5d4d634..09104726 100644 --- a/languages/Cobol.groovy +++ b/languages/Cobol.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -13,12 +13,7 @@ import com.ibm.dbb.build.report.records.* @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) @Field def impactUtils= loadScript(new File("${props.zAppBuildDir}/utilities/ImpactUtilities.groovy")) @Field def bindUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BindUtilities.groovy")) -@Field RepositoryClient repositoryClient - -@Field def resolverUtils -// Conditionally load the ResolverUtilities.groovy which require at least DBB 1.1.2 -if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { - resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy"))} +@Field def resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy")) println("** Building files mapped to ${this.class.getName()}.groovy script") @@ -44,15 +39,9 @@ sortedList.each { buildFile -> // Check if this a testcase isZUnitTestCase = (props.getFileProperty('cobol_testcase', buildFile).equals('true')) ? true : false - // configure appropriate dependency resolver - def dependencyResolver - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && props.cobol_dependencySearch && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { // use new SearchPathDependencyResolver - String dependencySearch = props.getFileProperty('cobol_dependencySearch', buildFile) - dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) - } else { // use deprecated DependencyResolver - String rules = props.getFileProperty('cobol_resolutionRules', buildFile) - dependencyResolver = buildUtils.createDependencyResolver(buildFile, rules) - } + // configure dependency resolution and create logical file + String dependencySearch = props.getFileProperty('cobol_dependencySearch', buildFile) + def dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) // copy build file and dependency files to data sets if(isZUnitTestCase){ @@ -61,14 +50,8 @@ sortedList.each { buildFile -> buildUtils.copySourceFiles(buildFile, props.cobol_srcPDS, 'cobol_dependenciesDatasetMapping', props.cobol_dependenciesAlternativeLibraryNameMapping, dependencyResolver) } - // get logical file - LogicalFile logicalFile - if (dependencyResolver instanceof SearchPathDependencyResolver) { - logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) - } - else { - logicalFile = dependencyResolver.getLogicalFile() - } + // Get logical file + LogicalFile logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) // create mvs commands String member = CopyToPDS.createMemberName(buildFile) @@ -93,7 +76,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The compile return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { // if this program needs to be link edited . . . @@ -114,14 +97,14 @@ sortedList.each { buildFile -> String errorMsg = "*! The link edit return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { if(!props.userBuild && !isZUnitTestCase){ // only scan the load module if load module scanning turned on for file String scanLoadModule = props.getFileProperty('cobol_scanLoadModule', buildFile) - if (scanLoadModule && scanLoadModule.toBoolean() && getRepositoryClient()) - impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile, repositoryClient) + if (scanLoadModule && scanLoadModule.toBoolean()) + impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile) } } } @@ -140,7 +123,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The bind package return code ($bindRc) for $buildFile exceeded the maximum return code allowed ($props.bind_maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}_bind.log":bindLogFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}_bind.log":bindLogFile]) } } @@ -270,7 +253,7 @@ def createCompileCommand(String buildFile, LogicalFile logicalFile, String membe String errorMsg = "*! Cobol.groovy. The dataset definition $datasetDefinition could not be resolved from the DBB Build properties." println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg) } } } @@ -396,14 +379,6 @@ def createLinkEditCommand(String buildFile, LogicalFile logicalFile, String memb return linkedit } - -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} - boolean buildListContainsTests(List buildList) { boolean containsZUnitTestCase = buildList.find { buildFile -> props.getFileProperty('cobol_testcase', buildFile).equals('true')} return containsZUnitTestCase ? true : false diff --git a/languages/DBDgen.groovy b/languages/DBDgen.groovy index dd2d951e..09f38cc8 100644 --- a/languages/DBDgen.groovy +++ b/languages/DBDgen.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -8,8 +8,6 @@ import groovy.transform.* @Field BuildProperties props = BuildProperties.getInstance() @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) -@Field RepositoryClient repositoryClient - println("** Building files mapped to ${this.class.getName()}.groovy script") // verify required build properties @@ -49,7 +47,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The assembly return code for DBDgen ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { @@ -60,7 +58,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The link edit return code for DBDgen ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } } @@ -160,12 +158,3 @@ def createDBDLinkEditCommand(String buildFile, String member, File logFile) { } -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} - - - diff --git a/languages/LinkEdit.groovy b/languages/LinkEdit.groovy index 9905efde..5d048f14 100644 --- a/languages/LinkEdit.groovy +++ b/languages/LinkEdit.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -9,7 +9,6 @@ import groovy.transform.* @Field BuildProperties props = BuildProperties.getInstance() @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) @Field def impactUtils= loadScript(new File("${props.zAppBuildDir}/utilities/ImpactUtilities.groovy")) -@Field RepositoryClient repositoryClient println("** Building files mapped to ${this.class.getName()}.groovy script") @@ -29,16 +28,10 @@ sortedList.each { buildFile -> // copy build file to input data set buildUtils.copySourceFiles(buildFile, props.linkedit_srcPDS, null, null, null) + // Get logical file + LogicalFile logicalFile = SearchPathDependencyResolver.getLogicalFile(buildFile,props.workspace) + // create mvs commands - LogicalFile logicalFile - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean()) { // use new SearchPathDependencyResolver - logicalFile = SearchPathDependencyResolver.getLogicalFile(buildFile,props.workspace) - } - else { // use deprecated DependencyResolver API - DependencyResolver dependencyResolver = buildUtils.createDependencyResolver(buildFile, null) - logicalFile = dependencyResolver.getLogicalFile() - } - String member = CopyToPDS.createMemberName(buildFile) File logFile = new File( props.userBuild ? "${props.buildOutDir}/${member}.log" : "${props.buildOutDir}/${member}.linkedit.log") @@ -57,14 +50,14 @@ sortedList.each { buildFile -> String errorMsg = "*! The link edit return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { if(!props.userBuild){ // only scan the load module if load module scanning turned on for file String scanLoadModule = props.getFileProperty('linkedit_scanLoadModule', buildFile) - if (scanLoadModule && scanLoadModule.toBoolean() && getRepositoryClient()) - impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile, repositoryClient) + if (scanLoadModule && scanLoadModule.toBoolean()) + impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile) } } @@ -121,13 +114,5 @@ def createLinkEditCommand(String buildFile, LogicalFile logicalFile, String memb } -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} - - diff --git a/languages/MFS.groovy b/languages/MFS.groovy index 968ff32f..86fa4028 100644 --- a/languages/MFS.groovy +++ b/languages/MFS.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -10,8 +10,6 @@ import groovy.transform.* @Field BuildProperties props = BuildProperties.getInstance() @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) -@Field RepositoryClient repositoryClient - println("** Building files mapped to ${this.class.getName()}.groovy script") // verify required build properties @@ -51,7 +49,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The phase1 return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { @@ -62,7 +60,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The phase 2 return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } } @@ -146,13 +144,3 @@ def createPhase2Command(String buildFile, String member, File logFile) { return mfsPhase2 } - -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} - - - diff --git a/languages/PLI.groovy b/languages/PLI.groovy index bce56dc7..720842a8 100644 --- a/languages/PLI.groovy +++ b/languages/PLI.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -12,12 +12,7 @@ import com.ibm.dbb.build.report.records.* @Field BuildProperties props = BuildProperties.getInstance() @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) @Field def impactUtils= loadScript(new File("${props.zAppBuildDir}/utilities/ImpactUtilities.groovy")) -@Field RepositoryClient repositoryClient - -@Field def resolverUtils -// Conditionally load the ResolverUtilities.groovy which require at least DBB 1.1.2 -if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { - resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy"))} +@Field def resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy")) println("** Building files mapped to ${this.class.getName()}.groovy script") @@ -42,19 +37,10 @@ sortedList.each { buildFile -> // Check if this a testcase isZUnitTestCase = (props.getFileProperty('pli_testcase', buildFile).equals('true')) ? true : false - // configure dependency resolution and create logical file - def dependencyResolver - LogicalFile logicalFile + // configure SearchPathDependencyResolver + String dependencySearch = props.getFileProperty('pli_dependencySearch', buildFile) + def dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && props.pli_dependencySearch && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { // use new SearchPathDependencyResolver - String dependencySearch = props.getFileProperty('pli_dependencySearch', buildFile) - dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) - logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) - } else { // use deprecated DependencyResolver - String rules = props.getFileProperty('pli_resolutionRules', buildFile) - dependencyResolver = buildUtils.createDependencyResolver(buildFile, rules) - logicalFile = dependencyResolver.getLogicalFile() - } // copy build file and dependency files to data sets if(isZUnitTestCase){ @@ -63,6 +49,9 @@ sortedList.each { buildFile -> buildUtils.copySourceFiles(buildFile, props.pli_srcPDS, 'pli_dependenciesDatasetMapping', props.pli_dependenciesAlternativeLibraryNameMapping, dependencyResolver) } + // Get logical file + LogicalFile logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) + // create mvs commands String member = CopyToPDS.createMemberName(buildFile) File logFile = new File( props.userBuild ? "${props.buildOutDir}/${member}.log" : "${props.buildOutDir}/${member}.pli.log") @@ -83,7 +72,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The compile return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { // if this program needs to be link edited . . . @@ -104,14 +93,14 @@ sortedList.each { buildFile -> String errorMsg = "*! The link edit return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { // only scan the load module if load module scanning turned on for file if(!props.userBuild && !isZUnitTestCase){ String scanLoadModule = props.getFileProperty('pli_scanLoadModule', buildFile) - if (scanLoadModule && scanLoadModule.toBoolean() && getRepositoryClient()) - impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile, repositoryClient) + if (scanLoadModule && scanLoadModule.toBoolean()) + impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile) } } } @@ -249,7 +238,7 @@ def createCompileCommand(String buildFile, LogicalFile logicalFile, String membe String errorMsg = "*! PLI.groovy. The dataset definition $datasetDefinition could not be resolved from the DBB Build properties." println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg) } } } @@ -347,13 +336,6 @@ def createLinkEditCommand(String buildFile, LogicalFile logicalFile, String memb } -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} - boolean buildListContainsTests(List buildList) { boolean containsZUnitTestCase = buildList.find { buildFile -> props.getFileProperty('pli_testcase', buildFile).equals('true')} return containsZUnitTestCase ? true : false diff --git a/languages/PSBgen.groovy b/languages/PSBgen.groovy index 1e783e2d..3a7ace11 100644 --- a/languages/PSBgen.groovy +++ b/languages/PSBgen.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -8,8 +8,6 @@ import groovy.transform.* @Field BuildProperties props = BuildProperties.getInstance() @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) -@Field RepositoryClient repositoryClient - println("** Building files mapped to ${this.class.getName()}.groovy script") // verify required build properties @@ -53,7 +51,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The assembly return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { @@ -64,7 +62,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The link edit return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else{ @@ -76,7 +74,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The acbgen return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } } } @@ -235,12 +233,3 @@ def createACBgenCommand(String buildFile, String member, File logFile) { return acbgen } -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} - - - diff --git a/languages/REXX.groovy b/languages/REXX.groovy index 0c7a2289..719bb10c 100644 --- a/languages/REXX.groovy +++ b/languages/REXX.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* // define script properties @@ -7,12 +7,7 @@ import com.ibm.dbb.repository.* @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) @Field def impactUtils= loadScript(new File("${props.zAppBuildDir}/utilities/ImpactUtilities.groovy")) @Field def bindUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BindUtilities.groovy")) -@Field RepositoryClient repositoryClient - -@Field def resolverUtils -// Conditionally load the ResolverUtilities.groovy which require at least DBB 1.1.2 -if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { - resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy"))} +@Field def resolverUtils= loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy")) println("** Building files mapped to ${this.class.getName()}.groovy script") @@ -32,23 +27,16 @@ sortedList.each { buildFile -> println "*** Building file $buildFile" - // configure dependency resolution and create logical file - def dependencyResolver - LogicalFile logicalFile - - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && props.rexx_dependencySearch && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { // use new SearchPathDependencyResolver - String dependencySearch = props.getFileProperty('rexx_dependencySearch', buildFile) - dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) - logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) - } else { // use deprecated DependencyResolver - String rules = props.getFileProperty('rexx_resolutionRules', buildFile) - dependencyResolver = buildUtils.createDependencyResolver(buildFile, rules) - logicalFile = dependencyResolver.getLogicalFile() - } + // configure dependency resolution and create logical file + String dependencySearch = props.getFileProperty('rexx_dependencySearch', buildFile) + def dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) // copy build file and dependency files to data sets buildUtils.copySourceFiles(buildFile, props.rexx_srcPDS, 'rexx_dependenciesDatasetMapping', null, dependencyResolver) + // Get logical file + LogicalFile logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile) + // create mvs commands String member = CopyToPDS.createMemberName(buildFile) File logFile = new File( props.userBuild ? "${props.buildOutDir}/${member}.log" : "${props.buildOutDir}/${member}.REXX.log") @@ -76,7 +64,7 @@ sortedList.each { buildFile -> String errorMsg = "*! The compile return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { // if this program needs to be link edited . . . @@ -89,14 +77,14 @@ sortedList.each { buildFile -> String errorMsg = "*! The link edit return code ($rc) for $buildFile exceeded the maximum return code allowed ($maxRC)" println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}.log":logFile]) } else { if (!props.userBuild){ // only scan the load module if load module scanning turned on for file String scanLoadModule = props.getFileProperty('rexx_scanLoadModule', buildFile) - if (scanLoadModule && scanLoadModule.toBoolean() && getRepositoryClient()) - impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile, repositoryClient) + if (scanLoadModule && scanLoadModule.toBoolean()) + impactUtils.saveStaticLinkDependencies(buildFile, props.linkedit_loadPDS, logicalFile) } } } @@ -241,10 +229,3 @@ def createLinkEditCommand(String buildFile, LogicalFile logicalFile, String memb return linkedit } - -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} diff --git a/languages/Transfer.groovy b/languages/Transfer.groovy index 6f1e942c..84ed5ca4 100644 --- a/languages/Transfer.groovy +++ b/languages/Transfer.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import com.ibm.dbb.build.report.records.* @@ -29,8 +29,6 @@ import groovy.transform.* // Set to keep information about which datasets where already checked/created @Field HashSet verifiedBuildDatasets = new HashSet() -@Field RepositoryClient repositoryClient - println("** Building files mapped to ${this.class.getName()}.groovy script") // verify required build properties @@ -52,7 +50,7 @@ buildList.each { buildFile -> errorMsg = "*! Warning. Member name (${member}) exceeds length of 8 characters. " println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg) } else { // evaluate the datasetmapping, which maps build files to targetDataset defintions @@ -80,27 +78,20 @@ buildList.each { buildFile -> String errorMsg = "*! The CopyToPDS return code ($rc) for $buildFile exceeded the maximum return code allowed (0)." println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg) } } catch (BuildException e) { // Catch potential exceptions like file truncation String errorMsg = "*! The CopyToPDS failed with an exception ${e.getMessage()}." println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg) } } else { String errorMsg = "*! Target dataset for $buildFile could not be obtained from file properties. " println(errorMsg) props.error = "true" - buildUtils.updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg) } } } -// internal methods -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} diff --git a/languages/ZunitConfig.groovy b/languages/ZunitConfig.groovy index 3b21a0fe..f7671502 100644 --- a/languages/ZunitConfig.groovy +++ b/languages/ZunitConfig.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -11,12 +11,7 @@ import groovy.xml.* @Field def buildUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BuildUtilities.groovy")) @Field def impactUtils= loadScript(new File("${props.zAppBuildDir}/utilities/ImpactUtilities.groovy")) @Field def bindUtils= loadScript(new File("${props.zAppBuildDir}/utilities/BindUtilities.groovy")) -@Field RepositoryClient repositoryClient - -@Field def resolverUtils -// Conditionally load the ResolverUtilities.groovy which require at least DBB 1.1.2 -if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { - resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy"))} +@Field def resolverUtils = loadScript(new File("${props.zAppBuildDir}/utilities/ResolverUtilities.groovy")) println("** Building files mapped to ${this.class.getName()}.groovy script") @@ -37,16 +32,9 @@ buildUtils.createLanguageDatasets(langQualifier) File logFile = new File("${props.buildOutDir}/${member}.zunit.jcl.log") File reportLogFile = new File("${props.buildOutDir}/${member}.zunit.report.log") - // configure dependency resolution - def dependencyResolver - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && props.zunit_dependencySearch && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { // use new SearchPathDependencyResolver - String dependencySearch = props.getFileProperty('zunit_dependencySearch', buildFile) - dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) - } else { // use deprecated DependencyResolver - String rules = props.getFileProperty('zunit_resolutionRules', buildFile) - dependencyResolver = buildUtils.createDependencyResolver(buildFile, rules) - } + String dependencySearch = props.getFileProperty('zunit_dependencySearch', buildFile) + def dependencyResolver = resolverUtils.createSearchPathDependencyResolver(dependencySearch) // copy build file and dependency files to data sets buildUtils.copySourceFiles(buildUtils.getAbsolutePath(buildFile), props.zunit_bzucfgPDS, 'zunit_dependenciesDatasetMapping', null, dependencyResolver) @@ -206,12 +194,12 @@ zunitDebugParm = props.getFileProperty('zunit_userDebugSessionTestParm', buildFi // print warning and report println warningMsg printReport(reportLogFile) - buildUtils.updateBuildResult(warningMsg:warningMsg,logs:["${member}_zunit.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(warningMsg:warningMsg,logs:["${member}_zunit.log":logFile]) } else { // rc > props.zunit_maxWarnRC.toInteger() props.error = "true" String errorMsg = "*! The zunit test failed with RC=($rc) for $buildFile " println(errorMsg) - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}_zunit.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}_zunit.log":logFile]) } } else { @@ -219,7 +207,7 @@ zunitDebugParm = props.getFileProperty('zunit_userDebugSessionTestParm', buildFi props.error = "true" String errorMsg = "*! zUnit Test Job ${zUnitRunJCL.submittedJobId} failed with ${zUnitRunJCL.maxRC}" println(errorMsg) - buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}_zunit.log":logFile],client:getRepositoryClient()) + buildUtils.updateBuildResult(errorMsg:errorMsg,logs:["${member}_zunit.log":logFile]) } } @@ -228,13 +216,6 @@ zunitDebugParm = props.getFileProperty('zunit_userDebugSessionTestParm', buildFi * Methods */ -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - - return repositoryClient -} - /* * returns containsPlayback, */ diff --git a/samples/MortgageApplication/application-conf/README.md b/samples/MortgageApplication/application-conf/README.md index 81e67ae9..0b5f441b 100644 --- a/samples/MortgageApplication/application-conf/README.md +++ b/samples/MortgageApplication/application-conf/README.md @@ -20,7 +20,6 @@ gitRepositoryURL | git repository URL of the application repository to establis excludeFileList | Files to exclude when scanning or running full build. skipImpactCalculationList | Files for which the impact analysis should be skipped in impact build jobCard | JOBCARD for JCL execs -useSearchConfiguration | Flag to define which DBB API is used for dependency and impact analysis. `false` uses DependencyResolver and ImpactResolver APIs, while `true` leverages the DBB SearchPathDependencyResolver and SearchParthImpactFinder APIs introduced with DBB 1.1.2 resolveSubsystems | boolean flag to configure the SearchPathDependencyResolver to evaluate if resolved dependencies impact the file flags isCICS, isSQL, isDLI, isMQ when creating the LogicalFile impactResolutionRules | Comma separated list of resolution rule properties used for impact builds. Sample resolution rule properties (in JSON format) are included below. ** deprecated ** Please consider moving to new SearchPathDepedencyAPI leveraging `impactSearch` configuration. impactSearch | Impact finder resolution search configuration leveraging the SearchPathImpactFinder API. Sample configurations are inlcuded below, next to the previous rule definitions. diff --git a/samples/MortgageApplication/application-conf/application.properties b/samples/MortgageApplication/application-conf/application.properties index b7271161..88806c93 100644 --- a/samples/MortgageApplication/application-conf/application.properties +++ b/samples/MortgageApplication/application-conf/application.properties @@ -97,23 +97,10 @@ propertyFileExtension=properties ############################################################### # Dependency Analysis and Impact Analysis configuration ############################################################### -# -# flag to define which DBB API is used for dependency and impact analysis -# -# false = uses the DependencyResolver and ImpactResolver APIs (default) -# please note that DependencyResolver and ImpactResolver APIs are deprecated -# configuration is based on the lang_resolutionRules and impactResolutionRules build properties -# -# true = leverages the DBB SearchPathDependencyResolver and SearchParthImpactFinder APIs introduced with DBB 1.1.2 -# configuration is based on the lang_dependencySearch and impactSearch build properties -# -useSearchConfiguration=false - # # boolean flag to configure the SearchPathDependencyResolver to evaluate if resolved dependencies impact # the file flags isCICS, isSQL, isDLI, isMQ when creating the LogicalFile # -# requires to use new APIs via useSearchConfiguration=true # default:false resolveSubsystems=false diff --git a/samples/application-conf/README.md b/samples/application-conf/README.md index 9cf708a8..67ea16cd 100644 --- a/samples/application-conf/README.md +++ b/samples/application-conf/README.md @@ -28,7 +28,6 @@ loadFileLevelProperties | Flag to enable the zAppBuild capability to load indivi propertyFilePath | relative path to folder containing individual property files | true propertyFileExtension | file extension for individual property files | true **Dependency and Impact resolution configuration** || -useSearchConfiguration | Flag to define which DBB API is used for dependency and impact analysis. `false` uses DependencyResolver and ImpactResolver APIs, while `true` leverages the DBB SearchPathDependencyResolver and SearchParthImpactFinder APIs introduced with DBB 1.1.2 | false resolveSubsystems | boolean flag to configure the SearchPathDependencyResolver to evaluate if resolved dependencies impact the file flags isCICS, isSQL, isDLI, isMQ when creating the LogicalFile | false impactResolutionRules | Comma separated list of resolution rule properties used for impact builds. Sample resolution rule properties (in JSON format) are included below. ** deprecated ** Please consider moving to new SearchPathDepedencyAPI leveraging `impactSearch` configuration. | true, recommended in file.properties impactSearch | Impact finder resolution search configuration leveraging the SearchPathImpactFinder API. Sample configurations are inlcuded below, next to the previous rule definitions. | true diff --git a/samples/application-conf/application.properties b/samples/application-conf/application.properties index 1fdb7876..f1282d31 100644 --- a/samples/application-conf/application.properties +++ b/samples/application-conf/application.properties @@ -116,23 +116,10 @@ propertyFileExtension=properties ############################################################### # Dependency Analysis and Impact Analysis configuration ############################################################### -# -# flag to define which DBB API is used for dependency and impact analysis -# -# false = uses the DependencyResolver and ImpactResolver APIs (default) -# please note that DependencyResolver and ImpactResolver APIs are deprecated -# configuration is based on the lang_resolutionRules and impactResolutionRules build properties -# -# true = leverages the DBB SearchPathDependencyResolver and SearchParthImpactFinder APIs introduced with DBB 1.1.2 -# configuration is based on the lang_dependencySearch and impactSearch build properties -# -useSearchConfiguration=false - # # boolean flag to configure the SearchPathDependencyResolver to evaluate if resolved dependencies impact # the file flags isCICS, isSQL, isDLI, isMQ when creating the LogicalFile # -# requires to use new APIs via useSearchConfiguration=true # default:false resolveSubsystems=false diff --git a/samples/userBuildDependencyFile/sample.json b/samples/userBuildDependencyFile/sample.json index 9b323665..9fd17dd8 100644 --- a/samples/userBuildDependencyFile/sample.json +++ b/samples/userBuildDependencyFile/sample.json @@ -1,12 +1,12 @@ { - "fileName": "/u/burgess/dbb/dbb-zappbuild/samples/MortgageApplication/cobol/epscmort.cbl", + "fileName": "MortgageApplication/cobol/epscmort.cbl", "isCICS": true, "isSQL": true, "isDLI": false, "isMQ": false, "dependencies": [ - "/u/burgess/dbb/dbb-zappbuild/samples/MortgageApplication/copybook/epsmtcom.cpy", - "/u/burgess/dbb/dbb-zappbuild/samples/MortgageApplication/copybook/epsnbrpm.cpy", + "MortgageApplication/copybook/epsmtcom.cpy", + "MortgageApplication/copybook/epsnbrpm.cpy", "MortgageApplication/copybook/epsmtinp.cpy", "MortgageApplication/copybook/epsmtout.cpy" ], diff --git a/utilities/BindUtilities.groovy b/utilities/BindUtilities.groovy index a700c630..c53bc39c 100644 --- a/utilities/BindUtilities.groovy +++ b/utilities/BindUtilities.groovy @@ -1,6 +1,6 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript import com.ibm.dbb.build.* -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import groovy.transform.* import groovy.cli.commons.* diff --git a/utilities/BuildUtilities.groovy b/utilities/BuildUtilities.groovy index 45ed6f51..bdd90443 100644 --- a/utilities/BuildUtilities.groovy +++ b/utilities/BuildUtilities.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @@ -116,8 +116,7 @@ def copySourceFiles(String buildFile, String srcPDS, String dependencyDatasetMap String language = props.getFileProperty('dbb.DependencyScanner.languageHint', buildFile) ?: 'UNKN' LogicalFile lfile = new LogicalFile(lname, buildFile, language, depFileData.isCICS, depFileData.isSQL, depFileData.isDLI) // set logical file in the dependency resolver if using deprecated API - if (dependencyResolver && (dependencyResolver instanceof DependencyResolver)) - dependencyResolver.setLogicalFile(lfile) + //dependencyResolver.setLogicalFile(lfile) // get list of dependencies from userBuildDependencyFile List dependencyPaths = depFileData.dependencies @@ -158,23 +157,10 @@ def copySourceFiles(String buildFile, String srcPDS, String dependencyDatasetMap } else if (dependencyDatasetMapping && dependencyResolver) { // resolve the logical dependencies to physical files to copy to data sets - List physicalDependencies - - if (dependencyResolver instanceof DependencyResolver) { // deprecated DependencyResolver - physicalDependencies = dependencyResolver.resolve() - if (props.verbose) { - println "*** Resolution rules for $buildFile:" - - if (props.formatConsoleOutput && props.formatConsoleOutput.toBoolean()) { - printResolutionRules(dependencyResolver.getResolutionRules()) - } else { - dependencyResolver.getResolutionRules().each{ rule -> println rule } - } - } - } else if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { - resolverUtils = loadScript(new File("ResolverUtilities.groovy")) - physicalDependencies = resolverUtils.resolveDependencies(dependencyResolver, buildFile) - } + + resolverUtils = loadScript(new File("ResolverUtilities.groovy")) + List physicalDependencies = resolverUtils.resolveDependencies(dependencyResolver, buildFile) + if (props.verbose) println "*** Physical dependencies for $buildFile:" @@ -284,11 +270,11 @@ def sortBuildList(List buildList, String rankPropertyName) { * updateBuildResult - used by language scripts to update the build result after a build step */ def updateBuildResult(Map args) { - // args : errorMsg / warningMsg, logs[logName:logFile], client:repoClient - + // args : errorMsg / warningMsg, logs[logName:logFile] + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() // update build results only in non-userbuild scenarios - if (args.client && !props.userBuild) { - def buildResult = args.client.getBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) + if (metadataStore && !props.userBuild) { + def buildResult = metadataStore.getBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) if (!buildResult) { println "*! No build result found for BuildGroup '${props.applicationBuildGroup}' and BuildLabel '${props.applicationBuildLabel}'" return @@ -316,8 +302,6 @@ def updateBuildResult(Map args) { } } - // save result - buildResult.save() } } @@ -325,48 +309,48 @@ def updateBuildResult(Map args) { * createDependencyResolver - Creates a dependency resolver using resolution rules declared * in a build or file property (json format). */ -def createDependencyResolver(String buildFile, String rules) { - if (props.verbose) println "*** Creating dependency resolver for $buildFile with $rules rules" +// def createDependencyResolver(String buildFile, String rules) { +// if (props.verbose) println "*** Creating dependency resolver for $buildFile with $rules rules" - // create a dependency resolver for the build file - DependencyResolver resolver = new DependencyResolver().file(buildFile) - .sourceDir(props.workspace) +// // create a dependency resolver for the build file +// DependencyResolver resolver = new DependencyResolver().file(buildFile) +// .sourceDir(props.workspace) - // add scanner if userBuild Dep File not provided, or not a user build - if (!props.userBuildDependencyFile || !props.userBuild) - resolver.setScanner(getScanner(buildFile)) - - // add resolution rules - if (rules) - resolver.setResolutionRules(parseResolutionRules(rules)) - - return resolver -} - -def parseResolutionRules(String json) { - List rules = new ArrayList() - JsonSlurper slurper = new groovy.json.JsonSlurper() - List jsonRules = slurper.parseText(json) - if (jsonRules) { - jsonRules.each { jsonRule -> - ResolutionRule resolutionRule = new ResolutionRule() - resolutionRule.library(jsonRule.library) - resolutionRule.lname(jsonRule.lname) - resolutionRule.category(jsonRule.category) - if (jsonRule.searchPath) { - jsonRule.searchPath.each { jsonPath -> - DependencyPath dependencyPath = new DependencyPath() - dependencyPath.collection(jsonPath.collection) - dependencyPath.sourceDir(jsonPath.sourceDir) - dependencyPath.directory(jsonPath.directory) - resolutionRule.path(dependencyPath) - } - } - rules << resolutionRule - } - } - return rules -} +// // add scanner if userBuild Dep File not provided, or not a user build +// if (!props.userBuildDependencyFile || !props.userBuild) +// resolver.setScanner(getScanner(buildFile)) + +// // add resolution rules +// if (rules) +// resolver.setResolutionRules(parseResolutionRules(rules)) + +// return resolver +// } + +// def parseResolutionRules(String json) { +// List rules = new ArrayList() +// JsonSlurper slurper = new groovy.json.JsonSlurper() +// List jsonRules = slurper.parseText(json) +// if (jsonRules) { +// jsonRules.each { jsonRule -> +// ResolutionRule resolutionRule = new ResolutionRule() +// resolutionRule.library(jsonRule.library) +// resolutionRule.lname(jsonRule.lname) +// resolutionRule.category(jsonRule.category) +// if (jsonRule.searchPath) { +// jsonRule.searchPath.each { jsonPath -> +// DependencyPath dependencyPath = new DependencyPath() +// dependencyPath.collection(jsonPath.collection) +// dependencyPath.sourceDir(jsonPath.sourceDir) +// dependencyPath.directory(jsonPath.directory) +// resolutionRule.path(dependencyPath) +// } +// } +// rules << resolutionRule +// } +// } +// return rules +// } @@ -538,20 +522,20 @@ def getLangPrefix(String scriptName){ } /* - * retrieveLastBuildResult(RepositoryClient) + * retrieveLastBuildResult() * returns last successful build result * */ -def retrieveLastBuildResult(RepositoryClient repositoryClient){ - +def retrieveLastBuildResult(){ + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() // get the last build result - def lastBuildResult = repositoryClient.getLastBuildResult(props.applicationBuildGroup, BuildResult.COMPLETE, BuildResult.CLEAN) + def lastBuildResult = metadataStore.getLastBuildResult(props.applicationBuildGroup, BuildResult.COMPLETE, BuildResult.CLEAN) if (lastBuildResult == null && props.topicBranchBuild){ // if this is the first topic branch build get the main branch build result if (props.verbose) println "** No previous successful topic branch build result. Retrieving last successful main branch build result." String mainBranchBuildGroup = "${props.application}-${props.mainBuildBranch}" - lastBuildResult = repositoryClient.getLastBuildResult(mainBranchBuildGroup, BuildResult.COMPLETE, BuildResult.CLEAN) + lastBuildResult = metadataStore.getLastBuildResult(mainBranchBuildGroup, BuildResult.COMPLETE, BuildResult.CLEAN) } if (lastBuildResult == null) { @@ -617,9 +601,9 @@ def generateDb2InfoRecord(String buildFile){ def validateDependencyFile(String buildFile, String depFilePath) { String[] allowedEncodings = ["UTF-8", "IBM-1047"] String[] reqDepFileProps = ["fileName", "isCICS", "isSQL", "isDLI", "isMQ", "dependencies", "schemaVersion"] - + depFilePath = getAbsolutePath(depFilePath) // Load dependency file and verify existance - File depFile = new File(getAbsolutePath(depFilePath)) + File depFile = new File(depFilePath) assert depFile.exists() : "*! Dependency file not found: ${depFile.getAbsolutePath()}" // Parse the JSON file @@ -642,7 +626,9 @@ def validateDependencyFile(String buildFile, String depFilePath) { assert depFileData."${depFileProp}" != null : "*! Missing required dependency file field '$depFileProp'" } // Validate depFileData.fileName == buildFile - assert getAbsolutePath(depFileData.fileName) == getAbsolutePath(buildFile) : "*! Dependency file mismatch: fileName does not match build file" + String buildFilePath = getAbsolutePath(buildFile) + String fileNamePath = getAbsolutePath(depFileData.fileName) + assert fileNamePath == buildFilePath : "*! Dependency file mismatch: The dependency file 'fileName' value does not match build file" return depFileData // return the parsed JSON object } @@ -704,29 +690,29 @@ def retrieveHFSFileEncoding(File file) { * Logs the resolution rules of the DependencyResolver in a table format * */ -def printResolutionRules(List rules) { +// def printResolutionRules(List rules) { - println("*** Configured resulution rules:") +// println("*** Configured resulution rules:") - // Print header of table - println(" " + "Library".padRight(10) + "Category".padRight(12) + "SourceDir/File".padRight(50) + "Directory".padRight(36) + "Collection".padRight(24) + "Archive".padRight(20)) - println(" " + " ".padLeft(10,"-") + " ".padLeft(12,"-") + " ".padLeft(50,"-") + " ".padLeft(36,"-") + " ".padLeft(24,"-") + " ".padLeft(20,"-")) - - // iterate over rules configured for the dependencyResolver - rules.each{ rule -> - searchPaths = rule.getSearchPath() - searchPaths.each { DependencyPath searchPath -> - def libraryName = (rule.getLibrary() != null) ? rule.getLibrary().padRight(10) : "N/A".padRight(10) - def categoryName = (rule.getCategory() != null) ? rule.getCategory().padRight(12) : "N/A".padRight(12) - def srcDir = (searchPath.getSourceDir() != null) ? searchPath.getSourceDir().padRight(50) : "N/A".padRight(50) - def directory = (searchPath.getDirectory() != null) ? searchPath.getDirectory().padRight(36) : "N/A".padRight(36) - def collection = (searchPath.getCollection() != null) ? searchPath.getCollection().padRight(24) : "N/A".padRight(24) - def archiveFile = (searchPath.getArchive() != null) ? searchPath.getArchive().padRight(20) : "N/A".padRight(20) - println(" " + libraryName + categoryName + srcDir + directory + collection + archiveFile) - - } - } -} +// // Print header of table +// println(" " + "Library".padRight(10) + "Category".padRight(12) + "SourceDir/File".padRight(50) + "Directory".padRight(36) + "Collection".padRight(24) + "Archive".padRight(20)) +// println(" " + " ".padLeft(10,"-") + " ".padLeft(12,"-") + " ".padLeft(50,"-") + " ".padLeft(36,"-") + " ".padLeft(24,"-") + " ".padLeft(20,"-")) + +// // iterate over rules configured for the dependencyResolver +// rules.each{ rule -> +// searchPaths = rule.getSearchPath() +// searchPaths.each { DependencyPath searchPath -> +// def libraryName = (rule.getLibrary() != null) ? rule.getLibrary().padRight(10) : "N/A".padRight(10) +// def categoryName = (rule.getCategory() != null) ? rule.getCategory().padRight(12) : "N/A".padRight(12) +// def srcDir = (searchPath.getSourceDir() != null) ? searchPath.getSourceDir().padRight(50) : "N/A".padRight(50) +// def directory = (searchPath.getDirectory() != null) ? searchPath.getDirectory().padRight(36) : "N/A".padRight(36) +// def collection = (searchPath.getCollection() != null) ? searchPath.getCollection().padRight(24) : "N/A".padRight(24) +// def archiveFile = (searchPath.getArchive() != null) ? searchPath.getArchive().padRight(20) : "N/A".padRight(20) +// println(" " + libraryName + categoryName + srcDir + directory + collection + archiveFile) + +// } +// } +// } /* * Logs information about the physical dependencies in a table format diff --git a/utilities/GitUtilities.groovy b/utilities/GitUtilities.groovy index d18b3e4a..407eec74 100644 --- a/utilities/GitUtilities.groovy +++ b/utilities/GitUtilities.groovy @@ -1,11 +1,11 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.* @Field BuildProperties props = BuildProperties.getInstance() -@Field RepositoryClient repositoryClient +@Field MetadataStore metadataStore /* * Tests if directory is in a local git repository @@ -25,7 +25,7 @@ def isGitDir(String dir) { if (gitError) { String warningMsg = "*? Warning executing isGitDir($dir). Git command: $cmd error: $gitError" println(warningMsg) - updateBuildResult(warningMsg:warningMsg,client:getRepositoryClient()) + updateBuildResult(warningMsg:warningMsg) } else if (gitResponse) { isGit = gitResponse.toString().trim().toBoolean() @@ -145,7 +145,7 @@ def getCurrentGitHash(String gitDir, boolean abbrev) { String errorMsg = "*! Error executing Git command: $cmd error: $gitError" println(errorMsg) props.error = "true" - updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + updateBuildResult(errorMsg:errorMsg) } return gitHash.toString().trim() } @@ -260,7 +260,7 @@ def getChangedFiles(String cmd) { String errorMsg = "*! Error executing Git command: $cmd error: $git_error \n *! Attempting to parse unstable git command for changed files..." println(errorMsg) props.error = "true" - updateBuildResult(errorMsg:errorMsg,client:getRepositoryClient()) + updateBuildResult(errorMsg:errorMsg) } for (line in git_diff.toString().split("\n")) { @@ -383,21 +383,22 @@ def getChangedProperties(String gitDir, String baseline, String currentHash, Str /** helper methods **/ -def getRepositoryClient() { - if (!repositoryClient && props."dbb.RepositoryClient.url") - repositoryClient = new RepositoryClient().forceSSLTrusted(true) - return repositoryClient +def getMetadataStore() { + if (!metadataStore) + metadataStore = MetadataStoreFactory.getMetadataStore() + return metadataStore } /* * updateBuildResult - for git cmd related issues */ def updateBuildResult(Map args) { - // args : errorMsg / warningMsg, client:repoClient + // args : errorMsg / warningMsg + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() // update build results only in non-userbuild scenarios - if (args.client && !props.userBuild) { - def buildResult = args.client.getBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) + if (metadataStore && !props.userBuild) { + def buildResult = metadataStore.getBuildResult(props.applicationBuildGroup, props.applicationBuildLabel) if (!buildResult) { println "*! No build result found for BuildGroup '${props.applicationBuildGroup}' and BuildLabel '${props.applicationBuildLabel}'" return @@ -412,7 +413,5 @@ def updateBuildResult(Map args) { // buildResult.setStatus(buildResult.WARNING) buildResult.addProperty("warning", args.warningMsg) } - // save result - buildResult.save() } } \ No newline at end of file diff --git a/utilities/ImpactUtilities.groovy b/utilities/ImpactUtilities.groovy index 569b94c8..372c51ae 100644 --- a/utilities/ImpactUtilities.groovy +++ b/utilities/ImpactUtilities.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import java.nio.file.FileSystems @@ -17,11 +17,9 @@ import java.util.regex.* @Field def resolverUtils -def createImpactBuildList(RepositoryClient repositoryClient) { - - // Conditionally load the ResolverUtilities.groovy which require at least DBB 1.1.2 - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { - resolverUtils = loadScript(new File("ResolverUtilities.groovy")) } +def createImpactBuildList() { + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() + resolverUtils = loadScript(new File("ResolverUtilities.groovy")) // local variables Set changedFiles = new HashSet() @@ -33,7 +31,7 @@ def createImpactBuildList(RepositoryClient repositoryClient) { boolean calculatedChanges = true // get the last build result to get the baseline hashes - def lastBuildResult = buildUtils.retrieveLastBuildResult(repositoryClient) + def lastBuildResult = buildUtils.retrieveLastBuildResult() // calculate changed files if (lastBuildResult || props.baselineRef) { @@ -50,7 +48,7 @@ def createImpactBuildList(RepositoryClient repositoryClient) { } // scan files and update source collection for impact analysis - updateCollection(changedFiles, deletedFiles, renamedFiles, repositoryClient) + updateCollection(changedFiles, deletedFiles, renamedFiles) if (calculatedChanges) { @@ -78,32 +76,9 @@ def createImpactBuildList(RepositoryClient repositoryClient) { List excludeMatchers = createPathMatcherPattern(props.excludeFileList) // list of impacts - def impacts - - if (props.useSearchConfiguration && props.useSearchConfiguration.toBoolean() && props.impactSearch && buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.2")) { // use new SearchPathDependencyResolver - - String impactSearch = props.getFileProperty('impactSearch', changedFile) - impacts = resolverUtils.findImpactedFiles(impactSearch, changedFile, repositoryClient) - } - else { - String impactResolutionRules = props.getFileProperty('impactResolutionRules', changedFile) - ImpactResolver impactResolver = createImpactResolver(changedFile, impactResolutionRules, repositoryClient) - - // Print impactResolverConfiguration - if (props.verbose && props.formatConsoleOutput && props.formatConsoleOutput.toBoolean()) { - // print collection information - println(" " + "Collection".padRight(20) ) - println(" " + " ".padLeft(20,"-")) - impactResolver.getCollections().each{ collectionName -> - println(" " + collectionName) - } - // print impact resolution rule in table format - buildUtils.printResolutionRules(impactResolver.getResolutionRules()) - } - - // resolving impacts - impacts = impactResolver.resolve() - } + String impactSearch = props.getFileProperty('impactSearch', changedFile) + def impacts = resolverUtils.findImpactedFiles(impactSearch, changedFile) + impacts.each { impact -> def impactFile = impact.getFile() @@ -151,7 +126,7 @@ def createImpactBuildList(RepositoryClient repositoryClient) { // create logical dependency and query collections for logical files with this dependency LogicalDependency lDependency = new LogicalDependency("$changedProp","BUILDPROPERTIES","PROPERTY") - logicalFileList = repositoryClient.getAllLogicalFiles(props.applicationCollectionName, lDependency) + logicalFileList = metadataStore.getCollection(props.applicationCollectionName).getLogicalFiles(lDependency) // get excludeListe @@ -195,7 +170,7 @@ def createImpactBuildList(RepositoryClient repositoryClient) { * */ -def createMergeBuildList(RepositoryClient repositoryClient){ +def createMergeBuildList(){ Set changedFiles = new HashSet() Set deletedFiles = new HashSet() Set renamedFiles = new HashSet() @@ -204,7 +179,7 @@ def createMergeBuildList(RepositoryClient repositoryClient){ (changedFiles, deletedFiles, renamedFiles, changedBuildProperties) = calculateChangedFiles(null) // scan files and update source collection - updateCollection(changedFiles, deletedFiles, renamedFiles, repositoryClient) + updateCollection(changedFiles, deletedFiles, renamedFiles) // iterate over changed file and add them to the buildSet @@ -461,7 +436,7 @@ def calculateChangedFiles(BuildResult lastBuildResult, boolean calculateConcurre * Scenario: Migrate Source to Git and scan against existing set of loadmodules. * Limitation: Sample for cobol */ -def scanOnlyStaticDependencies(List buildList, RepositoryClient repositoryClient){ +def scanOnlyStaticDependencies(List buildList){ buildList.each { buildFile -> def scriptMapping = ScriptMappings.getScriptName(buildFile) if(scriptMapping != null){ @@ -478,7 +453,7 @@ def scanOnlyStaticDependencies(List buildList, RepositoryClient repositoryClient if ((isLinkEdited && isLinkEdited.toBoolean()) || scriptMapping == "LinkEdit.groovy"){ try{ if (props.verbose) println ("*** Scanning load module $loadPDSMember of $buildFile") - saveStaticLinkDependencies(buildFile, props."${langPrefix}_loadPDS", logicalFile, repositoryClient) + saveStaticLinkDependencies(buildFile, props."${langPrefix}_loadPDS", logicalFile) } catch (com.ibm.dbb.build.ValidationException e){ println ("!* Error scanning output file for $buildFile : $loadPDSMember") @@ -503,11 +478,10 @@ def scanOnlyStaticDependencies(List buildList, RepositoryClient repositoryClient * * Invokes method generateConcurrentChangesReports to produce the reports * - * @param repositoryClient * @param buildSet * */ -def calculateConcurrentChanges(RepositoryClient repositoryClient, Set buildSet) { +def calculateConcurrentChanges(Set buildSet) { // initialize patterns List gitRefMatcherPatterns = createMatcherPatterns(props.reportConcurrentChangesGitBranchReferencePatterns) @@ -535,7 +509,7 @@ def calculateConcurrentChanges(RepositoryClient repositoryClient, Set bu (concurrentChangedFiles, concurrentRenamedFiles, concurrentDeletedFiles, concurrentBuildProperties) = calculateChangedFiles(null, true, gitReference) // generate reports and verify for intersects - generateConcurrentChangesReports(buildSet, concurrentChangedFiles, concurrentRenamedFiles, concurrentDeletedFiles, gitReference, repositoryClient) + generateConcurrentChangesReports(buildSet, concurrentChangedFiles, concurrentRenamedFiles, concurrentDeletedFiles, gitReference) } } @@ -546,7 +520,7 @@ def calculateConcurrentChanges(RepositoryClient repositoryClient, Set bu * Method to generate the Concurrent Changes reports and validate if the current build list intersects with concurrent changes */ -def generateConcurrentChangesReports(Set buildList, Set concurrentChangedFiles, Set concurrentRenamedFiles, Set concurrentDeletedFiles, String gitReference, RepositoryClient repositoryClient){ +def generateConcurrentChangesReports(Set buildList, Set concurrentChangedFiles, Set concurrentRenamedFiles, Set concurrentDeletedFiles, String gitReference){ String concurrentChangesReportLoc = "${props.buildOutDir}/report_concurrentChanges.txt" File concurrentChangesReportFile = new File(concurrentChangesReportLoc) @@ -573,9 +547,9 @@ def generateConcurrentChangesReports(Set buildList, Set concurre // update build result if (props.reportConcurrentChangesIntersectionFailsBuild && props.reportConcurrentChangesIntersectionFailsBuild.toBoolean()) { props.error = "true" - buildUtils.updateBuildResult(errorMsg:msg,client:repositoryClient) + buildUtils.updateBuildResult(errorMsg:msg) } else { - buildUtils.updateBuildResult(warningMsg:msg,client:repositoryClient) + buildUtils.updateBuildResult(warningMsg:msg) } } else @@ -595,9 +569,9 @@ def generateConcurrentChangesReports(Set buildList, Set concurre // update build result if (props.reportConcurrentChangesIntersectionFailsBuild && props.reportConcurrentChangesIntersectionFailsBuild.toBoolean()) { props.error = "true" - buildUtils.updateBuildResult(errorMsg:msg,client:repositoryClient) + buildUtils.updateBuildResult(errorMsg:msg) } else { - buildUtils.updateBuildResult(warningMsg:msg,client:repositoryClient) + buildUtils.updateBuildResult(warningMsg:msg) } } else @@ -617,9 +591,9 @@ def generateConcurrentChangesReports(Set buildList, Set concurre // update build result if (props.reportConcurrentChangesIntersectionFailsBuild && props.reportConcurrentChangesIntersectionFailsBuild.toBoolean()) { props.error = "true" - buildUtils.updateBuildResult(errorMsg:msg,client:repositoryClient) + buildUtils.updateBuildResult(errorMsg:msg) } else { - buildUtils.updateBuildResult(warningMsg:msg,client:repositoryClient) + buildUtils.updateBuildResult(warningMsg:msg) } } else @@ -635,7 +609,7 @@ def generateConcurrentChangesReports(Set buildList, Set concurre * Configured through reportExternalImpacts* build properties */ -def reportExternalImpacts(RepositoryClient repositoryClient, Set changedFiles){ +def reportExternalImpacts(Set changedFiles){ // query external collections to produce externalImpactList Map collectionImpactsSetMap = new HashMap() // @@ -645,6 +619,7 @@ def reportExternalImpacts(RepositoryClient repositoryClient, Set changed if (props.verbose) println("*** Running external impact analysis with file filter ${props.reportExternalImpactsAnalysisFileFilter} and collection patterns ${props.reportExternalImpactsCollectionPatterns} with analysis mode ${props.reportExternalImpactsAnalysisDepths}") + try { if (props.reportExternalImpactsAnalysisDepths == "simple" || props.reportExternalImpactsAnalysisDepths == "deep"){ @@ -671,7 +646,7 @@ def reportExternalImpacts(RepositoryClient repositoryClient, Set changed } if (externalImpactReportingList.size() != 0) { - (collectionImpactsSetMap, impactedFiles) = calculateLogicalImpactedFiles(externalImpactReportingList, changedFiles, collectionImpactsSetMap, repositoryClient, "***", "buildSet") + (collectionImpactsSetMap, impactedFiles) = calculateLogicalImpactedFiles(externalImpactReportingList, changedFiles, collectionImpactsSetMap, "***", "buildSet") // get impacted files of idenfied impacted files @@ -682,7 +657,7 @@ def reportExternalImpacts(RepositoryClient repositoryClient, Set changed } def impactsBin - (collectionImpactsSetMap, impactsBin) = calculateLogicalImpactedFiles(new ArrayList(impactedFiles), changedFiles, collectionImpactsSetMap, repositoryClient, "****", "impactSet") + (collectionImpactsSetMap, impactsBin) = calculateLogicalImpactedFiles(new ArrayList(impactedFiles), changedFiles, collectionImpactsSetMap, "****", "impactSet") } } @@ -720,7 +695,8 @@ def reportExternalImpacts(RepositoryClient repositoryClient, Set changed * Used to inspect dbb collections for potential impacts, sub-method to reportExternalImpacts */ -def calculateLogicalImpactedFiles(List fileList, Set changedFiles, Map collectionImpactsSetMap, RepositoryClient repositoryClient, String indentationMsg, String analysisMode) { +def calculateLogicalImpactedFiles(List fileList, Set changedFiles, Map collectionImpactsSetMap, String indentationMsg, String analysisMode) { + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() // local matchers to inspect files and collections List collectionMatcherPatterns = createMatcherPatterns(props.reportExternalImpactsCollectionPatterns) @@ -747,19 +723,13 @@ def calculateLogicalImpactedFiles(List fileList, Set changedFile if(logicalDependencies.size != 0) { // iterate over collections - repositoryClient.getAllCollections().each{ collection -> + metadataStore.getCollections().each{ collection -> String cName = collection.getName() if(matchesPattern(cName,collectionMatcherPatterns)){ // find matching collection names def Set externalImpactList = collectionImpactsSetMap.get(cName) ?: new HashSet() // query dbb web app for files with all logicalDependencies - def logicalImpactedFiles = repositoryClient.getAllImpactedFiles([cName], logicalDependencies); - - // API request unable to be processed - if (repositoryClient.getLastStatusCode() == 400 ) { - def exceptionMsg = "*!* (ImpactUtilities.calculateLogicalImpactedFiles) API to getAllImpactedFiles returned an error code (${repositoryClient.getLastStatusCode()}). Skipping calculation of external impacts. Please make sure the DBB Server is on 1.1.3 or later to be able to process the request." - throw new Exception(exceptionMsg) - } + def logicalImpactedFiles = metadataStore.getImpactedFiles([cName], logicalDependencies); logicalImpactedFiles.each{ logicalFile -> if (props.verbose) println("$indentationMsg Potential external impact found ${logicalFile.getLname()} (${logicalFile.getFile()}) in collection ${cName} ") @@ -789,41 +759,28 @@ def calculateLogicalImpactedFiles(List fileList, Set changedFile ] } -def createImpactResolver(String changedFile, String rules, RepositoryClient repositoryClient) { - if (props.verbose) println "*** Creating impact resolver for $changedFile with $rules rules" +def updateCollection(changedFiles, deletedFiles, renamedFiles) { - // create an impact resolver for the changed file - ImpactResolver resolver = new ImpactResolver().file(changedFile) - .collection(props.applicationCollectionName) - .collection(props.applicationOutputsCollectionName) - .repositoryClient(repositoryClient) - // add resolution rules - if (rules) - resolver.setResolutionRules(buildUtils.parseResolutionRules(rules)) - - return resolver -} - -def updateCollection(changedFiles, deletedFiles, renamedFiles, RepositoryClient repositoryClient) { - if (!repositoryClient) { - if (props.verbose) println "** Unable to update collections. No repository client." + if (!MetadataStoreFactory.metadataStoreExists()) { + if (props.verbose) println "** Unable to update collections. No Metadata Store." return } + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() if (props.verbose) println "** Updating collections ${props.applicationCollectionName} and ${props.applicationOutputsCollectionName}" //def scanner = new DependencyScanner() List logicalFiles = new ArrayList() List excludeMatchers = createPathMatcherPattern(props.excludeFileList) - verifyCollections(repositoryClient) + verifyCollections() // remove deleted files from collection deletedFiles.each { file -> // files in a collection are stored as relative paths from a source directory if (props.verbose) println "*** Deleting logical file for $file" logicalFile = buildUtils.relativizePath(file) - repositoryClient.deleteLogicalFile(props.applicationCollectionName, logicalFile) - repositoryClient.deleteLogicalFile(props.applicationOutputsCollectionName, logicalFile) + metadataStore.getCollection(props.applicationCollectionName).deleteLogicalFile(logicalFile) + metadataStore.getCollection(props.applicationOutputsCollectionName).deleteLogicalFile(logicalFile) } // remove renamed files from collection @@ -831,8 +788,8 @@ def updateCollection(changedFiles, deletedFiles, renamedFiles, RepositoryClient // files in a collection are stored as relative paths from a source directory if (props.verbose) println "*** Deleting renamed logical file for $file" logicalFile = buildUtils.relativizePath(file) - repositoryClient.deleteLogicalFile(props.applicationCollectionName, logicalFile) - repositoryClient.deleteLogicalFile(props.applicationOutputsCollectionName, logicalFile) + metadataStore.getCollection(props.applicationCollectionName).deleteLogicalFile(logicalFile) + metadataStore.getCollection(props.applicationOutputsCollectionName).deleteLogicalFile(logicalFile) } if (props.createTestcaseDependency && props.createTestcaseDependency.toBoolean() && changedFiles && changedFiles.size() > 1) { @@ -872,7 +829,7 @@ def updateCollection(changedFiles, deletedFiles, renamedFiles, RepositoryClient // find in local list of logical files first (batch processing) def testCaseFiles = logicalFiles.findAll{it.getLname().equals(sysTestDependency.getLname())} if (!testCaseFiles){ // alternate retrieve it from the collection - testCaseFiles = repositoryClient.getAllLogicalFiles(props.applicationCollectionName, sysTestDependency.getLname()).find{ + testCaseFiles = metadataStore.getCollection(props.applicationCollectionName).getLogicalFiles(sysTestDependency.getLname()).find{ it.getLanguage().equals("COB") } } @@ -890,7 +847,7 @@ def updateCollection(changedFiles, deletedFiles, renamedFiles, RepositoryClient } catch (Exception e) { String warningMsg = "***** Scanning failed for file $file (${props.workspace}/${file})" - buildUtils.updateBuildResult(warningMsg:warningMsg,client:getRepositoryClient()) + buildUtils.updateBuildResult(warningMsg:warningMsg) println(warningMsg) e.printStackTrace() @@ -904,9 +861,8 @@ def updateCollection(changedFiles, deletedFiles, renamedFiles, RepositoryClient // save logical files in batches of 500 to avoid running out of heap space if (logicalFiles.size() == 500) { if (props.verbose) - println "** Storing ${logicalFiles.size()} logical files in repository collection '$props.applicationCollectionName'" - repositoryClient.saveLogicalFiles(props.applicationCollectionName, logicalFiles); - if (props.verbose) println(repositoryClient.getLastStatus()) + println "** Storing ${logicalFiles.size()} logical files in MetadataStore collection '$props.applicationCollectionName'" + metadataStore.getCollection(props.applicationCollectionName).addLogicalFiles(logicalFiles) logicalFiles.clear() } } @@ -914,17 +870,18 @@ def updateCollection(changedFiles, deletedFiles, renamedFiles, RepositoryClient // save logical files if (props.verbose) - println "** Storing ${logicalFiles.size()} logical files in repository collection '$props.applicationCollectionName'" - repositoryClient.saveLogicalFiles(props.applicationCollectionName, logicalFiles); - if (props.verbose) println(repositoryClient.getLastStatus()) + println "** Storing ${logicalFiles.size()} logical files in MetadataStore collection '$props.applicationCollectionName'" + metadataStore.getCollection(props.applicationCollectionName).addLogicalFiles(logicalFiles) + } /* * saveStaticLinkDependencies - Scan the load module to determine LINK dependencies. Impact resolver can use * these to determine that this file gets rebuilt if a LINK dependency changes. */ -def saveStaticLinkDependencies(String buildFile, String loadPDS, LogicalFile logicalFile, RepositoryClient repositoryClient) { - if (repositoryClient) { +def saveStaticLinkDependencies(String buildFile, String loadPDS, LogicalFile logicalFile) { + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() + if (metadataStore) { LinkEditScanner scanner = new LinkEditScanner() if (props.verbose) println "*** Scanning load module for $buildFile" LogicalFile scannerLogicalFile = scanner.scan(buildUtils.relativizePath(buildFile), loadPDS) @@ -934,7 +891,7 @@ def saveStaticLinkDependencies(String buildFile, String loadPDS, LogicalFile log logicalFile.setLogicalDependencies(scannerLogicalFile.getLogicalDependencies()) // Store logical file and indirect dependencies to the outputs collection - repositoryClient.saveLogicalFile("${props.applicationOutputsCollectionName}", logicalFile ); + metadataStore.getCollection("${props.applicationOutputsCollectionName}").addLogicalFile( logicalFile ); } } @@ -943,9 +900,10 @@ def saveStaticLinkDependencies(String buildFile, String loadPDS, LogicalFile log * create or clone the collections. * Uses build properties */ -def verifyCollections(RepositoryClient repositoryClient) { - if (!repositoryClient) { - if (props.verbose) println "** Unable to verify collections. No repository client." +def verifyCollections() { + MetadataStore metadataStore = MetadataStoreFactory.getMetadataStore() + if (!metadataStore) { + if (props.verbose) println "** Unable to verify collections. No metadata store." return } @@ -953,37 +911,37 @@ def verifyCollections(RepositoryClient repositoryClient) { String mainOutputsCollectionName = "${props.application}-${props.mainBuildBranch}-outputs" // check source collection - if (!repositoryClient.collectionExists(props.applicationCollectionName)) { + if (!metadataStore.collectionExists(props.applicationCollectionName)) { if (props.topicBranchBuild) { - if (repositoryClient.collectionExists(mainCollectionName)) { - repositoryClient.copyCollection(mainCollectionName, props.applicationCollectionName) + if (metadataStore.collectionExists(mainCollectionName)) { + metadataStore.copyCollection(mainCollectionName, props.applicationCollectionName) if (props.verbose) println "** Cloned collection ${props.applicationCollectionName} from $mainCollectionName" } else { - repositoryClient.createCollection(props.applicationCollectionName) + metadataStore.createCollection(props.applicationCollectionName) if (props.verbose) println "** Created collection ${props.applicationCollectionName}" } } else { - repositoryClient.createCollection(props.applicationCollectionName) + metadataStore.createCollection(props.applicationCollectionName) if (props.verbose) println "** Created collection ${props.applicationCollectionName}" } } // check outputs collection - if (!repositoryClient.collectionExists(props.applicationOutputsCollectionName)) { + if (!metadataStore.collectionExists(props.applicationOutputsCollectionName)) { if (props.topicBranchBuild) { - if (repositoryClient.collectionExists(mainOutputsCollectionName)) { - repositoryClient.copyCollection("${mainOutputsCollectionName}", props.applicationOutputsCollectionName) + if (metadataStore.collectionExists(mainOutputsCollectionName)) { + metadataStore.copyCollection("${mainOutputsCollectionName}", props.applicationOutputsCollectionName) if (props.verbose) println "** Cloned collection ${props.applicationOutputsCollectionName} from $mainOutputsCollectionName" } else { - repositoryClient.createCollection(props.applicationOutputsCollectionName) + metadataStore.createCollection(props.applicationOutputsCollectionName) if (props.verbose) println "** Created collection ${props.applicationOutputsCollectionName}" } } else { - repositoryClient.createCollection(props.applicationOutputsCollectionName) + metadataStore.createCollection(props.applicationOutputsCollectionName) if (props.verbose) println "** Created collection ${props.applicationOutputsCollectionName}" } } diff --git a/utilities/ResolverUtilities.groovy b/utilities/ResolverUtilities.groovy index 4dee5aef..9fe55991 100644 --- a/utilities/ResolverUtilities.groovy +++ b/utilities/ResolverUtilities.groovy @@ -1,6 +1,6 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript import com.ibm.dbb.dependency.* -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.build.* import groovy.transform.* @@ -41,7 +41,7 @@ def createSearchPathDependencyResolver(String dependencySearch) { return new SearchPathDependencyResolver(dependencySearch) } -def findImpactedFiles(String impactSearch, String changedFile, RepositoryClient repositoryClient) { +def findImpactedFiles(String impactSearch, String changedFile) { List collections = new ArrayList() collections.add(props.applicationCollectionName) @@ -50,7 +50,7 @@ def findImpactedFiles(String impactSearch, String changedFile, RepositoryClient if (props.verbose) println ("*** Creating SearchPathImpactFinder with collections " + collections + " and impactSearch configuration " + impactSearch) - def finder = new SearchPathImpactFinder(impactSearch, collections, repositoryClient) + def finder = new SearchPathImpactFinder(impactSearch, collections) // Find all files impacted by the changed file impacts = finder.findImpactedFiles(changedFile, props.workspace) diff --git a/utilities/ScannerUtilities.groovy b/utilities/ScannerUtilities.groovy index 894bc0c5..ef1af344 100644 --- a/utilities/ScannerUtilities.groovy +++ b/utilities/ScannerUtilities.groovy @@ -1,5 +1,5 @@ @groovy.transform.BaseScript com.ibm.dbb.groovy.ScriptLoader baseScript -import com.ibm.dbb.repository.* +import com.ibm.dbb.metadata.* import com.ibm.dbb.dependency.* import com.ibm.dbb.build.* import groovy.transform.*