quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.36k stars 2.56k forks source link

`quarkus create app` uses wrong platform when using `--extension` #31319

Open knutwannheden opened 1 year ago

knutwannheden commented 1 year ago

Describe the bug

We have a custom Quarkus platform and we use quarkus create app to generate projects based on this platform. (We have a corresponding registry registered in the ~/.quarkus/config.yaml file to achieve this.)

When generating a new project without specifying any additional extensions (i.e. without adding the -x or --extension option), the project is generated as expected. But as soon as the -x option is added to add a specific extension, something unexpected happens: The generated project's pom.xml file refers to the Quarkus BOM rather than our platform's own BOM.

The reason appears to be that the logic in CreateProjectCommandHandler includes the Quarkus core extension origin, when determining the extension origins for the extensions to be added. This is by design as can be seen in the comment of the code: https://github.com/quarkusio/quarkus/blob/6cced964632d3a6b7710f73808906dbaa4f0f704/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/CreateProjectCommandHandler.java#L205-L212

On line 100 in the following loop over the origins the main catalog is first set to our own catalog (based on the RHS of the if condition), which would be correct. On the second loop iteration the main catalog is then overwritten with the Quarkus core catalog (since the LHS of the if condition evaluates to true): https://github.com/quarkusio/quarkus/blob/6cced964632d3a6b7710f73808906dbaa4f0f704/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/CreateProjectCommandHandler.java#L96-L105

Please also note that the extension which was specified via --extension is in fact in our own platform and not in the Quarkus platform. But even if it were part of the Quarkus core platform, I would still have expected that our own custom platform's BOM would have been used as the main catalog when generating the project.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

gsmet commented 1 year ago

/cc @aloubyansky

gsmet commented 1 year ago

/cc @gastaldi too

gastaldi commented 1 year ago

@knutwannheden nice investigation! Would you like to submit a PR with the fix?