From a0678010df017aa680e09f65ad06ede424c3e9b3 Mon Sep 17 00:00:00 2001 From: Tiago Bento Date: Wed, 2 Oct 2024 00:44:10 -0400 Subject: [PATCH] Hm --- .../e2e-tests/helper_test.go | 49 +++++++++++++++---- .../e2e-tests/quarkus_create_test.go | 3 ++ .../e2e-tests/quarkus_run_test.go | 2 +- .../kn-plugin-workflow/e2e-tests/run_test.go | 1 + packages/sonataflow-quarkus-devui/pom.xml | 1 + 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/packages/kn-plugin-workflow/e2e-tests/helper_test.go b/packages/kn-plugin-workflow/e2e-tests/helper_test.go index efef043a8be..d258fe143fa 100644 --- a/packages/kn-plugin-workflow/e2e-tests/helper_test.go +++ b/packages/kn-plugin-workflow/e2e-tests/helper_test.go @@ -25,6 +25,8 @@ import ( "bytes" "fmt" "io" + "io/fs" + "log" "os" "os/exec" "path/filepath" @@ -175,31 +177,58 @@ func CleanUpAndChdirTemp(t *testing.T) { func WriteMavenConfigFileWithTailDirs(projectDir string) { dirPath := filepath.Join(projectDir, ".mvn") - if _, err := os.Stat(dirPath); os.IsNotExist(err) { - err := os.Mkdir(dirPath, 0755) // Permissions: owner=rwx, group=rx, others=rx - if err != nil { + if _, err := os.Stat(dirPath); os.IsNotExist(err) { + err := os.Mkdir(dirPath, 0755) // Permissions: owner=rwx, group=rx, others=rx + if err != nil { fmt.Printf("Error creating .mvn directory. %v", err) os.Exit(1) - } - } + } + } - jbpmQuarkusDevUiM2, err := filepath.Abs("../../../node_modules/@kie-tools/sonataflow-quarkus-devui/dist/1st-party-m2/repository") + sonataflowQuarkusDevUiM2, err := filepath.Abs("../../../node_modules/@kie-tools/sonataflow-quarkus-devui/dist/1st-party-m2/repository") if err != nil { fmt.Printf("Failed to resolve absolute path for `@kie-tools/sonataflow-quarkus-devui` package. %v", err) os.Exit(1) - } + } mavenBaseM2, err := filepath.Abs("../../../node_modules/@kie-tools/maven-base/dist/1st-party-m2/repository") - if err != nil { + if err != nil { fmt.Printf("Failed to resolve absolute path for `@kie-tools/maven-base` package. %v", err) os.Exit(1) - } - err = os.WriteFile(filepath.Join(projectDir, ".mvn", "maven.config"), []byte("-Dmaven.repo.local.tail="+ mavenBaseM2 + "," + jbpmQuarkusDevUiM2 + "\n"), 0644) + } + + tail := mavenBaseM2 + "," + sonataflowQuarkusDevUiM2 + "\n" + fmt.Printf("Tail:" + tail) + + ListDirRecursively(mavenBaseM2) + ListDirRecursively(sonataflowQuarkusDevUiM2) + + err = os.WriteFile(filepath.Join(projectDir, ".mvn", "maven.config"), []byte("-Dmaven.repo.local.tail="+tail), 0644) if err != nil { fmt.Printf("Failed to create .mvn/maven.config file: %v", err) os.Exit(1) } } +func ListDirRecursively(absolutePath string) { + if _, err := os.Stat(absolutePath); os.IsNotExist(err) { + fmt.Println("Dir doesn't exist. " + absolutePath) + return + } + + // Walk through the directory and list files and directories + err := filepath.WalkDir(absolutePath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + fmt.Println(path) + return nil + }) + + if err != nil { + log.Fatal(err) + } +} + func AddSnapshotRepositoryDeclarationToPom(t *testing.T, projectDir string) { VerifyFilesExist(t, projectDir, []string{"pom.xml"}) pomFilePath := filepath.Join(projectDir, "pom.xml") diff --git a/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go b/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go index f7f063d9ae9..23aabd99c8f 100644 --- a/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go +++ b/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go @@ -23,6 +23,7 @@ package e2e_tests import ( "fmt" + "os" "path/filepath" "testing" @@ -108,6 +109,8 @@ func RunQuarkusCreateTest(t *testing.T, test CfgTestInputQuarkusCreate) string { // Run `quarkus create` command _, err = ExecuteKnWorkflowQuarkus(transformQuarkusCreateCmdCfgToArgs(test.input)...) + + err = os.Chdir(projectDir) require.NoErrorf(t, err, "Expected nil error, got: %v", err) WriteMavenConfigFileWithTailDirs(projectDir) diff --git a/packages/kn-plugin-workflow/e2e-tests/quarkus_run_test.go b/packages/kn-plugin-workflow/e2e-tests/quarkus_run_test.go index c969f03b912..f127d98575e 100644 --- a/packages/kn-plugin-workflow/e2e-tests/quarkus_run_test.go +++ b/packages/kn-plugin-workflow/e2e-tests/quarkus_run_test.go @@ -91,7 +91,7 @@ func RunQuarkusRunTest(t *testing.T, cfgTestInputPrepareQuarkusCreateRun CfgTest // Create and build the quarkus project projectName := RunQuarkusCreateTest(t, cfgTestInputPrepareQuarkusCreateRun) projectDir := filepath.Join(TempTestsPath, projectName) - + err = os.Chdir(projectDir) require.NoErrorf(t, err, "Expected nil error, got %v", err) WriteMavenConfigFileWithTailDirs(projectDir) diff --git a/packages/kn-plugin-workflow/e2e-tests/run_test.go b/packages/kn-plugin-workflow/e2e-tests/run_test.go index e190d163faf..f3f371b4b21 100644 --- a/packages/kn-plugin-workflow/e2e-tests/run_test.go +++ b/packages/kn-plugin-workflow/e2e-tests/run_test.go @@ -86,6 +86,7 @@ func RunRunTest(t *testing.T, cfgTestInputPrepareCreate CfgTestInputCreate, test projectName := GetCreateProjectName(t, cfgTestInputPrepareCreateRun) projectDir := filepath.Join(TempTestsPath, projectName) + err = os.Chdir(projectDir) require.NoErrorf(t, err, "Expected nil error, got %v", err) WriteMavenConfigFileWithTailDirs(projectDir) diff --git a/packages/sonataflow-quarkus-devui/pom.xml b/packages/sonataflow-quarkus-devui/pom.xml index bde74599d0a..cac8381adef 100644 --- a/packages/sonataflow-quarkus-devui/pom.xml +++ b/packages/sonataflow-quarkus-devui/pom.xml @@ -33,6 +33,7 @@ org.apache.kie.sonataflow sonataflow-quarkus-devui-parent + ${revision} KIE Tools :: SonataFlow Quarkus Dev UI Extension