Affected version
4.0.0-rc-4
Bug description
I want to preface this issue by saying I may be doing something wrong. I'm not well-versed in writing Maven plugins.
When experimenting with writing a Maven plugin using Maven 4.0.0-rc-4, I found what appears to be some inconsistencies with how obtaining services (e.g., OsService) works during unit testing versus when using the plugin in another project (integration testing/"production").
Using @Inject from Maven 4's new Dependency Injection API module (org.apache.maven:maven-api-di) works during unit tests, but fails for the same services when the plugin is used in another project. Conversely, using Session::getService fails during unit tests but then succeeds for the same services when using the plugin in another project.
| API |
Unit test |
Integration test |
Session::getService |
Fails |
Succeeds |
@Inject |
Succeeds |
Fails |
This problem makes it somewhat hard to test Maven plugins since what works during tests doesn't work once deployed and vice versa.
See https://stackoverflow.com/q/79735022/6395627 and https://gitlab.com/tkslaw/maven4-di-tests for more information, including an example plugin demonstrating the problem.
I can include code here if truly necessary, but the example (linked previously) is not exactly tiny.
Affected version
4.0.0-rc-4
Bug description
I want to preface this issue by saying I may be doing something wrong. I'm not well-versed in writing Maven plugins.
When experimenting with writing a Maven plugin using Maven 4.0.0-rc-4, I found what appears to be some inconsistencies with how obtaining services (e.g.,
OsService) works during unit testing versus when using the plugin in another project (integration testing/"production").Using
@Injectfrom Maven 4's new Dependency Injection API module (org.apache.maven:maven-api-di) works during unit tests, but fails for the same services when the plugin is used in another project. Conversely, usingSession::getServicefails during unit tests but then succeeds for the same services when using the plugin in another project.Session::getService@InjectThis problem makes it somewhat hard to test Maven plugins since what works during tests doesn't work once deployed and vice versa.
See https://stackoverflow.com/q/79735022/6395627 and https://gitlab.com/tkslaw/maven4-di-tests for more information, including an example plugin demonstrating the problem.
I can include code here if truly necessary, but the example (linked previously) is not exactly tiny.