-
Notifications
You must be signed in to change notification settings - Fork 746
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
Kotlin Code Gen module #435
Merged
Merged
Changes from all commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
fc927f1
Add kotlin code gen modules
ZacSweers fabdf13
Update kotlin to 1.2
ZacSweers c16bd74
Add a serializable dummy class
ZacSweers 5629bb9
Try using kapt configuration from kotlin-examples repo
ZacSweers 8b84f7a
Use proper allocated name for assignment too
ZacSweers 6c32fb7
Use selectName() API
ZacSweers 221b9b3
Clean up constructor parameter annotations & plumbing for qualifiers
ZacSweers d9303d3
Updates poms and kotlin code gen processor to support tests.
rharter f39f3fc
Ignore kotlin code gen tests for now
ZacSweers f45e0ff
Replace $ with _ in class names for consistency
ZacSweers 4c2b044
Shortcut Array types to arrayOf
ZacSweers a2dd477
Add DataClassTest
ZacSweers 380a3a2
Try generated option first, fall back to maven after
ZacSweers 316eb77
More idiomatic handling
ZacSweers 9c98c37
Only use nonnullable types for adapter properties
ZacSweers 35ef68c
Code dump of kotshi tests
ZacSweers 36689ab
Comment out specifics to get compiling
ZacSweers 592a08e
Generics support!
ZacSweers 3a1d735
Fix double primitive default
ZacSweers 15d556c
Pick up temporary snapshot for Any fix
ZacSweers 94d05c0
Invariance should just be null
ZacSweers 8cc2d81
Better handling of nullably-bound variance
ZacSweers 9c98105
Just assume the first jvm constructor for now as jvmMethodSig is flaky
ZacSweers 81287b7
Specify types param if needed
ZacSweers 8614325
Don't do lazy delegation
ZacSweers 6825d69
Clean up nullable typevariablename boundaries
ZacSweers 00087b9
Add type variables to extension function on companion object
ZacSweers f894c6c
Use properties instead of allocated names for more robustness
ZacSweers af945d3
If there are no type variables, make it null for simpler handling
ZacSweers 980016e
Fix generics and Type[] handling
ZacSweers e9c1bb3
Fix unnecessary as casts on primitive defaults
ZacSweers c3533dc
Reference spec directly for possible bangs
ZacSweers 7cded10
Use nullSafe() adapters for anything nullable or with default values
ZacSweers d952e02
Use object type in makeType()
ZacSweers a225bf5
Make TestPrimitiveDefaultValues work
ZacSweers 615325c
Re-enable TestClassWithJavaKeyword
ZacSweers 2b5da41
Ignore remaining tests that are pending decisions or JsonQualifier su…
ZacSweers b94d565
Remove customnames test as we're just going to stick with simple @Json
ZacSweers 0973769
Add toString() implementations
ZacSweers 96d0651
Reenable default values testing, adapt to kotlin lang support
ZacSweers 7271942
Remove primitive adapters bits since we're not using it
ZacSweers 266bceb
Clean up a bunch of leftover comments
ZacSweers 494a682
Switch to only nullable handling, report missing properties
ZacSweers f8d5833
Implement JsonQualifier support
ZacSweers 2cf7cfb
Use Kapt for AutoService/processor declaration
ZacSweers d13c494
Checkstyle
ZacSweers 0de2157
Remove unused primite type checks
ZacSweers b218363
Add test verifying mutable and immutable collections work
ZacSweers 49004ad
Fix test name
ZacSweers 57a3332
Standardize isRequired checks
ZacSweers 6c134a3
Add more nullability and mutability tests
ZacSweers e2b1be0
Kotlinpoet 0.7.0 final
ZacSweers 7461d68
Switch to new vararg overload for annotation class adapter()
ZacSweers d6e8a84
Make suffix just JsonAdapter without underscore
ZacSweers 4a91af8
Switch to just a regular constructor for MoshiSerializableFactory
ZacSweers c95a2b9
Remove constructor caching
ZacSweers c69c477
Remove unnecessary framework class checks
ZacSweers b9b2527
Nix unnecessary superclass lookups, inline constructor lookup
ZacSweers 90436da
Nix null token check in reads
ZacSweers 8eb5bb4
Nix null check in writes, do !! on first value use
ZacSweers dea9c0b
Nix null checks in favor of serializeNulls
ZacSweers 263be76
Inline null checks and fail eagerly
ZacSweers 7f5efd6
Fix double _Adapter
ZacSweers 4132192
First pass at simplifying adapter names
ZacSweers 1f08c70
Inline names to options property, life into class and rm companion
ZacSweers 428917d
Differentiate between absent and null, use nullSafe() as needed
ZacSweers dc8647f
Group together compile and test dependencies
ZacSweers 917ae9b
Remove incorrect comment
ZacSweers 62a9f1b
Revert formatting
ZacSweers ef4cdd6
Set, not mutable set
ZacSweers 9445169
Collapse else-if nesting to one when
ZacSweers a987697
Cleaner formatting test code
ZacSweers 12857e1
Collapse more to locals
ZacSweers 449667b
Collapse more
ZacSweers 960f85e
Return a nonnullable type in fromJson
ZacSweers d175897
Remove redundant out variance
ZacSweers 0390cc5
Use KClass where appropriate
ZacSweers 999e3fc
End comment in period
ZacSweers 0702fc7
Remove redundant comment
ZacSweers e090521
Throw on unrecognized type in simplified name
ZacSweers 1fec18a
Use illegalargumentexception instead
ZacSweers 5ddf528
Emit a nullcheck at the beginning of toJson instead
ZacSweers b59f36a
Remove extra newline
ZacSweers a33d46c
Simplify processing to be less abusive
ZacSweers 9a34bb0
Skip using asClassName() when possible
ZacSweers 7525f89
Use addComment()
ZacSweers 5597b91
Switch to declared constructors
ZacSweers d877e88
Unmodifiable set
ZacSweers 5ed2a58
return adapter(type, annotationTypes[0])
ZacSweers 67f4ab1
Slight optimization - check if the type is parameterized first
ZacSweers 9b6e78b
Add test for type aliases, optimize to reuse adapters if possible
ZacSweers a9ae13a
Use string templating where possible
ZacSweers 31b11f0
Remove all the kotshi tests
ZacSweers File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.squareup.moshi</groupId> | ||
<artifactId>moshi-parent</artifactId> | ||
<version>1.6.0-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>moshi-kotlin-codegen-compiler</artifactId> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jcenter</id> | ||
<url>https://jcenter.bintray.com/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.squareup.moshi</groupId> | ||
<artifactId>moshi</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup.moshi</groupId> | ||
<artifactId>moshi-kotlin-codegen-runtime</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
</dependency> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move up so compile and test artifacts are grouped There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<dependency> | ||
<groupId>me.eugeniomarletti</groupId> | ||
<artifactId>kotlin-metadata</artifactId> | ||
<version>1.2.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto</groupId> | ||
<artifactId>auto-common</artifactId> | ||
<version>0.10</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto.service</groupId> | ||
<artifactId>auto-service</artifactId> | ||
<version>1.0-rc4</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup</groupId> | ||
<artifactId>kotlinpoet</artifactId> | ||
<version>0.7.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<version>${kotlin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>kapt</id> | ||
<goals> | ||
<goal>kapt</goal> | ||
</goals> | ||
<configuration> | ||
<sourceDirs> | ||
<sourceDir>src/main/kotlin</sourceDir> | ||
<sourceDir>src/main/java</sourceDir> | ||
</sourceDirs> | ||
<annotationProcessorPaths> | ||
<annotationProcessorPath> | ||
<groupId>com.google.auto.service</groupId> | ||
<artifactId>auto-service</artifactId> | ||
<version>1.0-rc4</version> | ||
</annotationProcessorPath> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>compile</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>test-compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>testCompile</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>testCompile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This will prevent us from releasing to Maven central.
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.
I hadn't thought of that. What do you suggest? I don't know if @Takhion has strong feelings on publishing to mavencentral (this is for kotlin-metadata)
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.
Quite the opposite! I've already received other requests to publish to Maven central, and the next version will be there for sure (soon) 👍
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.
perf
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.
Added a tracking issue: Takhion/kotlin-metadata#5