Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logic to filter resource files from classes/ is not perfect #1005

Closed
chanseokoh opened this issue Sep 18, 2018 · 2 comments
Closed

Logic to filter resource files from classes/ is not perfect #1005

chanseokoh opened this issue Sep 18, 2018 · 2 comments
Assignees

Comments

@chanseokoh
Copy link
Member

chanseokoh commented Sep 18, 2018

MavenLayerConfigurations.getForJarProject():

I know we're doing our best, and maybe the logic below is the best we can do with the current API, but making a note here that the logic isn't perfect and resource files may slip into the classes layer, e.g., if a resource file is classes/com/example/my-cool.properties. However, now that #956 is fixed, this issue can be resolved somehow by leveraging the new API?

    // Gets the classes files in the 'classes' output directory. It finds the files that are classes
    // files by matching them against the .java source files. All other files are deemed resources.
    try (Stream<Path> classFileStream = Files.list(classesOutputDirectory)) {
      classFileStream.forEach(
          classFile -> {
            /*
             * Adds classFile to classesFiles if it is a .class file or is a directory that also
             * exists in the classes source directory; otherwise, adds file to resourcesFiles.
             */
            if (Files.isDirectory(classFile)
                && Files.exists(
                    classesSourceDirectory.resolve(classesOutputDirectory.relativize(classFile)))) {
              classesFiles.add(classFile);
              return;
            }

            if (FileSystems.getDefault().getPathMatcher("glob:**.class").matches(classFile)) {
              classesFiles.add(classFile);
              return;
            }

            resourcesFiles.add(classFile);
          });
    }
@patflynn
Copy link
Contributor

patflynn commented Sep 19, 2018 via email

@chanseokoh
Copy link
Member Author

chanseokoh commented Sep 19, 2018

I think this is a relatively minor problem. The Gradle plugin and the Maven plugin may generate different layers: the classes layer built by Gradle will have only .class files, whereas Maven may slip some non-.class files into the layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants