davsclaus opened a new pull request, #29816:
URL: https://github.com/apache/camel/pull/29816

   ## Summary
   
   Item 6 of [CAMEL-26912](https://issues.apache.org/jira/browse/CAMEL-26912): 
**local JARs broke the exported project.**
   
   A local JAR (`camel run route.camel.yaml greeter.jar`, or a JAR in an 
exported directory) becomes a `system` dependency of the pom.xml with 
`<systemPath>${project.basedir}/lib/<artifactId>-<version>.jar</systemPath>`. 
The artifactId and version come from the `pom.properties` of a JAR built by 
Maven, else from the file name (`greeter.jar`: `local:greeter:1.0`). But:
   
   - the JAR was copied to `lib/` under its own file name: `lib/greeter.jar`, 
while the pom.xml refers to `lib/greeter-1.0.jar`, so `mvn` fails; the same for 
a Maven-built JAR whose file name is not `artifactId-version.jar`
   - a JAR in a directory (`camel export proj`, with `proj/acme-greeter.jar`) 
was copied to `lib/proj/acme-greeter.jar`, whose directory was not created: the 
export failed with exit 66 (`File not found: 
.camel-jbang/work/lib/proj/acme-greeter.jar`); its artifactId was `proj/acme`
   - its `pom.properties` was looked up relative to the exported directory, not 
where the run has the JAR
   - the JAR was also copied into `src/main/resources`
   
   ### Fix
   
   - The JAR is copied to `lib/<artifactId>-<version>.jar`: the name that the 
pom.xml of every runtime (Camel Main, Spring Boot, Quarkus, with or without 
Kubernetes) refers to.
   - The artifactId and version of a JAR not built by Maven come from its file 
name, not its directory.
   - The `pom.properties` of the JAR is read from the path the run has 
(relative to the current directory), else relative to the exported directory as 
before.
   - A local JAR is not copied into `src/main/resources`.
   
   ## Tests
   
   - `ProjectExporterTest.localJarsAreInTheLibDirectoryAsThePomRefersToThem` 
for Camel Main, Spring Boot and Quarkus: a JAR not built by Maven in a 
directory (`libs/greeter.jar`) and a Maven-built JAR whose file name is not its 
artifact (`util.jar` of `com.acme:acme-util:2.1`) are in `lib/` as the pom.xml 
refers to them, and nowhere else. It fails without the fix.
   - camel-jbang-run (273 tests), camel-jbang-core including 
`RunExportGoldenTest` (golden files unchanged), and 
camel-jbang-plugin-kubernetes (156 tests) pass locally.
   - With the unpacked launcher, a route with `greeter.jar` (not built by 
Maven): the current launcher writes `lib/greeter.jar` and 
`src/main/resources/greeter.jar`, and `mvn -o compile` of the project fails 
(`Could not resolve dependencies ... local:greeter:jar:1.0 (system)`); `camel 
export proj` fails with exit 66. With the new camel-jbang-run jar both exports 
have the JARs in `lib/` as the pom.xml refers to them, and both projects 
compile with `mvn -o compile`.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


-- 
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