GoogleContainerTools / GoogleContainerTools/jib
Empty folders in the /app/resources directory slow down resource file scanning
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Environment**:
- *Jib version:* 3.4.1
- *Build tool:* maven
- *OS:* macOS Monterey
**Description of the issue**:
There are a large number of empty folders in the /app/resources directory in the container. It seems that all java packages have corresponding folders in the /resources directory, regardless of whether they contain resource files.
**Expected behavior**:
If the java package does not contain resource files, do not create corresponding empty folders in the /app/resources directory in the container. Or provide an [includeEmptyDirs](https://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#includeEmptyDirs) configuration parameter like maven resource plugin.
**Steps to reproduce**:
```
$ git clone https://github.com/GoogleContainerTools/jib.git
$ cd jib/examples/helloworld
Delete the following lines in pom.xml
gcr.io/REPLACE-WITH-YOUR-GCP-PROJECT/image-built-with-jib
$ mvn compile jib:dockerBuild
$ docker run --entrypoint /bin/bash --interactive --tty helloworld:1
# ls -alh /app/resources/example/
total 8.0K
drwxr-xr-x 2 root root 4.0K Jan 1 1970 .
drwxr-xr-x 3 root root 4.0K Jan 1 1970 ..
```
As you can see now, every java package that does not contain resource files has an empty folder in the /app/resources directory.
There are a lot of java packages in my current project. If there are a lot of empty folders in the /app/resources directory in the container, resource file search will become slow. For example, use Spring to scan the Hibernate mapping files: classpath*:/**/*.hbm .xml.
**Additional Information**:
I also tried [Jib Layer-Filter Extension](https://github.com/GoogleContainerTools/jib-extensions/tree/master/first-party/jib-layer-filter-extension-maven), but it only provides glob-based file filter and cannot filter empty folders.
Contributor guide
Assessment
This issue has not been assessed yet.