davsclaus commented on code in PR #31188:
URL: https://github.com/apache/camel/pull/31188#discussion_r4756614596


##########
tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java:
##########
@@ -322,6 +326,30 @@ private Path getComponentClassesDirectory(Path 
componentRootDirectory) {
         return result;
     }
 
+    private static String extractArtifactId(Path componentRootDirectory) {
+        Path pom = componentRootDirectory.resolve("pom.xml");
+        if (Files.exists(pom)) {
+            try {
+                boolean inParent = false;
+                for (String line : Files.readAllLines(pom)) {
+                    if (line.contains("<parent>")) {
+                        inParent = true;
+                    } else if (line.contains("</parent>")) {
+                        inParent = false;
+                    } else if (!inParent) {
+                        String artifactId = Strings.between(line, 
"<artifactId>", "</artifactId>");
+                        if (artifactId != null) {
+                            return artifactId.trim();
+                        }
+                    }
+                }
+            } catch (IOException e) {

Review Comment:
   Addressed at 5624270: the IOException is now logged at debug.
   
   _Claude Code on behalf of davsclaus_



##########
tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java:
##########
@@ -322,6 +326,30 @@ private Path getComponentClassesDirectory(Path 
componentRootDirectory) {
         return result;
     }
 
+    private static String extractArtifactId(Path componentRootDirectory) {
+        Path pom = componentRootDirectory.resolve("pom.xml");
+        if (Files.exists(pom)) {
+            try {
+                boolean inParent = false;
+                for (String line : Files.readAllLines(pom)) {
+                    if (line.contains("<parent>")) {
+                        inParent = true;
+                    } else if (line.contains("</parent>")) {
+                        inParent = false;
+                    } else if (!inParent) {
+                        String artifactId = Strings.between(line, 
"<artifactId>", "</artifactId>");
+                        if (artifactId != null) {
+                            return artifactId.trim();
+                        }
+                    }
+                }
+            } catch (IOException e) {
+                // fallback
+            }
+        }
+        return componentRootDirectory.getFileName().toString();

Review Comment:
   Addressed at 5624270: PrepareCatalogMojoTest covers extractArtifactId (4 
cases, including a one-line <parent>).
   
   _Claude Code on behalf of davsclaus_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to