This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.8.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.8.x by this push:
new a4fe5bcae7e CAMEL-21529: camel-catalog - Consider adding another
version discovery step (#16508)
a4fe5bcae7e is described below
commit a4fe5bcae7e8f20ce03bad6cdd236a38b67c244e
Author: Thomas Diesler <[email protected]>
AuthorDate: Wed Dec 11 07:11:23 2024 +0100
CAMEL-21529: camel-catalog - Consider adding another version discovery step
(#16508)
---
catalog/camel-catalog/pom.xml | 14 ++++++++++++
.../org/apache/camel/catalog/VersionHelper.java | 26 ++++++++++++++++++++--
.../src/main/resources/META-INF/version.properties | 17 ++++++++++++++
3 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/catalog/camel-catalog/pom.xml b/catalog/camel-catalog/pom.xml
index 754d174d5da..3da1d0320ce 100644
--- a/catalog/camel-catalog/pom.xml
+++ b/catalog/camel-catalog/pom.xml
@@ -126,6 +126,12 @@
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
<plugins>
<!-- generate and include all components in the catalog -->
@@ -169,6 +175,14 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <configuration>
+ <delimiters>
+ <delimiter>@</delimiter>
+ </delimiters>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git
a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/VersionHelper.java
b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/VersionHelper.java
index c7f5b26ac6d..3a62aa26867 100644
---
a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/VersionHelper.java
+++
b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/VersionHelper.java
@@ -30,8 +30,8 @@ public class VersionHelper {
if (version != null) {
return version;
}
+ // First, try to load from maven properties
InputStream is = null;
- // try to load from maven properties first
try {
Properties p = new Properties();
is =
getClass().getResourceAsStream("/META-INF/maven/org.apache.camel/camel-catalog/pom.properties");
@@ -51,7 +51,29 @@ public class VersionHelper {
}
}
- // fallback to using Java API
+ // Next, try to load from version.properties
+ if (version == null) {
+ try {
+ Properties p = new Properties();
+ is =
getClass().getResourceAsStream("/META-INF/version.properties");
+ if (is != null) {
+ p.load(is);
+ version = p.getProperty("version", "");
+ }
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ // Fallback to using Java API
if (version == null) {
Package aPackage = getClass().getPackage();
if (aPackage != null) {
diff --git
a/catalog/camel-catalog/src/main/resources/META-INF/version.properties
b/catalog/camel-catalog/src/main/resources/META-INF/version.properties
new file mode 100644
index 00000000000..5749462de88
--- /dev/null
+++ b/catalog/camel-catalog/src/main/resources/META-INF/version.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
[email protected]@