Migrate to KotlinPoet-metadata (#903)

* Add kotlinpoet version to properties

* Swap in kotlinpoet-metadata for kotlin-metadata in dependencies

* Don't use KotlinMetadataUtils and KotlinAbstractProcessor anymore

* Upcast to TypeElement

* Temporarily add direct kotlinx-metadata dependency

Something is wrong with packaging in my local kotlinpoet, will remove before

* Remove tags API from TargetParameter

No longer needed

* Add PropertySpec directly to TargetProperty, remove holder funs

Simplifies some things!

* Move generated annotation gen into type callback

Removes JsonClassCodegenProcessor completely from codegen API

* Remove unstable autocommon dependency

Won't be using this anymore after this change

* Manually put quotes jsonName in AdapterGenerator

Otherwise we could incur double escaping from kotlinpoet since we directly reuse possible-escaped parsed `@Json` name values

* Opt in to use `@UseExperimental` annotation for preview

* Rework and simplify metadata to just use kotlinpoet-metadata

This is hard to do in broken down 1:1 steps, but the net result is a much smaller implementation footprint, better error messages, and a simpler API interaction with the code gen API. There is some raw parsing of kotlinpoet types required (mostly around annotations), but otherwise it's pretty smooth sailing and a good test of the upcoming kotlinpoet-metadata support

* Declare KotlinPoetMetadataPreview directly

* Try to point to snapshots for CI build

* Update to classinspector API

* Remove TypeResolver API

No longer needed

* Kotlinpoet 1.4.0 final

* Fix missing import from rebase

* Remove old kotlin-metadata version
This commit is contained in:
Zac Sweers
2019-09-25 22:22:44 -04:00
committed by GitHub
parent 5f98e93698
commit 54d07b6cbf
11 changed files with 211 additions and 683 deletions

View File

@@ -27,6 +27,26 @@
<artifactId>kotlinpoet</artifactId>
<version>${kotlinpoet.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-metadata-jvm</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>kotlinpoet-metadata</artifactId>
<version>${kotlinpoet.version}</version>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>kotlinpoet-metadata-specs</artifactId>
<version>${kotlinpoet.version}</version>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>kotlinpoet-classinspector-elements</artifactId>
<version>${kotlinpoet.version}</version>
</dependency>
<dependency>
<groupId>net.ltgt.gradle.incap</groupId>
<artifactId>incap</artifactId>
@@ -34,11 +54,6 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.auto</groupId>
<artifactId>auto-common</artifactId>
<version>${auto-common.version}</version>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
@@ -67,10 +82,6 @@
The Kotlin compiler usage must be near the end of the list because its .jar file includes an
obsolete version of Guava!
-->
<dependency>
<groupId>me.eugeniomarletti.kotlin.metadata</groupId>
<artifactId>kotlin-metadata</artifactId>
</dependency>
<dependency>
<groupId>com.github.tschuchortdev</groupId>
<artifactId>kotlin-compile-testing</artifactId>
@@ -135,6 +146,12 @@
</goals>
</execution>
</executions>
<configuration>
<args>
<!-- So we can declare ourselves as users of KotlinPoetMetadataPreview -->
<arg>-Xuse-experimental=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>