Skip to content

Commit

Permalink
chore(build): Account for staging repository when loading Maven overl…
Browse files Browse the repository at this point in the history
…ay artifacts
  • Loading branch information
christophd committed Aug 24, 2022
1 parent 627d943 commit 2919a24
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 26 deletions.
2 changes: 1 addition & 1 deletion script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ check-platform:
maven-overlay:
@echo "####### Preparing maven dependencies bundle..."
mkdir -p build/_maven_overlay
./script/maven_overlay.sh $(RUNTIME_VERSION) build/_maven_overlay $(CAMEL_K_RUNTIME_DIR)
./script/maven_overlay.sh $(RUNTIME_VERSION) build/_maven_overlay $(STAGING_RUNTIME_REPO) $(CAMEL_K_RUNTIME_DIR)

kamel-overlay:
@echo "####### Copying kamel CLI to output build directory..."
Expand Down
91 changes: 66 additions & 25 deletions script/maven_overlay.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
Expand All @@ -19,7 +19,7 @@ location=$(dirname $0)
rootdir=$(realpath ${location}/../)

if [ "$#" -lt 2 ]; then
echo "usage: $0 <output directory> <Camel K runtime version> [<local Camel K runtime project directory>]"
echo "usage: $0 <Camel K runtime version> <output directory> [<staging repository>] [<local Camel K runtime project directory>]"
exit 1
fi

Expand All @@ -30,7 +30,45 @@ fi

runtime_version=$1
output_dir=$2
local_runtime_dir=${3:-}
staging_repo=${3:-}
local_runtime_dir=${4:-}

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
else
local_runtime_dir="${staging_repo}"
staging_repo=""
fi
fi


if [ -z "$local_runtime_dir" ]; then
mvn -q \
Expand All @@ -39,31 +77,34 @@ if [ -z "$local_runtime_dir" ]; then
-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
mv ${rootdir}/${output_dir}/camel-k-maven-logging-${runtime_version}.zip ${rootdir}/${output_dir}/camel-k-maven-logging.zip
else
# Take the dependencies from a local development environment
camel_k_runtime_source=$3
camel_k_runtime_source_version=$(mvn -f $camel_k_runtime_source/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)

if [ "$runtime_version" != "$camel_k_runtime_source_version" ]; then
echo "WARNING! You're building Camel K project using $runtime_version but trying to bundle dependencies from local Camel K runtime $camel_k_runtime_source_version"
fi

mvn -q \
$options \
-am \
-f $camel_k_runtime_source/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
# 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)

if [ "$runtime_version" != "$camel_k_runtime_source_version" ]; then
echo "WARNING! You're building Camel K project using $runtime_version but trying to bundle dependencies from local Camel K runtime $camel_k_runtime_source_version"
fi

mvn -q \
$options \
-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}

if [ -n "$staging_repo" ]; then
rm ${rootdir}/settings.xml
fi

rm ${rootdir}/${output_dir}/camel-k-maven-logging.zip

0 comments on commit 2919a24

Please sign in to comment.