You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2022/10/26 13:09:03 UTC

[camel-k] 05/07: fix(ci): bundle snapshot dependencies

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

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit d36451e9c7c5056362ee0bf0e75773e88be7087c
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Oct 24 16:55:26 2022 +0200

    fix(ci): bundle snapshot dependencies
---
 docs/modules/ROOT/pages/contributing/e2e.adoc |   4 +-
 script/Makefile                               |  31 ++------
 script/get_catalog.sh                         |   8 +-
 script/install_crc.sh                         |   2 +-
 script/install_minikube.sh                    |   2 +-
 script/maven_overlay.sh                       |  69 ++++-------------
 script/package_maven_artifacts.sh             | 106 +++++++++-----------------
 7 files changed, 65 insertions(+), 157 deletions(-)

diff --git a/docs/modules/ROOT/pages/contributing/e2e.adoc b/docs/modules/ROOT/pages/contributing/e2e.adoc
index e0992f8d5..c6dd3536b 100644
--- a/docs/modules/ROOT/pages/contributing/e2e.adoc
+++ b/docs/modules/ROOT/pages/contributing/e2e.adoc
@@ -44,11 +44,11 @@ make images
 
 The script will build the operator docker image and push it to the underlying docker daemon registry. At this stage, the cluster will be able to pickup this latest image when it executes the tests.
 
-You can also execute the following script, if by any chance you have some change applied to the `camel-k-runtime`. You can optionally point to your local Camel K runtime project directory if you need to install any SNAPSHOT dependency:
+You can also execute the following script, if by any chance you have some change applied to the `camel-k-runtime`. You can optionally point to your local Camel K runtime project directory if you need to install any local SNAPSHOT dependency:
 
 [source]
 ----
-make images-dev [CAMEL_K_RUNTIME_DIR=/path/to/camel-k-runtime-project]
+make images [CAMEL_K_RUNTIME_DIR=/path/to/camel-k-runtime-project]
 ----
 
 [[using-nexus]]
diff --git a/script/Makefile b/script/Makefile
index fe4f4fc46..de4932aa1 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -404,11 +404,17 @@ kamel-overlay:
 	cp kamel build/_output/bin
 
 images: build kamel-overlay maven-overlay bundle-kamelets
+ifneq (,$(findstring SNAPSHOT,$(RUNTIME_VERSION)))
+	./script/package_maven_artifacts.sh -s "$(STAGING_RUNTIME_REPO)" -d "$(CAMEL_K_RUNTIME_DIR)" $(RUNTIME_VERSION)
+endif
 	@echo "####### Building Camel K operator container image..."
 	mkdir -p build/_maven_output
 	docker build -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile .
 
 images-arch: build kamel-overlay maven-overlay bundle-kamelets
+ifneq (,$(findstring SNAPSHOT,$(RUNTIME_VERSION)))
+	./script/package_maven_artifacts.sh -s "$(STAGING_RUNTIME_REPO)" -d "$(CAMEL_K_RUNTIME_DIR)" $(RUNTIME_VERSION)
+endif
 	@echo "####### Building Camel K operator container image for multi architectures..."
 	mkdir -p build/_maven_output
 	docker buildx rm --all-inactive --force
@@ -423,25 +429,6 @@ ifeq ($(shell uname -m), arm64)
 	docker buildx build --platform=linux/amd64 -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile.arch .
 endif
 
-images-dev: build kamel-overlay maven-overlay bundle-kamelets package-artifacts
-	@echo "####### Building Camel K operator container development image..."
-	docker build -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile .
-
-images-arch-dev:  build kamel-overlay maven-overlay bundle-kamelets package-artifacts
-	@echo "####### Building Camel K operator container development image for multi architectures..."
-	docker buildx rm --all-inactive --force
-	docker buildx create --append --name builder
-ifeq ($(shell uname -m), x86_x64)
-	docker buildx build --platform=linux/amd64 -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile.arch .
-endif
-ifeq ($(shell uname -m), aarch64)
-	docker buildx build --platform=linux/arm64 -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile.arch .
-endif
-ifeq ($(shell uname -m), arm64)
-	mv kamel.linux.arm build/_output/bin/kamel
-	docker buildx build --platform=linux/amd64 -t $(CUSTOM_IMAGE):$(CUSTOM_VERSION) -f build/Dockerfile.arch .
-endif
-
 images-push:
 	docker push $(CUSTOM_IMAGE):$(CUSTOM_VERSION)
 
@@ -484,10 +471,6 @@ cross-compile:
 package-examples:
 	./script/package_examples.sh $(CUSTOM_VERSION)
 
-package-artifacts:
-	# useful for development purpose only in order to include any local development runtime dependency
-	./script/package_maven_artifacts.sh -s "$(STAGING_RUNTIME_REPO)" -d "$(CAMEL_K_RUNTIME_DIR)" $(RUNTIME_VERSION)
-
 release: clean codegen set-module-version set-version build-resources check-licenses build images images-push cross-compile package-examples git-tag
 
 release-staging: clean codegen set-module-version set-version build-resources check-licenses build images images-push-staging cross-compile package-examples git-tag
@@ -510,7 +493,7 @@ install-minikube:
 get-staging-repo:
 	@echo $(or ${STAGING_RUNTIME_REPO},https://repository.apache.org/content/repositories/snapshots@id=apache-snapshots@snapshots)
 
-.PHONY: do-build build build-kamel build-resources dep codegen images images-dev images-push images-push-staging test check test-integration clean release cross-compile package-examples set-version git-tag release-notes check-licenses generate-deepcopy generate-client generate-doc build-resources release-helm release-staging release-nightly get-staging-repo get-version build-submodules set-module-version bundle-kamelets generate-keda generate-strimzi
+.PHONY: do-build build build-kamel build-resources dep codegen images images-push images-push-staging test check test-integration clean release cross-compile package-examples set-version git-tag release-notes check-licenses generate-deepcopy generate-client generate-doc build-resources release-helm release-staging release-nightly get-staging-repo get-version build-submodules set-module-version bundle-kamelets generate-keda generate-strimzi
 .PHONY: controller-gen kubectl kustomize operator-sdk opm
 
 # find or download controller-gen if necessary
diff --git a/script/get_catalog.sh b/script/get_catalog.sh
index fe6487531..de279f8d2 100755
--- a/script/get_catalog.sh
+++ b/script/get_catalog.sh
@@ -36,16 +36,12 @@ fi
 rm -f ${rootdir}/resources/camel-catalog-*
 
 mvn -q dependency:copy -Dartifact="org.apache.camel.k:camel-k-catalog:$runtime_version:yaml:catalog" \
+  -D mdep.useBaseVersion=true \
   -DoutputDirectory=${rootdir}/resources/ \
   -s $location/maven-settings.xml \
   -Papache
+
 if [ -f "${rootdir}/resources/camel-k-catalog-${runtime_version}-catalog.yaml" ]; then
     mv ${rootdir}/resources/camel-k-catalog-"${runtime_version}"-catalog.yaml ${rootdir}/resources/camel-catalog-"${runtime_version}".yaml
-elif [[ $runtime_version == *"SNAPSHOT" ]]; then
-    # when using SNAPSHOT versions and a snapshot repository the downloaded artifact has a timestamp in place of the SNAPSHOT word
-    # we should replace this timestamp with the SNAPSHOT word
-    only_version=$(echo $runtime_version|sed 's/-SNAPSHOT//g')
-    cat_file=$(ls -lrt ${rootdir}/resources/camel-k-catalog-"${only_version}"*-catalog.yaml|tail -1|sed 's/.*resources\///g')
-    mv ${rootdir}/resources/$cat_file ${rootdir}/resources/camel-catalog-"${runtime_version}".yaml
 fi
 
diff --git a/script/install_crc.sh b/script/install_crc.sh
index 884c177c8..52255256e 100755
--- a/script/install_crc.sh
+++ b/script/install_crc.sh
@@ -31,7 +31,7 @@ if [ "$#" -ne 1 ]; then
     exit 1
 fi
 
-make images-dev
+make images
 
 # Tag image
 docker tag apache/camel-k:$1 default-route-openshift-image-registry.apps-crc.testing/$project/camel-k:$1
diff --git a/script/install_minikube.sh b/script/install_minikube.sh
index e9e1ff595..e8922467c 100755
--- a/script/install_minikube.sh
+++ b/script/install_minikube.sh
@@ -20,7 +20,7 @@
 set -e
 
 eval $(minikube docker-env)
-make images-dev
+make images
 
 # Perform installation
 ./kamel install
diff --git a/script/maven_overlay.sh b/script/maven_overlay.sh
index c8b25f571..4e84ce914 100755
--- a/script/maven_overlay.sh
+++ b/script/maven_overlay.sh
@@ -45,49 +45,13 @@ fi
 runtime_version=$1
 output_dir=$2
 
-if [ -n "$staging_repo" ]; then
-    if  [[ $staging_repo == http:* ]] || [[ $staging_repo == https:* ]]; then
-        options="${options} -s ${rootdir}/settings.xml"
-        cat << EOF > ${rootdir}/settings.xml
-<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
-  <profiles>
-    <profile>
-      <id>camel-k-staging</id>
-      <repositories>
-        <repository>
-          <id>camel-k-staging-releases</id>
-          <name>Camel K Staging</name>
-          <url>${staging_repo}</url>
-          <releases>
-            <enabled>true</enabled>
-            <updatePolicy>never</updatePolicy>
-          </releases>
-          <snapshots>
-            <enabled>false</enabled>
-          </snapshots>
-        </repository>
-      </repositories>
-    </profile>
-  </profiles>
-  <activeProfiles>
-    <activeProfile>camel-k-staging</activeProfile>
-  </activeProfiles>
-</settings>
-EOF
-    fi
+if [ ! -z $staging_repo ]; then
+  # Change the settings to include the staging repo if it's not already there
+  echo "INFO: updating the settings staging repository"
+  sed -i "s;<url>https://repository\.apache\.org/content/repositories/orgapachecamel-.*</url>;<url>$staging_repo</url>;" $location/maven-settings.xml
 fi
 
-
-if [ -z "$local_runtime_dir" ]; then
-    mvn -q \
-      $options \
-      dependency:copy \
-      -Dartifact=org.apache.camel.k:camel-k-maven-logging:${runtime_version}:zip \
-      -DoutputDirectory=${rootdir}/${output_dir}
-
-    mv ${rootdir}/${output_dir}/camel-k-maven-logging-${runtime_version}.zip ${rootdir}/${output_dir}/camel-k-maven-logging.zip
-else
+if [ ! -z "$local_runtime_dir" ]; then
     # Take the dependencies from a local development environment
     camel_k_runtime_source_version=$(mvn -f $local_runtime_dir/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
 
@@ -100,20 +64,17 @@ else
       -am \
       -f $local_runtime_dir/support/camel-k-maven-logging/pom.xml \
       install
-
-    mvn -q \
-      $options \
-      dependency:copy \
-      -Dartifact=org.apache.camel.k:camel-k-maven-logging:$camel_k_runtime_source_version:zip \
-      -DoutputDirectory=${rootdir}/${output_dir}
-
-    mv ${rootdir}/${output_dir}/camel-k-maven-logging-$camel_k_runtime_source_version.zip ${rootdir}/${output_dir}/camel-k-maven-logging.zip
 fi
 
-unzip -q -o ${rootdir}/${output_dir}/camel-k-maven-logging.zip -d ${rootdir}/${output_dir}
+mvn -q \
+  $options \
+  dependency:copy \
+  -Dartifact=org.apache.camel.k:camel-k-maven-logging:${runtime_version}:zip \
+  -D mdep.useBaseVersion=true \
+  -DoutputDirectory=${rootdir}/${output_dir} \
+  -Papache \
+  -s $location/maven-settings.xml
 
-if [ -n "$staging_repo" ]; then
-    rm ${rootdir}/settings.xml
-fi
+unzip -q -o ${rootdir}/${output_dir}/camel-k-maven-logging-${runtime_version}.zip -d ${rootdir}/${output_dir}
+rm -f camel-k-maven-logging-${runtime_version}.zip
 
-rm ${rootdir}/${output_dir}/camel-k-maven-logging.zip
diff --git a/script/package_maven_artifacts.sh b/script/package_maven_artifacts.sh
index 3b170bc8c..42d636f81 100755
--- a/script/package_maven_artifacts.sh
+++ b/script/package_maven_artifacts.sh
@@ -37,84 +37,52 @@ if [ "$#" -lt 1 ]; then
     exit 1
 fi
 
-options=""
-if [ "$CI" = "true" ]; then
-  options="--batch-mode"
-fi
-
 camel_k_destination="$PWD/build/_maven_output"
 camel_k_runtime_version=$1
+camel_k_project_pom_location=""
 maven_repo=${staging_repo:-https://repo1.maven.org/maven2}
 
-if [ -n "$staging_repo" ]; then
-    if  [[ $staging_repo == http:* ]] || [[ $staging_repo == https:* ]]; then
-        options="${options} -s ${rootdir}/settings.xml"
-        cat << EOF > ${rootdir}/settings.xml
-<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
-  <profiles>
-    <profile>
-      <id>camel-k-staging</id>
-      <repositories>
-        <repository>
-          <id>camel-k-staging-releases</id>
-          <name>Camel K Staging</name>
-          <url>${staging_repo}</url>
-          <releases>
-            <enabled>true</enabled>
-            <updatePolicy>never</updatePolicy>
-          </releases>
-          <snapshots>
-            <enabled>false</enabled>
-          </snapshots>
-        </repository>
-      </repositories>
-    </profile>
-  </profiles>
-  <activeProfiles>
-    <activeProfile>camel-k-staging</activeProfile>
-  </activeProfiles>
-</settings>
-EOF
-    fi
+if [ ! -z $staging_repo ]; then
+  # Change the settings to include the staging repo if it's not already there
+  echo "INFO: updating the settings staging repository"
+  sed -i "s;<url>https://repository\.apache\.org/content/repositories/orgapachecamel-.*</url>;<url>$staging_repo</url>;" $location/maven-settings.xml
 fi
 
 if [ -z "${local_runtime_dir}" ]; then
-    is_snapshot=$(echo "${camel_k_runtime_version}" | grep "SNAPSHOT")
-    if [ "$is_snapshot" = "${camel_k_runtime_version}" ]; then
-        echo "You're trying to package SNAPSHOT artifacts. You probably wants them from your local environment, try calling:"
-        echo "$0 <Camel K runtime version> <local Camel K runtime project directory>"
-        exit 3
-    fi
+  mvn -q dependency:copy \
+    -Dartifact="org.apache.camel.k:apache-camel-k-runtime:${camel_k_runtime_version}:zip:source-release" \
+    -D mdep.useBaseVersion=true \
+    -Papache \
+    -s $location/maven-settings.xml \
+    -DoutputDirectory=$PWD/build/.
+  unzip -q -o $PWD/build/apache-camel-k-runtime-${camel_k_runtime_version}-source-release.zip -d $PWD/build
+  rm $PWD/build/apache-camel-k-runtime-${camel_k_runtime_version}-source-release.zip
 
-    # Take the dependencies officially released
-    wget ${maven_repo}/org/apache/camel/k/apache-camel-k-runtime/${camel_k_runtime_version}/apache-camel-k-runtime-${camel_k_runtime_version}-source-release.zip -O $PWD/build/apache-camel-k-runtime-${camel_k_runtime_version}-source-release.zip
-    unzip -q -o $PWD/build/apache-camel-k-runtime-${camel_k_runtime_version}-source-release.zip -d $PWD/build
-    mvn -q \
-        $options \
-        -f $PWD/build/apache-camel-k-runtime-${camel_k_runtime_version}/pom.xml \
-        dependency:copy-dependencies \
-        -DincludeScope=runtime \
-        -Dmdep.copyPom=true \
-        -DoutputDirectory=$camel_k_destination \
-        -Dmdep.useRepositoryLayout=true
-    rm -rf $PWD/build/apache-camel-k-runtime*
+  camel_k_project_pom_location=$PWD/build/apache-camel-k-runtime-${camel_k_runtime_version}/pom.xml
 else
-    # Take the dependencies from a local development environment
-    camel_k_runtime_source=${local_runtime_dir}
-    camel_k_runtime_source_version=$(mvn $options -f $camel_k_runtime_source/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
+  # Take the dependencies from a local development environment
+  camel_k_runtime_source=${local_runtime_dir}
+  camel_k_runtime_source_version=$(mvn $options -f $camel_k_runtime_source/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
 
-    if [ "$camel_k_runtime_version" != "$camel_k_runtime_source_version" ]; then
-        echo "Misaligned version. You're building Camel K project using $camel_k_runtime_version but trying to bundle dependencies from local Camel K runtime $camel_k_runtime_source_version"
-        exit 2
-    fi
+  if [ "$camel_k_runtime_version" != "$camel_k_runtime_source_version" ]; then
+      echo "Misaligned version. You're building Camel K project using $camel_k_runtime_version but trying to bundle dependencies from local Camel K runtime $camel_k_runtime_source_version"
+      exit 2
+  fi
 
-    mvn -q \
-        $options \
-        -f $camel_k_runtime_source/pom.xml \
-    dependency:copy-dependencies \
-        -DincludeScope=runtime \
-        -Dmdep.copyPom=true \
-        -DoutputDirectory=$camel_k_destination \
-        -Dmdep.useRepositoryLayout=true
+  camel_k_project_pom_location=${local_runtime_dir}/pom.xml
 fi
+
+echo "Extracting Camel K runtime $camel_k_runtime_version dependencies... (may take some minutes to download)"
+mvn -q \
+  -f $camel_k_project_pom_location \
+  dependency:copy-dependencies \
+  -DincludeScope=runtime \
+  -Dmdep.copyPom=true \
+  -DoutputDirectory=$camel_k_destination \
+  -Dmdep.useRepositoryLayout=true \
+  -Papache \
+  -s $location/maven-settings.xml
+    
+if [ -z "${local_runtime_dir}" ]; then
+  rm -rf $PWD/build/apache-camel-k-runtime-${camel_k_runtime_version}
+fi 
\ No newline at end of file