Skip to content

Conversation

@altro3
Copy link
Collaborator

@altro3 altro3 commented Aug 21, 2022

Finally added support standard properties application.yml with environments

Fixes #766
Fixes #759
Fixes #166

Merge it after #791

@graemerocher
Copy link
Contributor

@altro3 could you rebase? Thanks

@altro3
Copy link
Collaborator Author

altro3 commented Sep 2, 2022

@graemerocher yes, sure. But, please, don't merge this PR yet. I'm not sure that everything is working as intended at the moment. In Java, there are restrictions on the access of the annotation processor to the source code. Those. I'm not sure if this solution will work, I need to additionally test the library when it is included as an annotation processor. I'll try to test it over the weekend

@altro3
Copy link
Collaborator Author

altro3 commented Sep 4, 2022

@graemerocher Phew, I had to complicate the solution a bit due to java limitations, but I implemented the ability to use standard configurations for micronaut. I had to add the project keyword to identify the path to the yaml files that are in the project sources, because. when starting annotation processing, java does not provide access to the project files directly, that is, it does not load classes into the classpath and does not load resources.

Pull request can be merged

super(configuration);

Path projectPath = context.getProjectDir().orElse(Paths.get(System.getProperty("user.dir")));
projectDir = projectPath.toString().replaceAll("\\\\", "/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a hack, why can't you just use path.toUri()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graemerocher Don't agree with you. This a stnadrad fix for windows. Why didn't I use toUri ? Let's see to example. My directory is D:\Work\my-project in windows and /home/my/work/my-project. I need to set this path as file:D:\Work\my-project for wind and file:/home/my/work/my-project.

If I use path.toUri().toString() than I have these paths: file:///D:/Work/my-project/ for Windows and file:///D:/Work/my-project/ and file:///home/my/work/my-project/.

The problem is that in order to correctly display the correct path, I need to trim file and 3 slashes for Windows, and file and 2 slashes for Linux. In general, there are more problems than benefits from such a solution. My solution is simple and clear

@graemerocher graemerocher merged commit 163f1bf into micronaut-projects:master Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants