Skip to content

Commit

Permalink
CAMEL-21529: camel-catalog - Consider adding another version discover…
Browse files Browse the repository at this point in the history
…y step
  • Loading branch information
tdiesler committed Dec 10, 2024
1 parent e5a765c commit 89cae7b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
14 changes: 14 additions & 0 deletions catalog/camel-catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down Expand Up @@ -169,6 +175,14 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public synchronized String getVersion() {
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");
Expand All @@ -51,7 +51,29 @@ public synchronized String getVersion() {
}
}

// 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
## ---------------------------------------------------------------------------
version=@project.version@

0 comments on commit 89cae7b

Please sign in to comment.