You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/08/24 12:31:46 UTC
[camel-k] 01/02: chore(build): Use Camel K runtime Maven structural logging module
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit e8bebae595a9b1fd33f7475605a80d64d3845ba2
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Wed Jun 15 09:10:26 2022 +0200
chore(build): Use Camel K runtime Maven structural logging module
- 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
---
build/Dockerfile | 2 +-
build/logback.xml | 62 -----------------------------------------------
script/Makefile | 2 +-
script/bundle_kamelets.sh | 3 ++-
script/maven_overlay.sh | 53 +++++++++++++++++++++++++++++++++++-----
5 files changed, 51 insertions(+), 71 deletions(-)
diff --git a/build/Dockerfile b/build/Dockerfile
index b8d28551d..a70b843c2 100644
--- a/build/Dockerfile
+++ b/build/Dockerfile
@@ -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"
diff --git a/build/logback.xml b/build/logback.xml
deleted file mode 100644
index 04e3c9228..000000000
--- a/build/logback.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<!--
- 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.
--->
-<configuration>
- <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <!--
- This configuration tries to output the Maven build log in a way that is as close as possible the native k8s
- log output format.
- -->
- <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
- <providers>
- <logLevel>
- <fieldName>level</fieldName>
- </logLevel>
- <timestamp>
- <fieldName>ts</fieldName>
- <timeZone>UTC</timeZone>
- </timestamp>
- <loggerName>
- <fieldName>logger</fieldName>
- </loggerName>
- <message>
- <fieldName>msg</fieldName>
- </message>
- <callerData>
- <classFieldName>class</classFieldName>
- </callerData>
- <threadName>
- <fieldName>thread</fieldName>
- </threadName>
- <mdc/>
- <arguments>
- <includeNonStructuredArguments>false</includeNonStructuredArguments>
- </arguments>
- <logstashMarkers/>
- <stackTrace>
- <fieldName>stack</fieldName>
- <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
- <maxLength>4096</maxLength>
- <rootCauseFirst>false</rootCauseFirst>
- </throwableConverter>
- </stackTrace>
- </providers>
- </encoder>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="CONSOLE"/>
- </root>
-
-</configuration>
\ No newline at end of file
diff --git a/script/Makefile b/script/Makefile
index 0d6cc2668..f548595ee 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -379,7 +379,7 @@ check-platform:
maven-overlay:
@echo "####### Preparing maven dependencies bundle..."
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)
kamel-overlay:
@echo "####### Copying kamel CLI to output build directory..."
diff --git a/script/bundle_kamelets.sh b/script/bundle_kamelets.sh
index 057beff9f..66e7e1a81 100755
--- a/script/bundle_kamelets.sh
+++ b/script/bundle_kamelets.sh
@@ -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
diff --git a/script/maven_overlay.sh b/script/maven_overlay.sh
index e2fc6229b..2804f847d 100755
--- a/script/maven_overlay.sh
+++ b/script/maven_overlay.sh
@@ -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