From 7f4d92fa7b86adc274b386141f9d6979fa3dfa53 Mon Sep 17 00:00:00 2001 From: noys Date: Thu, 30 Nov 2023 11:17:58 +0200 Subject: [PATCH] :bug: Fixed warning created by go:embed files. --- .../jfrog/ide/common/go/GoScanWorkspaceCreator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/jfrog/ide/common/go/GoScanWorkspaceCreator.java b/src/main/java/com/jfrog/ide/common/go/GoScanWorkspaceCreator.java index e4960c3f..4d1442d1 100644 --- a/src/main/java/com/jfrog/ide/common/go/GoScanWorkspaceCreator.java +++ b/src/main/java/com/jfrog/ide/common/go/GoScanWorkspaceCreator.java @@ -1,5 +1,6 @@ package com.jfrog.ide.common.go; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.go.GoDriver; @@ -68,8 +69,17 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO Path targetGoMod = targetDir.resolve(sourceDir.relativize(file)); Files.copy(file, targetGoMod); goDriver.runCmd("run . -goModPath=" + targetGoMod.toAbsolutePath() + " -wd=" + sourceDir.toAbsolutePath(), true); + return FileVisitResult.CONTINUE; + } + // Skip .git, .idea and .vscode (deny list) directories. + if (StringUtils.containsAny(fileName, ".git", ".idea", ".vscode")) { + return FileVisitResult.SKIP_SUBTREE; } // Files other than go.mod and *.go files are not necessary to build the dependency tree of used Go packages. + // Therefore, we just create an empty file with the same name so go:embed files won't cause a missing file error. + if (!fileName.equals("go.sum")) { + Files.createFile(targetDir.resolve(sourceDir.relativize(file))); + } return FileVisitResult.CONTINUE; }