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

Kotlin Code Gen module #435

Merged
merged 93 commits into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
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 Jan 28, 2018
fabdf13
Update kotlin to 1.2
ZacSweers Jan 29, 2018
c16bd74
Add a serializable dummy class
ZacSweers Jan 29, 2018
5629bb9
Try using kapt configuration from kotlin-examples repo
ZacSweers Jan 29, 2018
8b84f7a
Use proper allocated name for assignment too
ZacSweers Feb 3, 2018
6c32fb7
Use selectName() API
ZacSweers Feb 3, 2018
221b9b3
Clean up constructor parameter annotations & plumbing for qualifiers
ZacSweers Feb 3, 2018
d9303d3
Updates poms and kotlin code gen processor to support tests.
rharter Feb 8, 2018
f39f3fc
Ignore kotlin code gen tests for now
ZacSweers Feb 9, 2018
f45e0ff
Replace $ with _ in class names for consistency
ZacSweers Feb 9, 2018
4c2b044
Shortcut Array types to arrayOf
ZacSweers Feb 9, 2018
a2dd477
Add DataClassTest
ZacSweers Feb 9, 2018
380a3a2
Try generated option first, fall back to maven after
ZacSweers Feb 9, 2018
316eb77
More idiomatic handling
ZacSweers Feb 9, 2018
9c98c37
Only use nonnullable types for adapter properties
ZacSweers Feb 9, 2018
35ef68c
Code dump of kotshi tests
ZacSweers Feb 9, 2018
36689ab
Comment out specifics to get compiling
ZacSweers Feb 9, 2018
592a08e
Generics support!
ZacSweers Feb 9, 2018
3a1d735
Fix double primitive default
ZacSweers Feb 9, 2018
15d556c
Pick up temporary snapshot for Any fix
ZacSweers Feb 11, 2018
94d05c0
Invariance should just be null
ZacSweers Feb 11, 2018
8cc2d81
Better handling of nullably-bound variance
ZacSweers Feb 11, 2018
9c98105
Just assume the first jvm constructor for now as jvmMethodSig is flaky
ZacSweers Feb 11, 2018
81287b7
Specify types param if needed
ZacSweers Feb 11, 2018
8614325
Don't do lazy delegation
ZacSweers Feb 11, 2018
6825d69
Clean up nullable typevariablename boundaries
ZacSweers Feb 11, 2018
00087b9
Add type variables to extension function on companion object
ZacSweers Feb 11, 2018
f894c6c
Use properties instead of allocated names for more robustness
ZacSweers Feb 11, 2018
af945d3
If there are no type variables, make it null for simpler handling
ZacSweers Feb 11, 2018
980016e
Fix generics and Type[] handling
ZacSweers Feb 11, 2018
e9c1bb3
Fix unnecessary as casts on primitive defaults
ZacSweers Feb 11, 2018
c3533dc
Reference spec directly for possible bangs
ZacSweers Feb 12, 2018
7cded10
Use nullSafe() adapters for anything nullable or with default values
ZacSweers Feb 12, 2018
d952e02
Use object type in makeType()
ZacSweers Feb 12, 2018
a225bf5
Make TestPrimitiveDefaultValues work
ZacSweers Feb 12, 2018
615325c
Re-enable TestClassWithJavaKeyword
ZacSweers Feb 12, 2018
2b5da41
Ignore remaining tests that are pending decisions or JsonQualifier su…
ZacSweers Feb 12, 2018
b94d565
Remove customnames test as we're just going to stick with simple @Json
ZacSweers Feb 12, 2018
0973769
Add toString() implementations
ZacSweers Feb 12, 2018
96d0651
Reenable default values testing, adapt to kotlin lang support
ZacSweers Feb 12, 2018
7271942
Remove primitive adapters bits since we're not using it
ZacSweers Feb 12, 2018
266bceb
Clean up a bunch of leftover comments
ZacSweers Feb 12, 2018
494a682
Switch to only nullable handling, report missing properties
ZacSweers Feb 12, 2018
f8d5833
Implement JsonQualifier support
ZacSweers Feb 13, 2018
2cf7cfb
Use Kapt for AutoService/processor declaration
ZacSweers Feb 15, 2018
d13c494
Checkstyle
ZacSweers Feb 15, 2018
0de2157
Remove unused primite type checks
ZacSweers Feb 16, 2018
b218363
Add test verifying mutable and immutable collections work
ZacSweers Feb 16, 2018
49004ad
Fix test name
ZacSweers Feb 17, 2018
57a3332
Standardize isRequired checks
ZacSweers Feb 17, 2018
6c134a3
Add more nullability and mutability tests
ZacSweers Feb 17, 2018
e2b1be0
Kotlinpoet 0.7.0 final
ZacSweers Feb 17, 2018
7461d68
Switch to new vararg overload for annotation class adapter()
ZacSweers Feb 19, 2018
d6e8a84
Make suffix just JsonAdapter without underscore
ZacSweers Feb 19, 2018
4a91af8
Switch to just a regular constructor for MoshiSerializableFactory
ZacSweers Feb 19, 2018
c95a2b9
Remove constructor caching
ZacSweers Feb 19, 2018
c69c477
Remove unnecessary framework class checks
ZacSweers Feb 19, 2018
b9b2527
Nix unnecessary superclass lookups, inline constructor lookup
ZacSweers Feb 19, 2018
90436da
Nix null token check in reads
ZacSweers Feb 19, 2018
8eb5bb4
Nix null check in writes, do !! on first value use
ZacSweers Feb 19, 2018
dea9c0b
Nix null checks in favor of serializeNulls
ZacSweers Feb 19, 2018
263be76
Inline null checks and fail eagerly
ZacSweers Feb 19, 2018
7f5efd6
Fix double _Adapter
ZacSweers Feb 19, 2018
4132192
First pass at simplifying adapter names
ZacSweers Feb 19, 2018
1f08c70
Inline names to options property, life into class and rm companion
ZacSweers Feb 19, 2018
428917d
Differentiate between absent and null, use nullSafe() as needed
ZacSweers Feb 19, 2018
dc8647f
Group together compile and test dependencies
ZacSweers Feb 19, 2018
917ae9b
Remove incorrect comment
ZacSweers Feb 19, 2018
62a9f1b
Revert formatting
ZacSweers Feb 19, 2018
ef4cdd6
Set, not mutable set
ZacSweers Feb 19, 2018
9445169
Collapse else-if nesting to one when
ZacSweers Feb 19, 2018
a987697
Cleaner formatting test code
ZacSweers Feb 19, 2018
12857e1
Collapse more to locals
ZacSweers Feb 19, 2018
449667b
Collapse more
ZacSweers Feb 19, 2018
960f85e
Return a nonnullable type in fromJson
ZacSweers Feb 19, 2018
d175897
Remove redundant out variance
ZacSweers Feb 19, 2018
0390cc5
Use KClass where appropriate
ZacSweers Feb 19, 2018
999e3fc
End comment in period
ZacSweers Feb 19, 2018
0702fc7
Remove redundant comment
ZacSweers Feb 19, 2018
e090521
Throw on unrecognized type in simplified name
ZacSweers Feb 19, 2018
1fec18a
Use illegalargumentexception instead
ZacSweers Feb 19, 2018
5ddf528
Emit a nullcheck at the beginning of toJson instead
ZacSweers Feb 19, 2018
b59f36a
Remove extra newline
ZacSweers Feb 19, 2018
a33d46c
Simplify processing to be less abusive
ZacSweers Feb 19, 2018
9a34bb0
Skip using asClassName() when possible
ZacSweers Feb 19, 2018
7525f89
Use addComment()
ZacSweers Feb 19, 2018
5597b91
Switch to declared constructors
ZacSweers Feb 24, 2018
d877e88
Unmodifiable set
ZacSweers Feb 24, 2018
5ed2a58
return adapter(type, annotationTypes[0])
ZacSweers Feb 24, 2018
67f4ab1
Slight optimization - check if the type is parameterized first
ZacSweers Feb 24, 2018
9b6e78b
Add test for type aliases, optimize to reuse adapters if possible
ZacSweers Mar 10, 2018
a9ae13a
Use string templating where possible
ZacSweers Mar 11, 2018
31b11f0
Remove all the kotshi tests
ZacSweers Mar 12, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
134 changes: 134 additions & 0 deletions kotlin-codegen/compiler/pom.xml
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>
Copy link
Member

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.

Copy link
Collaborator Author

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)

Copy link

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) 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

perf

Copy link
Member

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

</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>
Copy link
Member

Choose a reason for hiding this comment

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

Move up so compile and test artifacts are grouped

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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>