From e9dccf7d625f89642254f512a8a4eaf4f8d3531d Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Mon, 12 Oct 2026 14:14:13 +0200 Subject: [PATCH] CAMEL-25587: camel-jbang - remove the route-parser plugin, use camel cmd route-structure instead camel cmd route-structure prints the structure of the routes of a Java source read with the Java DSL parser (CAMEL-25565), and of YAML and XML sources, so the route-parser plugin (camel-route-parser / Roaster) is removed. Co-Authored-By: Claude Opus 5.5 (1M context) Signed-off-by: Claus Ibsen --- bom/camel-bom/pom.xml | 5 - coverage/pom.xml | 5 - .../pages/camel-4x-upgrade-guide-4_24.adoc | 7 + .../ROOT/pages/camel-jbang-projects.adoc | 1 - .../jbang-commands/camel-jbang-commands.adoc | 1 - .../camel-jbang-route-parser.adoc | 29 ---- .../dsl/jbang/core/common/PluginType.java | 1 - .../camel-jbang-plugin-route-parser/pom.xml | 78 ---------- .../camel-jbang-plugin-commands-metadata.json | 5 - .../camel-jbang-plugin-route-parser | 2 - .../core/commands/parser/ParserPlugin.java | 32 ---- .../commands/parser/RouteParserCommand.java | 143 ------------------ dsl/camel-jbang/camel-launcher/pom.xml | 1 - dsl/camel-jbang/pom.xml | 1 - parent/pom.xml | 5 - 15 files changed, 7 insertions(+), 309 deletions(-) delete mode 100644 docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-route-parser.adoc delete mode 100644 dsl/camel-jbang/camel-jbang-plugin-route-parser/pom.xml delete mode 100644 dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json delete mode 100644 dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-route-parser delete mode 100644 dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/ParserPlugin.java delete mode 100644 dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/RouteParserCommand.java diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index b4e1ad15837a4..c172734deeacf 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -1362,11 +1362,6 @@ camel-jbang-plugin-kubernetes 4.23.0-SNAPSHOT - - org.apache.camel - camel-jbang-plugin-route-parser - 4.23.0-SNAPSHOT - org.apache.camel camel-jbang-plugin-test diff --git a/coverage/pom.xml b/coverage/pom.xml index 57bee44e6586c..eb720c6376933 100644 --- a/coverage/pom.xml +++ b/coverage/pom.xml @@ -2512,11 +2512,6 @@ camel-jbang-plugin-kubernetes ${project.version} - - org.apache.camel - camel-jbang-plugin-route-parser - ${project.version} - org.apache.camel camel-jbang-plugin-test diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc index 94a6e53532290..60ebcf049b213 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc @@ -67,3 +67,10 @@ camel-route-parser (Roaster). XML routes are read as before. The parser reads ev file, including those of a route builder created inside a test, so `validate` can find and validate endpoints it did not see before. An endpoint uri that is only a method call, such as `from(inboxQueue())`, is not validated (it was validated as a property placeholder without a component before); with `logUnparseable=true` it is logged. + +=== camel-jbang - the route-parser plugin is removed + +The `route-parser` plugin (`camel route-parser`) and its `camel-jbang-plugin-route-parser` artifact are removed. Use +`camel cmd route-structure MyRoute.java` instead: it prints the structure of the routes of a Java source, read +without compiling it, and of YAML and XML sources too. If you installed the plugin, remove it with +`camel plugin delete route-parser`. diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc index 753c1121f5e6c..63272ef00c98a 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc @@ -241,7 +241,6 @@ The plugins of the Apache Camel project: | tui | `camel tui`: the xref:camel-jbang-tui.adoc[Camel TUI] | mcp | `camel mcp`: the xref:camel-jbang-mcp.adoc[Camel MCP Server] | edit | `camel edit`: edit a Camel file in the terminal with suggestions and diagnostics -| route-parser | `camel route-parser`: parse Java routes and dump their structure |=== Plugins bundled with the CLI, such as `tui`, are installed on first use. diff --git a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc index 304f8d109ecd3..ad5934d6c6997 100644 --- a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc +++ b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc @@ -63,7 +63,6 @@ These commands are provided by plugins. A plugin is installed with `camel plugin | xref:jbang-commands/camel-jbang-generate.adoc[camel generate] | `generate` | Generate source code | xref:jbang-commands/camel-jbang-kubernetes.adoc[camel kubernetes] | `kubernetes` | Manage Camel applications running on Kubernetes | xref:jbang-commands/camel-jbang-mcp.adoc[camel mcp] | `mcp` | MCP server for AI coding assistants -| xref:jbang-commands/camel-jbang-route-parser.adoc[camel route-parser] | `route-parser` | Parses Java route and dumps route structure | xref:jbang-commands/camel-jbang-test.adoc[camel test] | `test` | Manage tests for Camel applications | xref:jbang-commands/camel-jbang-tui.adoc[camel tui] | `tui` | Camel TUI | xref:jbang-commands/camel-jbang-validate.adoc[camel validate] | `validate` | Validate Camel source code diff --git a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-route-parser.adoc b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-route-parser.adoc deleted file mode 100644 index 2986dc5c5e73c..0000000000000 --- a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-route-parser.adoc +++ /dev/null @@ -1,29 +0,0 @@ - -// AUTO-GENERATED by camel-package-maven-plugin - DO NOT EDIT THIS FILE -= camel route-parser - -Parses Java route and dumps route structure - -NOTE: This command is provided by the `route-parser` plugin. Install it with `camel plugin add route-parser`. - - -== Usage - -[source,bash] ----- -camel route-parser [options] ----- - - - -== Options - -[cols="2,5,1,2",options="header"] -|=== -| Option | Description | Default | Type -| `--raw` | To output raw without metadata | | boolean -| `--watch` | Execute periodically and showing output fullscreen | | boolean -| `-h,--help` | Display the help and sub-commands | | boolean -|=== - - diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java index 997214bd8841c..fe6ebd313ccb5 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginType.java @@ -28,7 +28,6 @@ public enum PluginType { GENERATE("generate", "generate", "Generate code such as DTOs", "4.8.0", null, "ASF"), EDIT("edit", "edit", "Edit Camel files with suggestions", "4.12.0", null, "ASF"), TEST("test", "test", "Manage tests for Camel applications", "4.14.0", null, "ASF"), - ROUTE_PARSER("route-parser", "route-parser", "Parses Java route and dumps route structure", "4.17.0", null, "ASF"), VALIDATE("validate", "validate", "Validate Camel routes", "4.18.0", null, "ASF"), MCP("mcp", "mcp", "MCP server for AI coding assistants", "4.21.0", null, "ASF"), TUI("tui", "tui", "Camel Dashboard", "4.20.0", null, "ASF"); diff --git a/dsl/camel-jbang/camel-jbang-plugin-route-parser/pom.xml b/dsl/camel-jbang/camel-jbang-plugin-route-parser/pom.xml deleted file mode 100644 index 641fc277d4d11..0000000000000 --- a/dsl/camel-jbang/camel-jbang-plugin-route-parser/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - 4.0.0 - - - org.apache.camel - camel-jbang-parent - 4.23.0-SNAPSHOT - ../pom.xml - - - camel-jbang-plugin-route-parser - - Camel :: JBang :: Plugin :: Route Parser - Camel CLI Route Parser - - - 4.17.0 - - Stable - false - - - - - org.apache.camel - camel-jbang-core - - - org.apache.camel - camel-route-parser - - - org.jboss.forge.roaster - roaster-jdt - ${roaster-version} - - - - - - - - org.apache.camel - camel-package-maven-plugin - - - prepare-jbang-commands - - prepare-jbang-commands - prepare-jbang-commands-doc - - process-classes - - - - - - diff --git a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json b/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json deleted file mode 100644 index 8c9c1d0ea4b65..0000000000000 --- a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "commands": [ - { "name": "route-parser", "fullName": "route-parser", "description": "Parses Java route and dumps route structure", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.parser.RouteParserCommand", "plugin": "route-parser", "options": [ { "names": "--raw", "description": "To output raw without metadata", "javaType": "boolean", "type": "boolean" }, { "names": "--watch", "description": "Execute periodically and showing output fullscreen", "javaType": "boolean", "type": "boolean" }, { "names": "-h,--help", "description": "Display the help and sub-commands", "javaType": "boolean", "type": "boolean" } ] } - ] -} diff --git a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-route-parser b/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-route-parser deleted file mode 100644 index f89c31e6b57de..0000000000000 --- a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/generated/resources/META-INF/services/org/apache/camel/camel-jbang-plugin/camel-jbang-plugin-route-parser +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.dsl.jbang.core.commands.parser.ParserPlugin diff --git a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/ParserPlugin.java b/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/ParserPlugin.java deleted file mode 100644 index c6608535b4482..0000000000000 --- a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/ParserPlugin.java +++ /dev/null @@ -1,32 +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. - */ -package org.apache.camel.dsl.jbang.core.commands.parser; - -import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain; -import org.apache.camel.dsl.jbang.core.common.CamelJBangPlugin; -import org.apache.camel.dsl.jbang.core.common.Plugin; -import picocli.CommandLine; - -@CamelJBangPlugin(name = "camel-jbang-plugin-route-parser", firstVersion = "4.17.0") -public class ParserPlugin implements Plugin { - - @Override - public void customize(CommandLine commandLine, CamelJBangMain main) { - commandLine.addSubcommand("route-parser", new RouteParserCommand(main)); - } - -} diff --git a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/RouteParserCommand.java b/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/RouteParserCommand.java deleted file mode 100644 index 1693b6f3d812b..0000000000000 --- a/dsl/camel-jbang/camel-jbang-plugin-route-parser/src/main/java/org/apache/camel/dsl/jbang/core/commands/parser/RouteParserCommand.java +++ /dev/null @@ -1,143 +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. - */ -package org.apache.camel.dsl.jbang.core.commands.parser; - -import java.io.File; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.camel.dsl.jbang.core.commands.CamelCommand; -import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain; -import org.apache.camel.dsl.jbang.core.commands.CommandHelper; -import org.apache.camel.parser.RouteBuilderParser; -import org.apache.camel.parser.model.CamelNodeDetails; -import org.apache.camel.util.FileUtil; -import org.apache.camel.util.StopWatch; -import org.jboss.forge.roaster.Roaster; -import org.jboss.forge.roaster.model.source.JavaClassSource; -import org.jline.jansi.Ansi; -import org.jline.jansi.AnsiConsole; -import picocli.CommandLine; - -@CommandLine.Command(name = "route-parser", description = "Parses Java route and dumps route structure") -public class RouteParserCommand extends CamelCommand { - - @CommandLine.Parameters(description = { "The Camel RouteBuilder Java source files to parse." }, - arity = "1..9", - paramLabel = "", - parameterConsumer = FilesConsumer.class) - Path[] filePaths; - List files = new ArrayList<>(); - - @CommandLine.Option(names = { "--raw" }, - description = "To output raw without metadata") - boolean raw; - - @CommandLine.Option(names = { "--watch" }, - description = "Execute periodically and showing output fullscreen") - boolean watch; - - private CommandHelper.ReadConsoleTask waitUserTask; - - public RouteParserCommand(CamelJBangMain main) { - super(main); - } - - @Override - public Integer doCall() throws Exception { - int exit; - final AtomicBoolean running = new AtomicBoolean(true); - if (watch) { - Thread t = new Thread(() -> { - waitUserTask = new CommandHelper.ReadConsoleTask(() -> running.set(false)); - waitUserTask.run(); - }, "WaitForUser"); - t.start(); - do { - exit = doWatchCall(); - if (exit == 0) { - // use 2-sec delay in watch mode - try { - StopWatch watch = new StopWatch(); - while (running.get() && watch.taken() < 2000) { - Thread.sleep(100); - } - } catch (Exception e) { - running.set(false); - } - } - } while (exit == 0 && running.get()); - } else { - exit = doWatchCall(); - } - return exit; - } - - protected Integer doWatchCall() throws Exception { - for (String file : files) { - Integer code = doDumpFile(file); - if (code != 0) { - return code; - } - } - return 0; - } - - protected Integer doDumpFile(String file) throws Exception { - File f = new File(file); - if (!f.exists() || !f.isFile()) { - printer().printErr("File not found: " + file); - return -1; - } - String ext = FileUtil.onlyExt(file); - if (!"java".equals(ext)) { - printer().printErr("Only .java source file is supported"); - return -1; - } - JavaClassSource clazz = (JavaClassSource) Roaster.parse(f); - List list = RouteBuilderParser.parseRouteBuilderTree(clazz, file, true); - if (watch) { - clearScreen(); - } - for (var route : list) { - printer().println(); - if (!raw) { - printer().printf("Source: %s%n", route.getFileName()); - printer().println("--------------------------------------------------------------------------------"); - } - String tree = route.dump(0); - printer().println(tree); - printer().println(); - } - return 0; - } - - protected void clearScreen() { - AnsiConsole.out().print(Ansi.ansi().eraseScreen().cursor(1, 1)); - } - - static class FilesConsumer extends CamelCommand.ParameterConsumer { - protected void doConsumeParameters(Stack args, RouteParserCommand cmd) { - String arg = args.pop(); - cmd.files.add(arg); - } - } - -} diff --git a/dsl/camel-jbang/camel-launcher/pom.xml b/dsl/camel-jbang/camel-launcher/pom.xml index e9178cb1866e7..3e35d8067878e 100644 --- a/dsl/camel-jbang/camel-launcher/pom.xml +++ b/dsl/camel-jbang/camel-launcher/pom.xml @@ -92,7 +92,6 @@ - org.apache.camel camel-jbang-plugin-generate diff --git a/dsl/camel-jbang/pom.xml b/dsl/camel-jbang/pom.xml index a25ca7b5bb4d9..812196e94628e 100644 --- a/dsl/camel-jbang/pom.xml +++ b/dsl/camel-jbang/pom.xml @@ -42,7 +42,6 @@ camel-jbang-plugin-edit camel-jbang-plugin-kubernetes camel-jbang-plugin-mcp - camel-jbang-plugin-route-parser camel-jbang-plugin-test camel-jbang-plugin-tui camel-jbang-plugin-validate diff --git a/parent/pom.xml b/parent/pom.xml index 2e1550d3681af..ad3712fc3fe48 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -3308,11 +3308,6 @@ camel-jbang-plugin-kubernetes ${project.version} - - org.apache.camel - camel-jbang-plugin-route-parser - ${project.version} - org.apache.camel camel-jbang-plugin-test