Skip to content

Commit

Permalink
Hm
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagobento committed Oct 2, 2024
1 parent 954d8a8 commit a067801
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
49 changes: 39 additions & 10 deletions packages/kn-plugin-workflow/e2e-tests/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"bytes"
"fmt"
"io"
"io/fs"
"log"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package e2e_tests

import (
"fmt"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion packages/kn-plugin-workflow/e2e-tests/quarkus_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions packages/kn-plugin-workflow/e2e-tests/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions packages/sonataflow-quarkus-devui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<groupId>org.apache.kie.sonataflow</groupId>
<artifactId>sonataflow-quarkus-devui-parent</artifactId>
<version>${revision}</version>

<name>KIE Tools :: SonataFlow Quarkus Dev UI Extension</name>

Expand Down

0 comments on commit a067801

Please sign in to comment.