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

generated code is not visible from Java source #119

Closed
yigit opened this issue Oct 8, 2020 · 3 comments
Closed

generated code is not visible from Java source #119

yigit opened this issue Oct 8, 2020 · 3 comments
Assignees
Labels
bug Something isn't working P1 major features or blocking bugs
Milestone

Comments

@yigit
Copy link
Collaborator

yigit commented Oct 8, 2020

Java code generated via CodeGenerator is not visible to java sources in the app.
So if you have some java source code in app that depends on to be generated code, it won't see the generated code unless it is in kotlin.
The other combinations work fine.

To clarify:
src: kotlin generated: kotlin <- works
src: kotlin generated: java <- works
src: java generated: kotlin <- works
src: java generated: java <- does not work

@ting-yuan ting-yuan self-assigned this Oct 9, 2020
@ting-yuan ting-yuan added bug Something isn't working P1 major features or blocking bugs labels Oct 9, 2020
@ting-yuan ting-yuan added this to the 2020Q4 milestone Oct 9, 2020
copybara-service bot pushed a commit to androidx/androidx that referenced this issue Oct 9, 2020
The initial abstraction for XProcessing ignored the Filer
API since it is an interface. This CL changes it to have
an abstraction in XProcessing instead to avoid re-implementing
full Filer API in KSP.

Also added a test for code generation. Unfortunately, KSP
does not yet support access to generated code from java sources.
google/ksp#119

Fortunately, it won't affect Room as we don't require access
to generated code.

Bug: 160322705
Test: XProcessingEnvTest.generateCode
Change-Id: I953a17cd857b7360d12269ccda1fe3c6b0489906
@ting-yuan
Copy link
Collaborator

ting-yuan commented Oct 9, 2020

@yigit Could you give me an example to reproduce? I tried the following and cannot repro:

workload/src/main/java/com/example/B.java
workload/build/generated/ksp/src/main/java/com/blabla/HELLO.java

where

// B.java
package com.example;

import com.blabla.HELLO;

class B {
    HELLO h = null;
}

I did found that when HELLO is under default package (i.e., not declared in a package), it is not discoverable for some reason. Is this your case?

@yigit
Copy link
Collaborator Author

yigit commented Nov 2, 2020

sorry i missed your message. In my case, classes are in packages.

If you have androidx checkout (instructions), you can try running this test:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt;l=203?q=XProcessingEnvTest

Just disable the check in the test that prevents it running in java src (line 206)

@yigit
Copy link
Collaborator Author

yigit commented Nov 11, 2020

with the plugin change, this issue is fixed as the plugin now adds sources to the kotlin compile task as a separate task.
I've verified w/ a sample

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

No branches or pull requests

2 participants