diff --git a/pkg/cmd/util_commands.go b/pkg/cmd/util_commands.go index ccea1dea0..eb6133567 100644 --- a/pkg/cmd/util_commands.go +++ b/pkg/cmd/util_commands.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "os/exec" + "runtime" "strings" "github.com/apache/camel-k/pkg/util" @@ -49,7 +50,13 @@ func assembleClasspathArgValue(properties []string, dependencies []string, route classpathContents = append(classpathContents, properties...) classpathContents = append(classpathContents, routes...) classpathContents = append(classpathContents, dependencies...) - return strings.Join(classpathContents, ":") + + pathSeparator := ":" + if runtime.GOOS == "windows" { + pathSeparator = ";" + } + + return strings.Join(classpathContents, pathSeparator) } func assembleIntegrationRunCommand(ctx context.Context, properties []string, dependencies []string, routes []string, propertiesDir string, stdout, stderr io.Writer, local bool) (*exec.Cmd, error) { diff --git a/pkg/resources/resources_support.go b/pkg/resources/resources_support.go index 187350b2b..fb1921522 100644 --- a/pkg/resources/resources_support.go +++ b/pkg/resources/resources_support.go @@ -21,6 +21,7 @@ import ( "bytes" "io/ioutil" "path/filepath" + "runtime" "strings" "text/template" @@ -42,7 +43,7 @@ func Resource(name string) []byte { name = "/" + name } - file, err := assets.Open(name) + file, err := assets.Open(fixPath(name)) if err != nil { log.Error(err, "cannot access resource file", "file", name) return nil @@ -77,7 +78,7 @@ func TemplateResource(name string, params interface{}) (string, error) { // DirExists tells if a directory exists and can be listed for files func DirExists(dirName string) bool { - if _, err := assets.Open(dirName); err != nil { + if _, err := assets.Open(fixPath(dirName)); err != nil { return false } return true @@ -90,6 +91,8 @@ func ResourcesWithPrefix(pathPrefix string) []string { var res []string for _, path := range Resources(dirPath) { + path = fixPath(path) + if result, _ := filepath.Match(pathPrefix+"*", path); result { res = append(res, path) } @@ -100,7 +103,7 @@ func ResourcesWithPrefix(pathPrefix string) []string { // Resources lists all file names in the given path (starts with '/') func Resources(dirName string) []string { - dir, err := assets.Open(dirName) + dir, err := assets.Open(fixPath(dirName)) if err != nil { log.Error(err, "error while listing resource files", "dir", dirName) return nil @@ -128,3 +131,11 @@ func Resources(dirName string) []string { } return res } + +func fixPath(path string) string { + if runtime.GOOS == "windows" { + path = strings.ReplaceAll(path, "\\", "/") + } + + return path +}