Reputation: 321
What i have
@ApplicationScoped
class with onStart method that is trying to read resource file with getClass().getClassLoader().getResourceAsStream()
method;
@BuildStep
with AdditionalBeanBuildItem
that produces my @ApplicatinScoped
class.
What i want to do
Get access to resource folder of application that uses my quarkus extension and read a file.
What is my problem
My quarkus extension can't seems to acces it (it read its own resources instead).
I guess i just need to use a different producer but i'm not sure which one.
Upvotes: 0
Views: 2953
Reputation: 63991
For one, you should be using Thread.currentThread().getContextClassLoader()
as the ClassLoader.
Other than that, Quarkus provides a few utilities like ClasspathUtils
and FileUtil
that will be useful.
A great example of how all this comes together is code that allows a user to customize the banner.
See https://github.com/quarkusio/quarkus/blob/2.3.0.Final/core/deployment/src/main/java/io/quarkus/deployment/steps/BannerProcessor.java#L46 for all the details
Upvotes: 5