Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qute - localization - multi-module project - need for duplicated resources/messages and beans.xml #24090

Closed
rsvoboda opened this issue Mar 4, 2022 · 4 comments · Fixed by #24179
Assignees
Labels
area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@rsvoboda
Copy link
Member

rsvoboda commented Mar 4, 2022

Describe the bug

Qute - localization - multi-module project - need for duplicated resources/messages and beans.xml

I have created https://github.com/rsvoboda/rsvoboda-playground/tree/master/qute-multimodule, api module contains all the necessary code and files, test module uses api module and focuses on testing.

qute-api and qute-test modules have the identical LocalizedMessagesTest. qute-api based tests work fine / without any workarounds.

But to make qute-test based tests work I had to:

  1. create empty beans.xml in qute-api
  2. copy resources/messages from qute-api to qute-test

For point 1) Would it be possible to auto-discover @MessageBundle interfaces?
It was not straightforward to figure out that I need to check https://quarkus.io/guides/cdi-reference#bean_discovery

For point 2) I don't really understand why is this dupplication needed, I would like to have everything in qute-api module.

Expected behavior

No need to duplicate resources/messages, ideally also no beans.xml needed

Actual behavior

Need for duplicated resources/messages and beans.xml

How to Reproduce?

Use my sample qute-multimodule project

git clone https://github.com/rsvoboda/rsvoboda-playground.git
cd rsvoboda-playground/qute-multimodule
mvn clean verify

To see the failures:

  • remove beans.xml in qute-api
  • remove resources/messages in qute-test

Output of uname -a or ver

No response

Output of java -version

Java 17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.3.Final

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

No response

Additional information

No response

@rsvoboda rsvoboda added kind/bug Something isn't working area/qute The template engine labels Mar 4, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 4, 2022

/cc @mkouba

@mkouba
Copy link
Contributor

mkouba commented Mar 8, 2022

But to make qute-test based tests work I had to:

1. create empty beans.xml in qute-api

You need to add the beans.xml or any other marker file in order to make the qute-api an application archive. Otherwise the qute-api is not part of the app index if you run your app from within qute-test module. This behavior is not qute-specific. See also the Working with multi-module projects and Bean Discovery docs. I'm no quarkus multi-module expert but I believe that this requirement applies to any other app components (CDI beans, JAX-RS resources, etc.). CC @geoand @aloubyansky

2. copy resources/messages from qute-api to qute-test

I think that this is something we should fix. Currently, we only load the message files from the app root which is probably a leftover from the original design/POC where only files from src/main/resources/templates folder of the root app archive were considered (ofc this is no longer the case). I'll try to prepare a PR.

@geoand
Copy link
Contributor

geoand commented Mar 8, 2022

but I believe that this requirement applies to any other app components (CDI beans, JAX-RS resources, etc.)

Correct

@Chexpir
Copy link
Contributor

Chexpir commented Dec 16, 2022

FYI, so it appears in Google to future people searching for this issue.

After this fix, the contrary occurs on migration, and you can get errors like this one (catching it now during Quarkus upgrade on one service we use qute).

  java.lang.IllegalStateException: Duplicate localized files found:
- alert_en.properties: [/app/workdir/x-core-extension/integration-test/build/resources/test/messages/alert_en.properties, /app/workdir/x-core-extension/runtime/build/resources/main/messages/alert_en.properties]

Solution is obvious after finding this page, you can remove the errors by deleting the duplicated file in test folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants