0

Using the Reflections library, how to obtain all the resources with a particular file extension located exactly in one package ?

I tried with this code:

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setUrls(...);
    cb.setScanners(new ResourcesScanner());
    FilterBuilder fb = new FilterBuilder();
    fb.include(FilterBuilder.prefix("org.p1")); //filtering resources in package "org.p1"
    cb.filterInputsBy(fb);
    Reflections reflections = new Reflections(cb);
    Pattern pattern = Pattern.compile(".*\\.xxx");
    Set<String> set = reflections.getResources(pattern); //resources having as extension "xxx" and located in package "org.p1"

But this is answering all the resources with extension "xxx" in the package "org.p1" AND in any subpackage inside it (e.g., "org.p1.p2").

Can I configure Reflections to answer only the resources located in "org.p1" and ignore its subpackages (if any) ?

Sergio
  • 8,532
  • 11
  • 52
  • 94

1 Answers1

0

Why not to try Pattern.compile("org\\.p1\\.xxx");?

AlexR
  • 114,158
  • 16
  • 130
  • 208