This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 2120eecfad1 CAMEL-21043: Ensure generated camel-dependencies parent 
version is always in sync with the one used in org.apache.camel:camel
2120eecfad1 is described below

commit 2120eecfad1563c1c33c5ce83a38f0c807033984
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Mon Aug 5 13:18:03 2024 +0100

    CAMEL-21043: Ensure generated camel-dependencies parent version is always 
in sync with the one used in org.apache.camel:camel
---
 .../camel/maven/sync/properties/SyncPropertiesMojo.java    | 14 ++++++++++++++
 .../src/main/resources/camel-dependencies-template.xml     |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java
 
b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java
index 8e84d86fd0d..52f66cfff34 100644
--- 
a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java
+++ 
b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java
@@ -32,7 +32,9 @@ import java.util.stream.Stream;
 
 import org.apache.camel.tooling.util.FileUtil;
 import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -161,8 +163,20 @@ public class SyncPropertiesMojo extends AbstractMojo {
                 .sorted()
                 .collect(Collectors.joining("\n        "));
 
+        final Parent parent = camelPomXmlModel.getParent();
+        if (parent == null || !parent.getGroupId().equals("org.apache") || 
!parent.getArtifactId().equals("apache")) {
+            throw new MojoExecutionException("Unexpected parent groupId / 
artifactId in parent " + camelPomXmlPath);
+        }
+
+        final String apacheParentVersion = parent.getVersion();
+        if (ObjectHelper.isEmpty(apacheParentVersion)) {
+            throw new MojoExecutionException(
+                    "Unable to determine the version of org.apache:apache 
parent from " + camelPomXmlPath);
+        }
+
         try {
             final String camelPropertiesContent = template
+                    .replace("@apache-parent-version@", apacheParentVersion)
                     .replace("@version@", version)
                     .replace("@properties@", properties);
 
diff --git 
a/tooling/maven/sync-properties-maven-plugin/src/main/resources/camel-dependencies-template.xml
 
b/tooling/maven/sync-properties-maven-plugin/src/main/resources/camel-dependencies-template.xml
index e1722a6a692..09e895c7565 100644
--- 
a/tooling/maven/sync-properties-maven-plugin/src/main/resources/camel-dependencies-template.xml
+++ 
b/tooling/maven/sync-properties-maven-plugin/src/main/resources/camel-dependencies-template.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache</groupId>
         <artifactId>apache</artifactId>
-        <version>30</version>
+        <version>@apache-parent-version@</version>
         <relativePath />
     </parent>
 

Reply via email to