Implement support for reading resource files in a symbol processor#2068
Implement support for reading resource files in a symbol processor#2068ansman wants to merge 1 commit intogoogle:mainfrom
Conversation
| fun getResource(path: String): InputStream? | ||
| fun getAllResources(): Sequence<String> |
There was a problem hiding this comment.
Obviously these would have to be documented before merging.
I also don't know how they would behave on non JVM targets which would have to be tested.
| import java.io.FileNotFoundException | ||
| import java.io.InputStream | ||
|
|
||
| fun Iterable<File>.getResource(path: String): InputStream? = firstNotNullOfOrNull { root -> |
There was a problem hiding this comment.
TODO: Add a test that verifies that you cannot access things in parent directories.
| @get:SkipWhenEmpty | ||
| @get:IgnoreEmptyDirectories | ||
| @get:PathSensitive(PathSensitivity.RELATIVE) | ||
| abstract val resourceRoots: ListProperty<Directory> |
There was a problem hiding this comment.
I did not make resource handling incremental. Not sure if it's needed and how the API would look. Maybe there would be a separate getNewResources or something like that.
| fun getResource(path: String): InputStream? | ||
| fun getAllResources(): Sequence<String> |
There was a problem hiding this comment.
TODO: We'd need a way to associate an output file with a specific resource.
| } | ||
|
|
||
| @Test | ||
| fun testUpToDate() { |
There was a problem hiding this comment.
FYI this test will fail until Gradle is updated due to issues with how older Gradle handles SkipWhenEmpty and ListProperty<Directory>
Heavily WIP, depends on google/ksp#2068
This would fix #2008