Skip to content

Commit

Permalink
chore(build): Use Camel K runtime Maven structural logging module
Browse files Browse the repository at this point in the history
- Load and extract structural logging artifacts from Camel K runtime module
- Use logback configuration provided by this runtime module
- Add logging artifacts during Dockerfile image build
  • Loading branch information
christophd committed Jun 20, 2022
1 parent 9fba1db commit 118b825
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 71 deletions.
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN mkdir -p ${MAVEN_HOME} \
ADD build/_maven_output /tmp/artifacts/m2
ADD build/_kamelets /kamelets
COPY build/_maven_overlay/ /usr/share/maven/lib/
ADD build/logback.xml /usr/share/maven/conf/
ADD build/_maven_overlay/logback.xml /usr/share/maven/conf/

ENV MAVEN_OPTS="${MAVEN_OPTS} -Dlogback.configurationFile=/usr/share/maven/conf/logback.xml"

Expand Down
62 changes: 0 additions & 62 deletions build/logback.xml

This file was deleted.

2 changes: 1 addition & 1 deletion script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ check-platform:
# The below are dependencies needed for maven structured logs. We must bundle into the final container image.
maven-overlay:
mkdir -p build/_maven_overlay
./script/maven_overlay.sh build/_maven_overlay
./script/maven_overlay.sh $(RUNTIME_VERSION) build/_maven_overlay $(CAMEL_K_RUNTIME_DIR)

images: bundle-kamelets test maven-overlay
mkdir -p build/_maven_output
Expand Down
3 changes: 2 additions & 1 deletion script/bundle_kamelets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
# limitations under the License.

location=$(dirname $0)
rootdir=$location/../

set -e

repo=$1
branch=$2

cd $location/../
cd $rootdir
target=./build/_kamelets

# Always recreate the dir
Expand Down
53 changes: 47 additions & 6 deletions script/maven_overlay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,55 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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>]"
exit 1
fi

options=""
if [ "$CI" = "true" ]; then
options="--batch-mode"
fi

mvn -q $options dependency:get -Dartifact=ch.qos.logback:logback-core:1.2.3 -Ddest=$1
mvn -q $options dependency:get -Dartifact=ch.qos.logback:logback-classic:1.2.3 -Ddest=$1
mvn -q $options dependency:get -Dartifact=net.logstash.logback:logstash-logback-encoder:4.11 -Ddest=$1
mvn -q $options dependency:get -Dartifact=com.fasterxml.jackson.core:jackson-annotations:2.9.10 -Ddest=$1
mvn -q $options dependency:get -Dartifact=com.fasterxml.jackson.core:jackson-core:2.9.10 -Ddest=$1
mvn -q $options dependency:get -Dartifact=com.fasterxml.jackson.core:jackson-databind:2.9.10.8 -Ddest=$1
runtime_version=$1
output_dir=$2
local_runtime_dir=${3:-}

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
# 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
fi

unzip -q -o ${rootdir}/${output_dir}/camel-k-maven-logging.zip -d ${rootdir}/${output_dir}

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

0 comments on commit 118b825

Please sign in to comment.