-
Notifications
You must be signed in to change notification settings - Fork 283
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
Implement support for reading resource files in a symbol processor #2068
base: main
Are you sure you want to change the base?
Conversation
fun getResource(path: String): InputStream? | ||
fun getAllResources(): Sequence<String> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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