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 fails to detect src/main/resources templates when running maven test #17271

Closed
mjgkaastrupandersen opened this issue May 17, 2021 · 6 comments
Labels
area/maven area/qute The template engine triage/invalid This doesn't seem right triage/needs-reproducer We are waiting for a reproducer.

Comments

@mjgkaastrupandersen
Copy link

I have tried implementing my Qute templates using @ResourcePath annotation but I am switching to the Type-safe templates strategy to have compile checking (which works great btw).

Maven compile reports build success but when running a maven test, my tests fail, as my template-using classes no longer is able to find the templates:

java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.qute.deployment.QuteProcessor#collectTemplateTypeInfo threw an exception: io.quarkus.qute.TemplateException: Declared template ClassName/templateName could not be found. Either add it or delete its declaration in [...]ClassName$Templates.templateName

I assume that this is because, in test, Qute is looking for the template in the src/test/resources/templates/ClassName/templateName and no longer src/main/resources/templates/ClassName/templateName as it did on compile-time.

Copying my templates to src/test/resources/templates, the issue no longer exists but this is not very desirable, as my tests no longer would test production templates.

This is not expected behaviour in my opinion.

Also, I would like to use test-specific templates declared only in my test classes, which should probably be taken into consideration, if this issue results in a fix.

@quarkus-bot
Copy link

quarkus-bot bot commented May 17, 2021

/cc @mkouba, @quarkusio/devtools

@quarkus-bot quarkus-bot bot added area/maven area/qute The template engine labels May 17, 2021
@mkouba
Copy link
Contributor

mkouba commented May 17, 2021

Hello @mjgkaastrupandersen, a minimal reproducer and some information about your environment (e.g. Quarkus version) would be really helpful.

@michaelgarde
Copy link

michaelgarde commented May 17, 2021

@mkouba off course. My bad.
We are currently on

  • Quarkus version 1.11.6.Final-redhat-00001,
  • Maven 3.8.1,
  • java-11-openjdk 11.0.10

Build system is running on Ubuntu in WSL2

I'll see if I can find the time to create a minimal reproducer.

@mkouba mkouba added the triage/needs-reproducer We are waiting for a reproducer. label Jun 18, 2021
@famod
Copy link
Member

famod commented Nov 11, 2021

I was just having the same problem, mainly while working in Eclipse.

I started with a test with a template in src/test/resources/templates and when it was green I continued to add a Template injection point to a class in src/main/java and I placed the respective template in src/main/resources/templates.
That's when trouble started. The respective test (a different one than I first mentioned) failed all the time with "No template found for ...". I even double checked with mvn test ..., same problem.
The test passed when I moved the template to src/test/resources/templates and it broke again when moving it back to main.

Then I ran mvn clean test ... and I was finally able to run the test as expected!
So it seems there is a weird "caching" problem when you start with a template in test and then switch over to main.

PS: Quarkus 2.4.1.Final

@mkouba
Copy link
Contributor

mkouba commented Nov 12, 2021

So it seems there is a weird "caching" problem when you start with a template in test and then switch over to main.

Yes, that would be my guess as well. I always do mvn clean test just to be sure...

@geoand
Copy link
Contributor

geoand commented May 17, 2022

Closing as we never got a reproducer

@geoand geoand closed this as completed May 17, 2022
@geoand geoand added the triage/invalid This doesn't seem right label May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maven area/qute The template engine triage/invalid This doesn't seem right triage/needs-reproducer We are waiting for a reproducer.
Projects
None yet
Development

No branches or pull requests

5 participants