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

Clarification on expected behaviour for microprofile-config.properties file in webapp directory #182

Open
anusreelakshmi934 opened this issue Feb 22, 2024 · 11 comments

Comments

@anusreelakshmi934
Copy link

anusreelakshmi934 commented Feb 22, 2024

Currently, it seems that the LSP4MP language server does not provide suggestions for the microprofile-config.properties file when it is located under the webapp/META-INF directory.
image

Suggestions are only available when the file is placed under resources/META-INF.
image

Related - #249

Tools for MicroProfile Version: v0.11.0
OS: Mac
Steps to Reproduce:
Place microprofile-config.properties under webapp directory.
Open VSCode and try to access suggestions for properties within the microprofile-config.properties file.

@anusreelakshmi934
Copy link
Author

I attempted to use Quarkus Tools but found that snippet suggestions were not appearing in both VSCode and Eclipse when working within the Webapp directory. However, I did receive suggestions under the resources directory. Interestingly, in IntelliJ, I received suggestions regardless of the location I was working in.

@angelozerr
Copy link
Contributor

We need to support this usecase but have you a link to the MicroProfile specification which says that webapp folder is a valid folder for microprofile-config.properties please.

@TrevCraw
Copy link

@angelozerr As far as I can tell from the MicroProfile specification, I don't see anything specifying a valid location for microprofile-config.properties in src. I only see the META-INF/microprofile-config.properties location specified for when the application is built.

However, I do not know the spec very well, so maybe there is somewhere where the valid src locations for microprofile-config.properties are defined and I have not found it. It seems as though a user may be able to have a microprofile-config.properties file in any location in src as long as the project build tool handles copying it to the right location for the application build.

@angelozerr
Copy link
Contributor

@TrevCraw before developping something it should be really nice to ask to MicroProfile specification team a clear specification about this location file.

@TrevCraw
Copy link

@yeekangc @Emily-Jiang Would either of you be able to speak to whether or not there are MicroProfile specifications that define where a microprofile-config.properties file should be located in the src of a project?

@angelozerr How was it determined that the src/main/resources/META-INF location should be supported?

@angelozerr
Copy link
Contributor

angelozerr commented Apr 16, 2024

@angelozerr How was it determined that the src/main/resources/META-INF location should be supported?

If I remember it is hard-coded and managed at https://github.com/eclipse/lsp4mp/blob/8e53e583508cc4d141482a55046cfd76a0362092/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/providers/MicroProfileConfigSourceProvider.java#L49

And I think there are this behavior on vscode client side

"workspaceContains:**src/main/resources/META-INF/microprofile-config.properties",

But perhaps I miss some part of code, it requires some investigation. Any PR are welcome!

@Emily-Jiang
Copy link

@yeekangc @Emily-Jiang Would either of you be able to speak to whether or not there are MicroProfile specifications that define where a microprofile-config.properties file should be located in the src of a project?

@angelozerr How was it determined that the src/main/resources/META-INF location should be supported?

@TrevCraw The file microprofile-config.properties is under META-INF and the path can be load by the app classloader using the path: META-INF/microprofile-config.properties. See here for details. For a war achive, the file would be at WEB-INF/classes/META-INF/microprofile-config.properties.

@TrevCraw
Copy link

TrevCraw commented Apr 29, 2024

@angelozerr It appears that the location src/main/resources may have been chosen since it is the default location for a project's resources when working with Maven. However, it should be noted that users can easily customize their pom.xml to pull resources from other locations: https://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html.

@TrevCraw
Copy link

@Emily-Jiang Thank you for your response. My understanding is that what you outlined applies to the built application (please correct me if I am wrong). Is there anything in the MP specifications that dictates where a user must have their microprofile-config.properties file located in their project source code?

@angelozerr
Copy link
Contributor

angelozerr commented Apr 29, 2024

@TrevCraw if I remember we hard code the META-INF folder but not the src/main/resources folder which is get by jdt api

@Emily-Jiang
Copy link

@Emily-Jiang Thank you for your response. My understanding is that what you outlined applies to the built application (please correct me if I am wrong). Is there anything in the MP specifications that dictates where a user must have their microprofile-config.properties file located in their project source code?

The spec does not say where in the project it should be placed. It varies based on different projects. It will be fine as long as in the binary it ends up under META-INF/microprofile-config.properties where it can be loaded by the classloader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants