This is an automated email from the ASF dual-hosted git repository.

ricardozanini pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 1780e46941c [sonataflow-builder-image] Fix #3168 - Add 
ADDITIONAL_DEPENDENCIES var to have optional libs in m2 (#3169)
1780e46941c is described below

commit 1780e46941cd0dbd932c442abc2170e8380220b7
Author: Ricardo Zanini <[email protected]>
AuthorDate: Wed Jun 11 13:23:47 2025 -0300

    [sonataflow-builder-image] Fix #3168 - Add ADDITIONAL_DEPENDENCIES var to 
have optional libs in m2 (#3169)
    
    Signed-off-by: Ricardo Zanini <[email protected]>
---
 .../sonataflow/builder/build-config/module.yaml    |  4 ++
 .../sonataflow/builder/runtime/added/build-app.sh  |  1 +
 .../tests/features/sonataflow-builder-2.feature    | 14 ------
 .../sonataflow-builder-static-checks.feature}      | 18 ++++----
 .../tests/features/sonataflow-builder.feature      | 19 +++++++-
 .../common/build/added/cleanup_project.sh          |  3 +-
 .../sonataflow/common/build/added/create-app.sh    | 50 ++++++++++++++++++----
 .../modules/sonataflow/common/build/module.yaml    | 16 ++++++-
 .../modules/sonataflow/common/scripts/module.yaml  |  6 ---
 9 files changed, 89 insertions(+), 42 deletions(-)

diff --git 
a/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/build-config/module.yaml
 
b/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/build-config/module.yaml
index 45bee2664c5..d2f877fd39f 100644
--- 
a/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/build-config/module.yaml
+++ 
b/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/build-config/module.yaml
@@ -26,3 +26,7 @@ envs:
     value: "false"
   - name: QUARKUS_EXTENSIONS
     value: 
smallrye-health,org.apache.kie.sonataflow:sonataflow-quarkus:${KOGITO_VERSION},org.kie:kie-addons-quarkus-knative-eventing:${KOGITO_VERSION},org.kie:kogito-addons-quarkus-microprofile-config-service-catalog:${KOGITO_VERSION},org.kie:kie-addons-quarkus-kubernetes:${KOGITO_VERSION},org.kie:kie-addons-quarkus-events-process:${KOGITO_VERSION},org.kie:kie-addons-quarkus-process-management:${KOGITO_VERSION},org.kie:kie-addons-quarkus-source-files:${KOGITO_VERSION},org.kie:kogito-add
 [...]
+    # When adding Quarkus extensions remember to also add the `deployment` 
counterpart of each dependency.
+    # This is required because they are not transitive dependencies, but added 
by Quarkus during the `quarkus-plugin` and built time execution.
+  - name: ADDITIONAL_DEPENDENCIES
+    value: 
org.kie:kie-addons-quarkus-persistence-jdbc:${KOGITO_VERSION},org.kie:kie-addons-quarkus-persistence-jdbc-deployment:${KOGITO_VERSION},io.quarkus:quarkus-jdbc-postgresql:${QUARKUS_PLATFORM_VERSION},io.quarkus:quarkus-jdbc-postgresql-deployment:${QUARKUS_PLATFORM_VERSION}
diff --git 
a/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/added/build-app.sh
 
b/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/added/build-app.sh
index 80fd578df63..384803d8349 100755
--- 
a/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/added/build-app.sh
+++ 
b/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/added/build-app.sh
@@ -68,5 +68,6 @@ cd ${KOGITO_HOME}/serverless-workflow-project
     -B \
     -s "${MAVEN_SETTINGS_PATH}" \
     -DskipTests \
+    -Dmaven.javadoc.skip=true \
     -Dquarkus.container-image.build=false \
     clean install
diff --git 
a/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder-2.feature
 
b/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder-2.feature
deleted file mode 100644
index 7cb7705d987..00000000000
--- 
a/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder-2.feature
+++ /dev/null
@@ -1,14 +0,0 @@
[email protected]/apache/incubator-kie-sonataflow-builder
-Feature: Serverless Workflow images common
-
-  Scenario: Verify if the swf and quarkus files are under 
/home/kogito/.m2/repository
-    When container is started with command bash
-    Then file /home/kogito/.m2/repository/io/quarkus/platform/quarkus-bom 
should exist and be a directory
-      And file 
/home/kogito/.m2/repository/org/apache/kie/sonataflow/sonataflow-quarkus/ 
should exist and be a directory
-
-  # This check should be enabled again once a similar check is done on runtimes
-  # to make sure we only have one version of quarkus bom ...
-  # See https://issues.redhat.com/browse/KOGITO-8555 to enable again
-  # Scenario: verify if there is no dependencies with multiple versions in 
/home/kogito/.m2/repository
-  #   When container is started with command bash
-  #   Then run sh -c 'ls /home/kogito/.m2/repository/io/quarkus/quarkus-bom  | 
wc -l' in container and immediately check its output for 1
diff --git 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/module.yaml
 
b/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder-static-checks.feature
similarity index 50%
copy from 
packages/sonataflow-image-common/resources/modules/sonataflow/common/build/module.yaml
copy to 
packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder-static-checks.feature
index 0dfa7fac8ee..b475319e5c0 100644
--- 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/module.yaml
+++ 
b/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder-static-checks.feature
@@ -1,4 +1,3 @@
-#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,12 +15,13 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-schema_version: 1
-name: org.kie.sonataflow.common.build
-version: "main"
-description: "Kogito Serverless Workflow image build process"
-
-# Requires org.kie.sonataflow.common.scripts module
[email protected]/apache/incubator-kie-sonataflow-builder
+Feature: SonataFlow Builder Static Checks
 
-execute:
-  - script: configure.sh
+  Scenario: Verify if the sonataflow and quarkus files are under 
/home/kogito/.m2/repository
+    When container is started with command bash
+    Then file /home/kogito/.m2/repository/io/quarkus/platform/quarkus-bom 
should exist and be a directory
+    And file 
/home/kogito/.m2/repository/org/apache/kie/sonataflow/sonataflow-quarkus/ 
should exist and be a directory
+    And file 
/home/kogito/.m2/repository/org/kie/kie-addons-quarkus-persistence-jdbc/ should 
exist and be a directory
+    And file /home/kogito/.m2/repository/io/quarkus/quarkus-agroal should 
exist and be a directory
+    And file /home/kogito/.m2/repository/io/quarkus/quarkus-jdbc-postgresql 
should exist and be a directory
diff --git 
a/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature
 
b/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature
index 728cb34f4e1..3b0ac708019 100644
--- 
a/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature
+++ 
b/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature
@@ -1,5 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
 @docker.io/apache/incubator-kie-sonataflow-builder
-Feature: Serverless Workflow builder images
+Feature: SonataFlow Builder Image Sanity Checks
 
   Scenario: Verify that the application is built and started correctly
     When container is started with command bash -c 
'/home/kogito/launch/build-app.sh && java -jar 
target/quarkus-app/quarkus-run.jar'
diff --git 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/cleanup_project.sh
 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/cleanup_project.sh
index f79d30bff4c..7cc43815783 100755
--- 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/cleanup_project.sh
+++ 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/cleanup_project.sh
@@ -33,8 +33,7 @@ rm -rfv "${PROJECT_ARTIFACT_ID}"/*.bak
 # Maven useless files
 # Needed to avoid Maven to automatically re-download from original Maven 
repository ...
 echo 'Clean Maven useless files'
-find "${KOGITO_HOME}"/.m2/repository -name _remote.repositories -type f -delete
-find "${KOGITO_HOME}"/.m2/repository -name _maven.repositories -type f -delete
+find "${KOGITO_HOME}"/.m2/repository -name '_*.repositories' -type f -delete
 find "${KOGITO_HOME}"/.m2/repository -name '*.lastUpdated' -type f -delete
 
 # Remove files that include build timestamps to have reproducible images
diff --git 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/create-app.sh
 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/create-app.sh
index 15655a143d4..f86ed97f0b7 100755
--- 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/create-app.sh
+++ 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/added/create-app.sh
@@ -124,21 +124,53 @@ if [ "${SCRIPT_DEBUG^^}" = "TRUE" ]; then
     cat pom.xml
 fi
 
-# we force the dependencies download beforehand, so we won't have problems 
when running or building our apps in offline mode
-# see:
-#   
https://quarkus.io/guides/maven-tooling#downloading-maven-artifact-dependencies-for-offline-development-and-testing
-#   
https://maven.apache.org/plugins/maven-dependency-plugin/go-offline-mojo.html
-"${MAVEN_CMD}" -B ${MAVEN_ARGS_APPEND} \
+cp "pom.xml" "pom.bak"
+
+if [ -n "${ADDITIONAL_DEPENDENCIES}" ]; then
+  echo "Adding additional dependencies (extensions): 
${ADDITIONAL_DEPENDENCIES}"
+  echo "${ADDITIONAL_DEPENDENCIES}" | tr ',' '\n' | \
+    xargs -n1 -I{} \
+      "${MAVEN_CMD}" \
+        -B ${MAVEN_ARGS_APPEND} \
+        -nsu \
+        -s "${MAVEN_SETTINGS_PATH}" \
+        quarkus:add-extension \
+        -Dextensions="{}"
+fi
+
+echo "Running Quarkus go-offline"
+"${MAVEN_CMD}" \
+  -B ${MAVEN_ARGS_APPEND} \
   -nsu \
-  -B \
   -s "${MAVEN_SETTINGS_PATH}" \
   -DskipTests=true \
   -Dmaven.javadoc.skip=true \
-  clean dependency:go-offline 
"${QUARKUS_PLATFORM_GROUPID}":quarkus-maven-plugin:"${QUARKUS_PLATFORM_VERSION}":go-offline
 install
+  
"${QUARKUS_PLATFORM_GROUPID}":quarkus-maven-plugin:"${QUARKUS_PLATFORM_VERSION}":go-offline
 
-# clean up
-"${MAVEN_CMD}" -B ${MAVEN_ARGS_APPEND} \
+echo "Running go-offline / resolve-plugins"
+"${MAVEN_CMD}" \
+  -B ${MAVEN_ARGS_APPEND} \
+  -nsu \
+  -s "${MAVEN_SETTINGS_PATH}" \
+  -DskipTests=true \
+  -Dmaven.javadoc.skip=true \
+  dependency:resolve-plugins \
+  dependency:go-offline
+
+echo "Running install"
+"${MAVEN_CMD}" \
+  -B ${MAVEN_ARGS_APPEND} \
   -nsu \
+  -s "${MAVEN_SETTINGS_PATH}" \
+  -DskipTests=true \
+  -Dmaven.javadoc.skip=true \
+  install
+
+# You can also remove target directories if you want a slimmer image:
+"${MAVEN_CMD}" \
   -B \
+  -nsu \
   -s "${MAVEN_SETTINGS_PATH}" \
   clean
+
+mv "pom.bak" "pom.xml"
\ No newline at end of file
diff --git 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/module.yaml
 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/module.yaml
index 0dfa7fac8ee..48a1f2564af 100644
--- 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/module.yaml
+++ 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/module.yaml
@@ -19,9 +19,23 @@
 schema_version: 1
 name: org.kie.sonataflow.common.build
 version: "main"
-description: "Kogito Serverless Workflow image build process"
+description: "SonataFlow image build process"
 
 # Requires org.kie.sonataflow.common.scripts module
 
+envs:
+  - name: QUARKUS_EXTENSIONS
+    example: 
"org.apache.kie.sonataflow:sonataflow-quarkus:${KOGITO_VERSION},org.kie:kie-addons-quarkus-knative-eventing:${KOGITO_VERSION}"
+    description: To add extensions to the SonataFlow application pom.xml file.
+  - name: QUARKUS_CREATE_ARGS
+    example: -DnoCode
+    description: To use only if you plan to use the 
${KOGITO_HOME}/launch/create-app.sh
+  - name: ADDITIONAL_DEPENDENCIES
+    example: org.kie:kie-addons-quarkus-persistence-jdbc:${KOGITO_VERSION}
+    description: |
+      Comma-separated list of additional dependencies to add to the image 
local Maven repository. 
+      These dependencies are NOT added to the SonataFlow application pom.xml 
file. 
+      The libraries will be available at the m2/repository directory.
+
 execute:
   - script: configure.sh
diff --git 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/module.yaml
 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/module.yaml
index 71aff5ad379..4abadb99aaf 100644
--- 
a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/module.yaml
+++ 
b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/module.yaml
@@ -22,9 +22,6 @@ version: "main"
 description: "SonataFlow images common scripts"
 
 envs:
-  - name: QUARKUS_EXTENSIONS
-    example: 
"org.apache.kie.sonataflow:sonataflow-quarkus:${KOGITO_VERSION},org.kie:kie-addons-quarkus-knative-eventing:${KOGITO_VERSION}"
-    description: To add extension to your application
   - name: PROJECT_GROUP_ID
     value: "org.acme"
     description: Please do not change. To change only if you plan to use the 
${KOGITO_HOME}/launch/create-app.sh
@@ -34,9 +31,6 @@ envs:
   - name: PROJECT_VERSION
     value: "1.0.0-SNAPSHOT"
     description: Please do not change. To change only if you plan to use the 
${KOGITO_HOME}/launch/create-app.sh
-  - name: QUARKUS_CREATE_ARGS
-    example: -DnoCode
-    description: To use only if you plan to use the 
${KOGITO_HOME}/launch/create-app.sh
   - name: QUARKUS_ADD_EXTENSION_ARGS
     description: To use only if you plan to use the 
${KOGITO_HOME}/launch/add-extension.sh
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to