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

Allow Code-geneated Moshi Adapters #82

Merged

Conversation

macisamuele
Copy link
Collaborator

@macisamuele macisamuele commented Jan 22, 2020

The goal of this PR is pretty straight forward it plugs-in moshi-kotlin-codegen into the generated code.

The main difference in the code generated by swagger-gradle-codegen is the presence of @JsonClass(generateAdapter = true) within the code.

This annotation allows KotlinJsonAdapterFactory to identify the JsonAdapter generated via kotlin annotation processor (kapt) if the kapt directive (look into samples/junit-tests/build.gradle changes) is enabled.

This approach leads to a no-op change for users of the current tool but empowers them to get better runtime performances by enabling kapt.
Disclaimer: I've not verified the performance improvements but considering that this is an opt-in approach I'm not concerned about it

Fixes #68
Fixes #62
Fixes #71

Copy link
Collaborator

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally good 👍 Still we have a couple of things to address:

@cortinico cortinico changed the title allow codegeneated moshi adaapters Allow Code-geneated Moshi Adapters Jan 22, 2020
@cortinico cortinico added the enhancement New feature or request label Jan 22, 2020
@cortinico cortinico added this to the 1.4.0 milestone Jan 22, 2020
@cortinico
Copy link
Collaborator

cortinico commented Jan 22, 2020 via email

@macisamuele
Copy link
Collaborator Author

Sure thing, as mentioned I did not see (I should have looked more carefully) PRs already trying to address the same issue.
As soon as I got some extra time I'll try to verify the presence of blockers and ensure that attribution is respected ;)

@macisamuele macisamuele force-pushed the maci-allow-codegeneated-moshi-adaapters branch from 1a80090 to 6c453a8 Compare January 22, 2020 20:01
@macisamuele macisamuele modified the milestones: 1.4.0, 2.0.0 Jan 22, 2020
@macisamuele macisamuele force-pushed the maci-allow-codegeneated-moshi-adaapters branch from 6c453a8 to 10dd7df Compare January 25, 2020 12:14
@macisamuele
Copy link
Collaborator Author

@cortinico, @filipemp: I did re-push the changes as I made the pre-commit hooks configuration less greedy ;)
Instead of ignoring the all samples directory I'm ignoring them into samples/.*/src/main/java/
NOTE: This is done because at the current state the codedgen does not really produce pretty source (according to the lint).
I will eventually look at it, but the reports are mostly related to wrong indentation and/or not needed imports.

@cortinico
Copy link
Collaborator

Can we have the re-formatting + pre-commit change on a separate change? This makes checking out the PR Diffs for third party easier.

@macisamuele
Copy link
Collaborator Author

macisamuele commented Jan 25, 2020

@cortinico just to be sure, before publishing the changes, are you asking me to remove commits
e835456, dcf4e3d and 10dd7df?
If so I'm more than happy to remove it from this PR and publish a follow-up PR once this is merged 😃

Definitely it will simplify reviewing this, after all the commits are applying automated fixes

@cortinico
Copy link
Collaborator

Yes correct. Let's keep the "infra" work outside of this PR.

@macisamuele macisamuele force-pushed the maci-allow-codegeneated-moshi-adaapters branch from 10dd7df to aa38f00 Compare January 26, 2020 17:14
Copy link
Collaborator

@filipemp filipemp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but @cortinico has way more context on the global scale than I do so I'd wait for his review

.gitignore Outdated Show resolved Hide resolved
samples/kotlin-android/build.gradle.kts Outdated Show resolved Hide resolved
settings.gradle.kts Outdated Show resolved Hide resolved
@macisamuele macisamuele merged commit bb15a09 into Yelp:master Jan 27, 2020
@macisamuele macisamuele deleted the maci-allow-codegeneated-moshi-adaapters branch January 27, 2020 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix generated Kotlin enums for Moshi and Proguard/R8 Add support for moshi-kotlin-codegen
3 participants