davsclaus opened a new pull request, #27732:
URL: https://github.com/apache/camel/pull/27732
`camel-report-maven-plugin` read Java routes with camel-route-parser
(Roaster/JDT): `route-coverage` built the node tree of each route, and
`validate` read the endpoint uris, simple expressions and route ids. Both goals
only use the **line** of a node; neither reads columns, offsets or end lines.
Messages are `Class.method(File.java:LINE)`, and coverage matches nodes by tree
order, node id or line. So the Java DSL parser of camel-java-io, which gives a
line for every node of the Camel model it reads without compiling the source,
is enough.
## What this does
New `JavaRouteModelReader` in the plugin. It reads a Java source with
`LwJavaParser` and returns the same detail objects camel-route-parser gave, so
the mojo logic is unchanged:
- **route-coverage:** `CamelNodeDetails` trees, built with the rules of the
XML tree of camel-route-parser: EIPs with an input or output, starting at
`from`, and `when`/`otherwise` left out so their steps are outputs of the
choice. The test checks the Java tree equals the tree camel-route-parser builds
from the same route in XML.
- **validate:**
- Endpoints: from, poll and pollEnrich are consumers; to, toD, wireTap and
enrich are producers. intercept uris without a wildcard are validated but are
not part of the seda/direct pair check.
- Simple expressions and predicates: predicate or not comes from the
catalog (`asPredicate`).
- Route ids.
As camel-route-parser did:
- a uri built with a value only known at runtime is validated with that part
as a placeholder: `"http://localhost:" + port + "/x"` becomes
`http://localhost:{{port}}/x`;
- endpoints injected with `@EndpointInject`, and `to(field)` for such a
field, are read;
- `String` fields with an initializer, used as `from(ftp)`, are read.
XML routes stay on camel-route-parser, and camel-route-parser stays (IDE
tooling uses it). The Roaster dependencies stay in the pom, because
camel-route-parser's XML parser loads classes that refer to them. New
dependency: `camel-java-io` (core; it only adds camel-xml-io, the plugin
already has camel-core).
## Checked on tests/camel-itest
`mvn camel-report:validate` (`includeTest`, `includeXml`), with this plugin
and with the plugin from main:
| | main (Roaster) | this PR |
|---|---|---|
| endpoints | 164 passed, 3 incapable | 184 passed |
| simple | 7 passed, 2 invalid | 7 passed, 2 invalid |
| route ids | 21 | 21 |
| seda/direct pairs | 0 pairs, 2 non-pairs | the same |
- Found only by main: 3 "uris" that are only a method call
(`from(inboxQueue())`), which Roaster turned into `{{inboxQueue}}`, a
placeholder with no component.
- Found only by this PR: 20 endpoints in `ValidatorSchemaImportTest`, whose
route builders camel-route-parser did not read.
## Tests
New `JavaRouteModelReaderTest` (the plugin had no tests for these goals). It
covers:
- route trees equal to the XML ones;
- endpoints with their consumer/producer side and lines, a constant
resolved, and an unknown uri reported as unparsable;
- simple predicates and expressions;
- route ids and the class name from the package;
- placeholders, `@EndpointInject` and String fields;
- a class without routes.
All 67 plugin tests pass.
Docs: plugin page (and its user-manual copy), and a 4.24 upgrade-guide entry
(appended to `camel-4x-upgrade-guide-4_24.adoc`).
Fixes [CAMEL-25591](https://issues.apache.org/jira/browse/CAMEL-25591)
_Claude Code on behalf of Claus Ibsen_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]