I have a Maven project with several API's and the rough flat structure is:
application
- common
- api-01
- api-02
- ...
- api-20
- global
Each of the module has:
<parent>
<groupId>com.application</groupId>
<artifactId>application</artifactId>
<version>placeholder</version>
</parent>
- Some of the APIs (
api-01,api-02...api-20) have a dependency oncommon. -
Each API follows the package naming convention, ex.
com.application.api01 -
The
globalhave dependencies on all the APIs dependencies (api-01,api-02...api-20).
There is a test class in global where I use ClassPathScanningCandidateComponentProvider to get all the classes in all the APIs:
final ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new RegexPatternTypeFilter(Pattern.compile(".*")));
final Set<BeanDefinition> classes = provider.findCandidateComponents("com.application");
Standalone test
When I run the standalone test only without Maven, all the classes are recognized correctly and I see them. I guess it happens because the target folder with a built jar file exists.
Maven test
When I build the project and run all the test with mvn clean install, I see no class included in any API (api-01, api-02 ... api-20). Yet all the classes from common are recognized. The target folder is created upon building the module and since the global is built as the last one, I expect all the classes (from jar files) should be recognized.
Question
How to assure that Maven is able to see all the API classes in global? I don't use Java 9 yet, but Java 8.
I can provide more info upon request.
Aucun commentaire:
Enregistrer un commentaire