Skip to content

Commit

Permalink
Resolve Merge Conflicts with 'main' Branch (#255)
Browse files Browse the repository at this point in the history
* Fix NPE when using dependency file (#230) (#231)

* move logical file creation after call to copySourceFiles

Signed-off-by: Luke Burgess <[email protected]>

* setting logical file in copySourceFiles

Signed-off-by: Luke Burgess <[email protected]>

* adding check for dependency resolver

Signed-off-by: Luke Burgess <[email protected]>

Co-authored-by: Luke Burgess <[email protected]>

Co-authored-by: Luke Burgess <[email protected]>
Co-authored-by: Luke Burgess <[email protected]>

* Merge Develop into main for zAppBuild v2.5.2 release (#252)

* Fix NPE when using dependency file (#230)

* move logical file creation after call to copySourceFiles

Signed-off-by: Luke Burgess <[email protected]>

* setting logical file in copySourceFiles

Signed-off-by: Luke Burgess <[email protected]>

* adding check for dependency resolver

Signed-off-by: Luke Burgess <[email protected]>

Co-authored-by: Luke Burgess <[email protected]>

* Assembler.groovy removal of hard coded library name (#237)

Signed-off-by: Dennis Behm <[email protected]>

* Skip unnecessary impact calculation on created full build list (#236)

* skip unnecessary impact calculation on generated full build list

Signed-off-by: Dennis Behm <[email protected]>

* Revised implementation of reporting of external impacts feature (#239)

* Revised implementation of reporting of external impacts

Signed-off-by: Dennis Behm <[email protected]>

* Revisions to Function Overview of Report External Impacts

Signed-off-by: Lauren Li <[email protected]>

* Handle case with back-level DBB server

Signed-off-by: Dennis Behm <[email protected]>

Signed-off-by: Dennis Behm <[email protected]>
Signed-off-by: Lauren Li <[email protected]>
Co-authored-by: Lauren Li <[email protected]>

Signed-off-by: Dennis Behm <[email protected]>
Signed-off-by: Lauren Li <[email protected]>
Co-authored-by: Luke Burgess <[email protected]>
Co-authored-by: Luke Burgess <[email protected]>
Co-authored-by: Dennis Behm <[email protected]>
Co-authored-by: Lauren Li <[email protected]>

* remove another merge conflict

* remove leftover RepositoryClient references after merge

Signed-off-by: Dennis Behm <[email protected]>
Signed-off-by: Lauren Li <[email protected]>
Co-authored-by: Dennis Behm <[email protected]>
Co-authored-by: Dan Bruce <[email protected]>
Co-authored-by: Luke Burgess <[email protected]>
Co-authored-by: Lauren Li <[email protected]>
  • Loading branch information
5 people authored Oct 17, 2022
1 parent cd70579 commit be55bdf
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 109 deletions.
39 changes: 12 additions & 27 deletions build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ println("\n** Build start at $props.startTime")
// initialize build
initializeBuildProcess(args)

// create build list and list of deletedFiles
// create build list
List<String> buildList = new ArrayList()
List<String> deletedFiles = new ArrayList()

(buildList, deletedFiles) = createBuildList()
buildList = createBuildList()

// build programs in the build list
def processCounter = 0
Expand Down Expand Up @@ -69,15 +68,6 @@ else {
}
}

// document deletions in build report
if (deletedFiles.size() != 0 && props.documentDeleteRecords && props.documentDeleteRecords.toBoolean()) {
println("** Document deleted files in Build Report.")
if (buildUtils.assertDbbBuildToolkitVersion(props.dbbToolkitVersion, "1.1.3")) {
buildReportUtils = loadScript(new File("utilities/BuildReportUtilities.groovy"))
buildReportUtils.processDeletedFilesList(deletedFiles)
}
}

// finalize build process
if (processCounter == 0)
processCounter = buildList.size()
Expand Down Expand Up @@ -599,24 +589,19 @@ def createBuildList() {
}

// Perform analysis and build report of external impacts
if (props.reportExternalImpacts && props.reportExternalImpacts.toBoolean() && metadataStore){

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(buildSet.plus(changedFiles))
}
else if(buildSet) {
println "** Perform analysis and reporting of external impacted files for the build list."
impactUtils.reportExternalImpacts(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 (metadataStore && props.reportConcurrentChanges && props.reportConcurrentChanges.toBoolean()){
if (props.reportConcurrentChanges && props.reportConcurrentChanges.toBoolean()){
println "** Calculate and document concurrent changes."
impactUtils.calculateConcurrentChanges(buildSet)
}
Expand All @@ -630,7 +615,7 @@ def createBuildList() {
}
}

return [buildList, deleteList]
return buildList
}


Expand Down
3 changes: 1 addition & 2 deletions languages/Assembler.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ def createAssemblerCommand(String buildFile, LogicalFile logicalFile, String mem
assembler.dd(new DDStatement().dsn(props.MODGEN).options("shr"))
if (buildUtils.isCICS(logicalFile))
assembler.dd(new DDStatement().dsn(props.SDFHMAC).options("shr"))
if (buildUtils.isSQL(logicalFile))
assembler.dd(new DDStatement().dsn("DBC0CFG.DB2.V12.SDSNSAMP").options("shr"))
//if (buildUtils.isSQL(logicalFile))
if (props.SDFSMAC)
assembler.dd(new DDStatement().dsn(props.SDFSMAC).options("shr"))

Expand Down
4 changes: 3 additions & 1 deletion utilities/BuildUtilities.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def copySourceFiles(String buildFile, String srcPDS, String dependencyDatasetMap
String lname = CopyToPDS.createMemberName(buildFile)
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
//dependencyResolver.setLogicalFile(lfile)

// get list of dependencies from userBuildDependencyFile
List<String> dependencyPaths = depFileData.dependencies

Expand Down
114 changes: 35 additions & 79 deletions utilities/ImpactUtilities.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def createImpactBuildList() {
Set<String> deletedFiles = new HashSet<String>()
Set<String> renamedFiles = new HashSet<String>()
Set<String> changedBuildProperties = new HashSet<String>()
Set<String> buildSet = new HashSet<String>()

boolean calculatedChanges = true

// get the last build result to get the baseline hashes
def lastBuildResult = buildUtils.retrieveLastBuildResult()
Expand All @@ -36,96 +39,49 @@ def createImpactBuildList() {
}
else {
// else create a fullBuild list
println "*! No prior build result located. Building all programs"
println "*! No prior build result located. Creating a full build list."
changedFiles = buildUtils.createFullBuildList()
buildSet = changedFiles

// skip impact calculation and return the generated build list
calculatedChanges = false
}

// scan files and update source collection for impact analysis
updateCollection(changedFiles, deletedFiles, renamedFiles)

// create build list using impact analysis
if (props.verbose) println "*** Perform impacted analysis for changed files."

Set<String> buildSet = new HashSet<String>()
Set<String> changedBuildPropertyFiles = new HashSet<String>()

PropertyMappings githashBuildableFilesMap = new PropertyMappings("githashBuildableFilesMap")


changedFiles.each { changedFile ->
// if the changed file has a build script then add to build list
if (ScriptMappings.getScriptName(changedFile)) {
buildSet.add(changedFile)
if (props.verbose) println "** Found build script mapping for $changedFile. Adding to build list"
}
if (calculatedChanges) {

// check if impact calculation should be performed, default true
if (shouldCalculateImpacts(changedFile)){
// create build list using impact analysis
if (props.verbose) println "*** Perform impacted analysis for changed files."

// perform impact analysis on changed file
if (props.verbose) println "** Performing impact analysis on changed file $changedFile"
PropertyMappings githashBuildableFilesMap = new PropertyMappings("githashBuildableFilesMap")

// get exclude list
List<PathMatcher> excludeMatchers = createPathMatcherPattern(props.excludeFileList)

// Get impacted files using the SearchPathImpactFinder
String impactSearch = props.getFileProperty('impactSearch', changedFile)
def impacts = resolverUtils.findImpactedFiles(impactSearch, changedFile)

impacts.each { impact ->
def impactFile = impact.getFile()
if (props.verbose) println "** Found impacted file $impactFile"
// only add impacted files that have a build script mapped to it
if (ScriptMappings.getScriptName(impactFile)) {
// only add impacted files, that are in scope of the build.
if (!matches(impactFile, excludeMatchers)){

// calculate abbreviated gitHash for impactFile
filePattern = FileSystems.getDefault().getPath(impactFile).getParent().toString()
if (filePattern != null && githashBuildableFilesMap.getValue(impactFile) == null) {
abbrevCurrentHash = gitUtils.getCurrentGitHash(buildUtils.getAbsolutePath(filePattern), true)
githashBuildableFilesMap.addFilePattern(abbrevCurrentHash, filePattern+"/*")
}

// add file to buildset
buildSet.add(impactFile)
if (props.verbose) println "** $impactFile is impacted by changed file $changedFile. Adding to build list."
}
else {
// impactedFile found, but on Exclude List
// Possible reasons: Exclude of file was defined after building the collection.
// Rescan/Rebuild Collection to synchronize it with defined build scope.
if (props.verbose) println "!! $impactFile is impacted by changed file $changedFile, but is on Exlude List. Not added to build list."
}
}
}

}else {
if (props.verbose) println "** Impact analysis for $changedFile has been skipped due to configuration."
}
}

// Perform impact analysis for property changes
if (props.impactBuildOnBuildPropertyChanges && props.impactBuildOnBuildPropertyChanges.toBoolean()){
if (props.verbose) println "*** Perform impacted analysis for property changes."

changedBuildProperties.each { changedProp ->

if (props.impactBuildOnBuildPropertyList.contains(changedProp.toString())){

// perform impact analysis on changed property
if (props.verbose) println "** Performing impact analysis on property $changedProp"
changedFiles.each { changedFile ->
// if the changed file has a build script then add to build list
if (ScriptMappings.getScriptName(changedFile)) {
buildSet.add(changedFile)
if (props.verbose) println "** Found build script mapping for $changedFile. Adding to build list"
}

// create logical dependency and query collections for logical files with this dependency
LogicalDependency lDependency = new LogicalDependency("$changedProp","BUILDPROPERTIES","PROPERTY")
logicalFileList = metadataStore.getCollection(props.applicationCollectionName).getLogicalFiles(lDependency)
// check if impact calculation should be performed, default true
if (shouldCalculateImpacts(changedFile)){

// perform impact analysis on changed file
if (props.verbose) println "** Performing impact analysis on changed file $changedFile"

// get excludeListe
// get exclude list
List<PathMatcher> excludeMatchers = createPathMatcherPattern(props.excludeFileList)

logicalFileList.each { logicalFile ->
def impactFile = logicalFile.getFile()
// list of impacts
String impactSearch = props.getFileProperty('impactSearch', changedFile)
def impacts = resolverUtils.findImpactedFiles(impactSearch, changedFile)


impacts.each { impact ->
def impactFile = impact.getFile()
if (props.verbose) println "** Found impacted file $impactFile"
// only add impacted files that have a build script mapped to it
if (ScriptMappings.getScriptName(impactFile)) {
Expand Down Expand Up @@ -991,12 +947,12 @@ def verifyCollections() {

}

/*
/*
* calculates the correct filepath from the git diff, due to different offsets in the directory path
* like nested projects, projects at root level, no root folder
*
*
* returns null if file not found + mustExist
*
*
* scenarios / mode
* 1 - Application projects are nested (e.q Mortgage in zAppBuild), Projects on Rootlevel
* 2 - Repository name is used as Application Root dir
Expand Down Expand Up @@ -1040,7 +996,7 @@ def fixGitDiffPath(String file, String dir, boolean mustExist, mode) {
if (mode==3 && !mustExist) return [fixedFileName, 3]

// Scenario 4:
// Repository name is used as application root directory and
// Repository name is used as application root directory and
// applicationSrcDirs is scoping the build scope by filtering on a subdirectory
// applicationSrcDirs=nazare-demo-genapp/src
fixedFileName = "${props.application}/$file"
Expand Down Expand Up @@ -1071,7 +1027,7 @@ def matches(String file, List<PathMatcher> pathMatchers) {

/**
* shouldCalculateImpacts
*
*
* Method to calculate if impact analysis should be performed for a changedFile in an impactBuild scenario
* returns a boolean - default true
*/
Expand Down

0 comments on commit be55bdf

Please sign in to comment.