Fixing GoPackager
@@ -29,6 +29,7 @@ import com.blackducksoftware.integration.hub.packman.util.FileFinder
import com.blackducksoftware.integration.hub.packman.util.ProjectInfoGatherer
import com.blackducksoftware.integration.hub.packman.util.executable.Executable
import com.blackducksoftware.integration.hub.packman.util.executable.ExecutableRunner
+import com.blackducksoftware.integration.hub.packman.util.executable.ExecutableRunnerException
import com.google.gson.Gson
@Component
@@ -60,9 +61,11 @@ class GoPackager {
def children = new ArrayList<DependencyNode>()
goDirectories.each {
String goDepContents = getGoDepContents(it, goExecutable)
+ if(goDepContents?.trim()){
DependencyNode child = goDepParser.parseGoDep(goDepContents)
children.add(child)
}
+ }
if (packmanProperties.getGoAggregate()) {
root.children = children
return [root]
@@ -75,16 +78,20 @@ class GoPackager {
def vendorDirectory = new File(goDirectory, "vendor")
def goDepsDirectory = new File(goDirectory, "Godeps")
def goDepsFile = new File(goDepsDirectory, "Godeps.json")
- boolean previousGodepsFile = goDepsFile.exists()
+ if (goDepsFile.exists()) {
+ return goDepsFile.text
+ }
boolean previousVendorFile = vendorDirectory.exists()
- if (!previousGodepsFile) {
+ def goDepContents = null
+ try{
logger.info("Running ${goExecutable} save on path ${goDirectory.getAbsolutePath()}")
Executable executable = new Executable(goDirectory, goExecutable, ['save'])
executableRunner.executeLoudly(executable)
+ } catch (ExecutableRunnerException e){
+ logger.error("Failed to run ${goExecutable} save on path ${goDirectory.getAbsolutePath()}, ${e.getMessage().trim()}")
}
- def goDepContents = goDepsFile.text
- if(!previousGodepsFile){
- // We dont want to delete the Godeps directory if we didnt create it with the save command
+ if (goDepsFile.exists()) {
+ goDepContents = goDepsFile.text
FileUtils.deleteDirectory(goDepsDirectory)
}
if (!previousVendorFile && vendorDirectory.exists()) {
