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

Implement support for reading resource files in a symbol processor #2068

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ansman
Copy link
Contributor

@ansman ansman commented Aug 29, 2024

This would fix #2008

Comment on lines +41 to +42
fun getResource(path: String): InputStream?
fun getAllResources(): Sequence<String>
Copy link
Contributor Author

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 ->
Copy link
Contributor Author

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>
Copy link
Contributor Author

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.

Comment on lines +41 to +42
fun getResource(path: String): InputStream?
fun getAllResources(): Sequence<String>
Copy link
Contributor Author

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() {
Copy link
Contributor Author

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>

SIMULATAN added a commit to SnotyMe/snoty-backend that referenced this pull request Sep 28, 2024
Heavily WIP, depends on google/ksp#2068
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

Successfully merging this pull request may close these issues.

Accessing resources by name
1 participant