Skip to content

Commit

Permalink
Fix NPE when using dependency file (#230) (#231)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Jun 30, 2022
1 parent f078a66 commit af5ba44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
17 changes: 11 additions & 6 deletions languages/Cobol.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,14 @@ sortedList.each { buildFile ->
// Check if this a testcase
isZUnitTestCase = (props.getFileProperty('cobol_testcase', buildFile).equals('true')) ? true : false

// configure dependency resolution and create logical file
// configure appropriate dependency resolver
def dependencyResolver
LogicalFile logicalFile

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)
logicalFile = resolverUtils.createLogicalFile(dependencyResolver, buildFile)

} else { // use deprecated DependencyResolver
String rules = props.getFileProperty('cobol_resolutionRules', buildFile)
dependencyResolver = buildUtils.createDependencyResolver(buildFile, rules)
logicalFile = dependencyResolver.getLogicalFile()
}

// copy build file and dependency files to data sets
Expand All @@ -65,6 +60,16 @@ sortedList.each { buildFile ->
}else{
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()
}

// create mvs commands
String member = CopyToPDS.createMemberName(buildFile)
File logFile = new File( props.userBuild ? "${props.buildOutDir}/${member}.log" : "${props.buildOutDir}/${member}.cobol.log")
Expand Down
5 changes: 4 additions & 1 deletion utilities/BuildUtilities.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ 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
if (dependencyResolver && (dependencyResolver instanceof DependencyResolver))
dependencyResolver.setLogicalFile(lfile)

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

Expand Down

0 comments on commit af5ba44

Please sign in to comment.