-
Notifications
You must be signed in to change notification settings - Fork 950
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
Adds KotlinPoet integration to Room Processing #137
Adds KotlinPoet integration to Room Processing #137
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
1 similar comment
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
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.
overall lgtm, thanks!
Can you add a test to GeneratedCodeMatchTest to ensure we find these files properly as well.
Sure, working on it |
@yigit Is there anyway I can get the current generation path? I've stumbled upon two situations:
I am investigating what can be done about the latter but not sure how to handle the java scenario yet. |
ef89069
to
91f8f88
Compare
91f8f88
to
3ed4fae
Compare
We can maybe ignore kotlin code verification for now and instead throw an exception that it is not supported if an assertion receives a kotlin file w/ the java processor (to avoid false positives). I'm also not against changing Source.kotlin to require a qName but that would be inconsistent with how kotlin works so I'd rather don't do that for now. We can resolve it later. |
I've managed to run the tests by verifying if TestRunner's
I agree, and modified it to take the relative path instead of the absolute. All tests are passing (the CI looks to have broken but they're passing locally). |
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.
lgtm, just small nits in the test.
you can ignore presubmit, i think we broke playground again, it will work fine in AOSP if it is passing locally (just don't rebase until we fix playground:) )
@Test | ||
fun successfulGeneratedKotlinCodeMatch() { | ||
// java environment will not generate kotlin files | ||
if (runTest.toString() == "java") return |
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.
if (runTest.toString() == "java") return | |
if (runTest.toString() == "java") throw AssumptionViolatedException() |
so that test is reported as skippped instead of succeeded.
@Test | ||
fun missingGeneratedKotlinCode_mismatch() { | ||
// java environment will not generate kotlin files | ||
if (runTest.toString() == "java") return |
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.
same here. eventually we should probaby change TestRunner instead of equals check but not important for this PR.
it also probably makes sense to move this to a helper function assumeCanGenerateKotlinCode
that throws assumption violation.
it should be fixed now: https://android-review.googlesource.com/c/platform/frameworks/support/+/1624289 |
Ok, I will try rebasing now. I also applied precondition checks for running KotlinPoet on javaAP without kapt. I can remove those if you don't think that's applicable. Will push the changes once tests pass. Edit: playground still broken to me after rebase |
3ed4fae
to
bcf7ef7
Compare
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.
lgtm, thanks for adding the kapt parameter check as well.
if CL is fine, it should pass in AOSP which is what matters anyways. github might block it but if it is the only one, we'll skip.
Approving so that it gets mirrored into AOSP
the aosp build failed due to some unused imports.
You can validate these locally as described here: Looks like the lint changes are still breaking playground. Locally, you can workaround it by commenting the source sets in |
Adds `write()` method that accepts KotlinPoet's an instance of `FileSpec`. Also adds KotlinPoet as an API dependency and an extension function similar to that of JavaPoet. Test: ./gradlew test connectedCheck without benchmarks Fixes: b/182195680
Modifies `KotlinSource` to take relative path instead of absolute path for testing, making it somewhat similar to how `JavaSource` takes qualified name.
Also adds tests for the changes and marks tests which skip backends it does not target with `AssumptionViolatedException`.
bcf7ef7
to
96dc315
Compare
Proposed Changes
Adds
write()
method that accepts KotlinPoet's an instance ofFileSpec
. Also adds KotlinPoet as an API dependency and an extensionfunction similar to that of JavaPoet.
Also verifies if processing backend is set for generating kotlin code
and fails for KotlinPoet if it isn't.
Testing
Test: ./gradlew test connectedCheck without benchmarks
Fixes
Fixes: b/182195680