lundi 19 juin 2017

If there a way to get project root package from some class?

Imagine that I have such project structure:

/myProject
. /folder1
. . /subfolder2
. /folder2

Is there a way to receive a root package from class, which can be stored in any of these folders, during runtime? I need this in project, which I consider to be a library. These are the rows, where I need to get package name in runtime.

Reflections reflections = new Reflections(clazz.getRootPackageName());  // "com.myCompany" as a parameter, for example
Set<Class<? extends MyInterface>> classes = reflections.getSubTypesOf(MyInterface.class);





Aucun commentaire:

Enregistrer un commentaire