Skip to content

Commit

Permalink
Maybe fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagobento committed Oct 1, 2024
1 parent 8363fec commit 008b2ff
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 93 deletions.
45 changes: 29 additions & 16 deletions examples/drools-process-usertasks-quarkus-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,7 @@
<name>Kie-Tools Example :: Process with Usertasks Quarkus</name>
<description>Kogito user tasks orchestration - Quarkus</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
Expand Down Expand Up @@ -90,6 +74,35 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>kie-tools--maven-profile--1st-party-dependencies</id>
<activation>
<property>
<name>ignore--kie-tools--maven-profile--1st-party-dependencies</name>
<value>!true</value>
</property>
</activation>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
Expand Down
23 changes: 11 additions & 12 deletions examples/jbpm-compact-architecture-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@
<kogito.task-console.image>docker.io/apache/incubator-kie-kogito-task-console:main</kogito.task-console.image>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -150,6 +138,17 @@
<properties>
<quarkus.profile>dev</quarkus.profile>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
Expand Down
42 changes: 26 additions & 16 deletions examples/sonataflow-greeting-quarkus-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,7 @@
<name>KIE Tools Example :: SonataFlow Greeting :: Quarkus</name>
<description>SonataFlow Example - Quarkus</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.kie.sonataflow</groupId>
<artifactId>sonataflow-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.kie.sonataflow</groupId>
<artifactId>sonataflow-quarkus-devui</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kie.sonataflow</groupId>
<artifactId>sonataflow-quarkus</artifactId>
Expand Down Expand Up @@ -131,6 +115,32 @@
</plugins>
</build>
<profiles>
<profile>
<id>kie-tools--maven-profile--1st-party-dependencies</id>
<activation>
<property>
<name>ignore--kie-tools--maven-profile--1st-party-dependencies</name>
<value>!true</value>
</property>
</activation>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.kie.sonataflow</groupId>
<artifactId>sonataflow-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.kie.sonataflow</groupId>
<artifactId>sonataflow-quarkus-devui</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>container</id>
<activation>
Expand Down
40 changes: 29 additions & 11 deletions packages/dev-deployment-kogito-quarkus-blank-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-with-drools-quarkus</artifactId>
Expand Down Expand Up @@ -138,10 +131,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand All @@ -160,6 +149,35 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>kie-tools--maven-profile--1st-party-dependencies</id>
<activation>
<property>
<name>ignore--kie-tools--maven-profile--1st-party-dependencies</name>
<value>!true</value>
</property>
</activation>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-quarkus-devui</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<resources>
<resource>
Expand Down
22 changes: 22 additions & 0 deletions packages/kn-plugin-workflow/e2e-tests/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,28 @@ 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 {
fmt.Printf("Error creating .mvn directory. %v", err)
os.Exit(1)
}
}

absolutePath, 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 sonataflow-quarkus-devui package. %v", err)
os.Exit(1)
}
err = os.WriteFile(filepath.Join(projectDir, ".mvn", "maven.config"), []byte("-Dmaven.repo.local.tail=" + absolutePath + "\n"), 0644)
if err != nil {
fmt.Printf("Failed to create .mvn/maven.config file: %v", err)
os.Exit(1)
}
}

func AddSnapshotRepositoryDeclarationToPom(t *testing.T, projectDir string) {
VerifyFilesExist(t, projectDir, []string{"pom.xml"})
pomFilePath := filepath.Join(projectDir, "pom.xml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func RunQuarkusBuildTest(t *testing.T, cfgTestInputQuarkusCreate CfgTestInputQua

err = os.Chdir(projectDir)
require.NoErrorf(t, err, "Expected nil error, got %v", err)
WriteMavenConfigFileWithTailDirs(projectDir)

// Run `quarkus build` command
args := transformQuarkusBuildCmdCfgToArgs(test.input)
Expand Down
7 changes: 4 additions & 3 deletions packages/kn-plugin-workflow/e2e-tests/quarkus_convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ func RunQuarkusConvertTest(t *testing.T, cfgTestInputCreateConvert CfgTestInputC
projectName := GetCreateProjectName(t, cfgTestInputCreateConvert)
projectDir := filepath.Join(TempTestsPath, projectName)

// Create the project
RunCreateTest(t, cfgTestInputCreateConvert)

err = os.Chdir(projectDir)
require.NoErrorf(t, err, "Expected nil error, got %v", err)
WriteMavenConfigFileWithTailDirs(projectDir)

// Create the project
RunCreateTest(t, cfgTestInputCreateConvert)

// Run `quarkus convert` command
_, err = ExecuteKnWorkflowQuarkus(transformQuarkusConvertCmdCfgToArgs(t, test.input)...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func RunQuarkusCreateTest(t *testing.T, test CfgTestInputQuarkusCreate) string {
// Run `quarkus create` command
_, err = ExecuteKnWorkflowQuarkus(transformQuarkusCreateCmdCfgToArgs(test.input)...)
require.NoErrorf(t, err, "Expected nil error, got: %v", err)
WriteMavenConfigFileWithTailDirs(projectDir)

// Check if the project directory was created
require.DirExistsf(t, projectDir, "Expected project directory '%s' to be created", projectDir)
Expand Down
2 changes: 2 additions & 0 deletions packages/kn-plugin-workflow/e2e-tests/quarkus_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ 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)

cmd := exec.Command(KnExecutable)

Expand Down
3 changes: 3 additions & 0 deletions packages/kn-plugin-workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"test-e2e:quarkus": "run-script-if --ignore-errors \"$(build-env endToEndTests.ignoreFailures)\" --bool \"$(build-env endToEndTests.run)\" --then \"pnpm go:test-e2e:quarkus\" \"pnpm go:test-e2e:report\"",
"test-e2e:quarkus:logs": "run-script-if --ignore-errors \"$(build-env endToEndTests.ignoreFailures)\" --bool \"$(build-env endToEndTests.run)\" --then \"pnpm go:test-e2e:quarkus:logs\" \"pnpm go:test-e2e:report\""
},
"dependencies": {
"@kie-tools/sonataflow-quarkus-devui": "workspace:*"
},
"devDependencies": {
"@kie-tools/root-env": "workspace:*",
"@kie-tools/sonataflow-devmode-image": "workspace:*",
Expand Down
15 changes: 5 additions & 10 deletions packages/maven-config-setup-helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const DEFAULT_LOCAL_REPO = String(
})
).trim();

const BOOTSTRAP_CLI_ARGS = `--settings=${BOOTSTRAP_SETTINGS_XML_PATH}`;
const BOOTSTRAP_CLI_ARGS = `-P'!kie-tools--maven-profile--1st-party-dependencies' --settings=${BOOTSTRAP_SETTINGS_XML_PATH}`;

module.exports = {
/**
Expand Down Expand Up @@ -82,9 +82,7 @@ module.exports = {
* @returns A comma-separated string containing a flat list of absolute paths of local Maven repositories.
*/
buildTailFromPackageJson: (dirname) => {
const packageJson = require(path.resolve(dirname ?? ".", "package.json"));
const tail = deepResolveMavenLocalRepoTail(path.resolve("."), packageJson.name).join(",");
return tail;
return deepResolveMavenLocalRepoTail(path.resolve(dirname ?? ".")).join(",");
},

/**
Expand Down Expand Up @@ -171,9 +169,7 @@ module.exports = {
.map((l) => l.trim())
.join("\n");

const newMavenConfigString = `### Package-specific configuration${
originalMvnConfigString ? `\n${originalMvnConfigString}\n` : ``
}
const newMavenConfigString = `${originalMvnConfigString ? `\n${originalMvnConfigString}\n` : ``}
${trimmedMavenConfigString.trim()}`;

console.info(`[maven-config-setup-helper] Writing '${MVN_CONFIG_FILE_PATH}'...`);
Expand All @@ -183,22 +179,21 @@ ${trimmedMavenConfigString.trim()}`;
? ""
: `
#### Default configuration
${DEFAULT_MAVEN_CONFIG}`;

fs.writeFileSync(MVN_CONFIG_FILE_PATH, `${newMavenConfigString}${defaultMavenConfigString}`);
console.timeEnd(`[maven-config-setup-helper] Configuring Maven through .mvn/maven.config...`);
},
};

function deepResolveMavenLocalRepoTail(cwd, packageName) {
function deepResolveMavenLocalRepoTail(cwd) {
const packageJsonDependencies = require(path.resolve(cwd, "package.json")).dependencies ?? {};
return [
...new Set([
path.resolve(fs.realpathSync(cwd), "dist/1st-party-m2/repository"),
...Object.entries(packageJsonDependencies).flatMap(([depName, depVersion]) =>
depVersion === "workspace:*" // It's an internal package.
? deepResolveMavenLocalRepoTail(fs.realpathSync(cwd + "/node_modules/" + packageName), depName)
? deepResolveMavenLocalRepoTail(cwd + "/node_modules/" + depName)
: []
),
]),
Expand Down
Loading

0 comments on commit 008b2ff

Please sign in to comment.