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

Empty Kotlin SourceFileSet is passed to JavaPrinter #90

Open
alexander-yevsyukov opened this issue Oct 18, 2022 · 2 comments · May be fixed by #173
Open

Empty Kotlin SourceFileSet is passed to JavaPrinter #90

alexander-yevsyukov opened this issue Oct 18, 2022 · 2 comments · May be fixed by #173
Labels
bug Something isn't working
Milestone

Comments

@alexander-yevsyukov
Copy link
Collaborator

alexander-yevsyukov commented Oct 18, 2022

If Kotlin is enabled in a project it causes current language filtering fail because an empty Kotlin-based set is still passed to a JavaPrinter.

It can be reproduced in protodata-extension/.../UuidJavaRenderer.java class. The PR #87 added a forced check to quit the printing if a file isn't found. If you remove the check the tests would fail with the following diagnostics:

> Task :consumer:launchProtoDataMain FAILED
Exception in thread "main" java.lang.IllegalArgumentException: File not found: `io/spine/protodata/test/ProjectId.java`. 
Source root: `/Users/sanders/Projects/Spine/ProtoData/tests/consumer/build/generated-proto/main/kotlin`. 
Target root: `/Users/sanders/Projects/Spine/ProtoData/tests/consumer/generated/main/kotlin`.
        at io.spine.protodata.renderer.SourceFileSet.file$lambda$2(SourceFileSet.kt:131)
        at java.base/java.util.Optional.orElseThrow(Optional.java:408)
        at io.spine.protodata.renderer.SourceFileSet.file(SourceFileSet.kt:130)
        at io.spine.protodata.test.uuid.UuidJavaRenderer.render(UuidJavaRenderer.java:93)
        at io.spine.protodata.renderer.Renderer.renderSources$compiler(Renderer.kt:54)

As you can see from the above error, the file which is attempted to be found is .java, while source- and target roots are under main/kotlin.

This happens because UuiRenderer attempts to find ProjectId.java (which name it calculates from a proto type name) under a directory with generated Kotlin code.

Presumably, the root cause is that Renderer.renderSources() creates an empty set (when all .kt files are not matched to .java), and then the empty set is passed to UuidJavaRenderer.render().

@alexander-yevsyukov alexander-yevsyukov added the bug Something isn't working label Oct 18, 2022
@alexander-yevsyukov
Copy link
Collaborator Author

@armiol, @dmdashenkov, FYI.

@alexander-yevsyukov
Copy link
Collaborator Author

I've added the check for the empty set in Renderer.renderSource(). But it did not work work inside #87 (as currently integration tests don't seem to use the latest code).

More, it failed one of the tests of Pipeline, so I had to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants