private static @Nullable VirtualFile findResourceFile(@NotNull ModulePackagingElement element,
                                                        @NotNull PackagingElementResolvingContext context,
                                                        @NotNull String relativePath) {
    Module module = element.findModule(context);
    if (module == null) return null;

    CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(context.getProject());
    boolean searchInSourceRoots = areResourceFilesFromSourceRootsCopiedToOutput(module);
    for (VirtualFile sourceRoot : element.getSourceRoots(context)) {
      final VirtualFile sourceFile = sourceRoot.findFileByRelativePath(relativePath);
      if (sourceFile != null) {
        boolean underResourceRoots =
          ProjectFileIndex.getInstance(context.getProject()).isUnderSourceRootOfType(sourceFile, JavaModuleSourceRootTypes.RESOURCES);
        if (underResourceRoots || searchInSourceRoots && compilerConfiguration.isResourceFile(sourceFile)) {
          return sourceFile;
        }
      }
    }
    return null;
  }
private static @Nullable VirtualFile findResourceFile(@NotNull ModulePackagingElement element,
                                                        @NotNull PackagingElementResolvingContext context,
                                                        @NotNull String relativePath)