Commit Graph

84 Commits

Author SHA1 Message Date
Jesse Wilson
28831b04cf [maven-release-plugin] prepare for next development iteration 2020-08-26 21:38:44 -04:00
Jesse Wilson
cff20193c2 [maven-release-plugin] prepare release moshi-parent-1.10.0 2020-08-26 21:38:36 -04:00
Zac Sweers
a5dbc1d642 Update to Kotlin 1.4.0 (#1191)
* Update to Kotlin 1.4.0

* Remove moshi-kotlin rules in favor of Kotlin's

* Ignore tests for now

* Update to OptIn

* Update test for kotlin 1.4 behavior
2020-08-25 22:51:44 -04:00
Zac Sweers
debb7d3160 Generate proguard rules for code gen on demand (#1067)
* Extract target constructor signature into TargetConstructor.kt

We'll need this to know what the runtime types are for proguard rules

* Add ProguardConfig

* Wire in proguard config

* Write proguard configs out with adapters

* Add full tests

* Now remove the rules!

* Ignore on inline classes for now

* Pass adapter constructor params correctly
2020-01-14 14:59:10 -05:00
Zac Sweers
365e955381 Update to KotlinPoet 1.5.0 (#1062) 2020-01-10 21:05:21 -05:00
Zac Sweers
791ff3211e Update to Kotlin compile testing 1.2.4 (#1014)
* Update to Kotlin compile testing 1.2.4

This allows us to un-toe-hold a test from before

* Fix trailing newline

* Add class-based alternative

* Use updated test API

* Update to 1.2.5

* Update to Kotlin 1.3.60
2019-12-05 22:37:02 +01:00
Jesse Wilson
b287596c60 [maven-release-plugin] prepare for next development iteration 2019-11-17 09:53:53 -05:00
Jesse Wilson
89a254d644 [maven-release-plugin] prepare release moshi-parent-1.9.2 2019-11-17 09:53:46 -05:00
Jesse Wilson
f7dbde2114 Upgrade to KotlinPoet 1.4.4 (#1027)
This fixes support for reified inline types.
2019-11-16 22:54:29 -05:00
Jesse Wilson
878e9a86d6 [maven-release-plugin] prepare for next development iteration 2019-10-30 23:26:50 -04:00
Jesse Wilson
0af27a39a6 [maven-release-plugin] prepare release moshi-parent-1.9.1 2019-10-30 23:26:43 -04:00
Egor Andreevici
13c5ac5e26 KotlinPoet 1.4.3 2019-10-30 18:59:09 -04:00
Jesse Wilson
4637950bab [maven-release-plugin] prepare for next development iteration 2019-10-29 07:57:56 -04:00
Jesse Wilson
0c8005bcee [maven-release-plugin] prepare release moshi-parent-1.9.0 2019-10-29 07:57:49 -04:00
Zac Sweers
d5a43e35f3 Update to KotlinPoet 1.4.2 (#972)
* Unwrap typealiases

This was a change in 1.4.2 left over from moshi's prior metadata logic. We need the unwrapped type for class references

* Add toe-hold for testing shared adapter behavior

* Add regression test for abstractSuperProperties

* Kotlinpoet 1.4.2
2019-10-29 07:51:17 -04:00
Zac Sweers
01b7ea4ba2 Update to KotlinPoet 1.4.1/Kotlin 1.3.50 (#956)
* KotlinPoet 1.4.1 & Kotlin 1.3.50

KotlinPoet uses 1.3.50, so this just matches that now

* Remove now-unnecessary custom shade

This uses the same common package prefix in kotlinpoet now

* Add backwardReferencingTypeVars() regression test

Coverage for #955
2019-10-26 15:04:51 -04:00
Zac Sweers
9dc331f20c Update kotlin-compile-testing to 1.2.3
https://github.com/tschuchortdev/kotlin-compile-testing/releases/tag/1.2.3

* Check file extensions automatically when creating `SourceFile`s with the new factory functions
* Less noisy output/verbose flag actually works as intended
2019-10-05 20:29:03 -04:00
Zac Sweers
902a935f89 Shade kotlinpoet-metadata and kotlinx-metadata (#936)
* Shade kotlinpoet-metadata and kotlinx-metadata

* Relocate KotlinPoet's shaded autocommon dep too
2019-09-25 23:15:06 -04:00
Zac Sweers
54d07b6cbf 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
2019-09-25 22:22:44 -04:00
Zac Sweers
5f98e93698 Switch to kotlin-compile-testing for JsonClassCodegenProcessorTe… (#928)
* Add kotlin-compile-testing dependency

* Add Okio dependency to tests to match kotlin-compile-testing

Without this, Okio.sink() fails to resolve at runtime

* Try converting privateConstructor() to kotlin-compile-testing

* Space

* Update to 1.2.2

* Use new kotlin source file API

* Use temporaryFolder as workingDir

* Extract prepareCompilation helper method

This allows for modifying the compilation with extra bits as needed

* Migrate tests entirely to new API

* Remove incorrect error message

This passed before, but was picked up in https://github.com/square/moshi/pull/903 before and observed to be incorrect.

* Remove custom kotlin compiler implementations

* Add an OK exit code test

This wasn't possible before!

* Remove jitpack dependency now that it's on mavencentral

* Move versions to parent pom

* Fix new test from rebase
2019-09-25 16:41:31 -04:00
Jesse Wilson
54c44c5570 Merge pull request #871 from ZacSweers/z/kotlin1340
Update to Kotlin 1.3.40
2019-06-19 21:47:41 -04:00
Zac Sweers
6a1a15b974 Update to Kotlin 1.3.40 2019-06-19 20:06:50 -05:00
Sean Sullivan
0142e2aaf0 maven-compiler-plugin 3.8.1 2019-06-18 17:00:31 -04:00
Zac Sweers
a5020ddb3c Support gradle incremental processing in code gen (#824)
* Support gradle incremental processing in code gen

This adds support for incremental compilation in gradle via incap helper and marking the code gen as `ISOLATING`.

Depends on a newer version of KotlinPoet that has https://github.com/square/kotlinpoet/pull/647

Resolves #589

* Opportunistically update to auto-service 1.0-rc5

Supports incremental compilation and moves annotations to a separate artifact

* 1.2.0 final!

* Mark compiler embeddales as test only
2019-04-17 18:12:11 -07:00
Zac Sweers
1c3dc89da1 Update to Kotlin 1.3.21
Resolves #777
2019-03-25 19:44:03 -07:00
Jesse Wilson
6b6c1af907 [maven-release-plugin] prepare for next development iteration 2018-11-09 10:04:52 +11:00
Jesse Wilson
eb7110bf59 [maven-release-plugin] prepare release moshi-parent-1.8.0 2018-11-09 10:04:36 +11:00
Jesse Wilson
7055391230 Implement peekJson() for JsonUtf8Reader
This required an upgrade to Okio 1.16.0.
2018-10-08 11:44:03 -04:00
Jesse Wilson
2cb81857ac [maven-release-plugin] prepare for next development iteration 2018-09-24 22:55:49 -04:00
Jesse Wilson
9a652f8788 [maven-release-plugin] prepare release moshi-parent-1.7.0 2018-09-24 22:55:35 -04:00
Jesse Wilson
735f0c39f7 Upgrade Kotlin, AssertJ, compile-testing, and kotlin-metadata dependencies 2018-09-24 21:48:25 -04:00
Sean Sullivan
4392642f03 maven-compiler-plugin 3.8.0 2018-09-23 21:12:54 -07:00
Eric Cochran
3fa09dd110 Update to Okio 1.15.0. 2018-09-11 22:24:38 -07:00
Jesse Wilson
9ea1f845a8 Generate Kotlin documentation with Dokka 2018-08-14 20:20:15 -04:00
Jesse Wilson
31ef245eeb [maven-release-plugin] prepare for next development iteration 2018-05-14 23:00:15 -04:00
Jesse Wilson
bf4d1f8693 [maven-release-plugin] prepare release moshi-parent-1.6.0 2018-05-14 23:00:02 -04:00
Jesse Wilson
60cb608956 Move Kotlin reflection into a kotlin/reflect directory
The maven coordinates stay the same.
2018-05-14 17:28:28 -04:00
Jesse Wilson
9f69029ef0 Move the Kotlin code generator to the kotlin/ module 2018-05-14 16:29:52 -04:00
Jesse Wilson
986cc4c794 [maven-release-plugin] prepare for next development iteration 2018-05-06 21:50:45 -04:00
Jesse Wilson
c2f890879c [maven-release-plugin] prepare release moshi-parent-1.6.0-RC1 2018-05-06 21:50:39 -04:00
Jake Wharton
4f3f74f016 Merge pull request #515 from square/eric.versions
Group dependency version codes together.
2018-04-27 10:27:41 -04:00
Eric Cochran
1589ca8ddb Group dependency version codes together. 2018-04-25 16:40:20 -07:00
Eric Cochran
0d8b5efaa1 Update Error Prone to 2.3.1. 2018-04-25 16:37:46 -07:00
Eric Cochran
14f2dcc357 Update to Okio 1.14.0. 2018-04-06 17:10:33 -07:00
Jesse Wilson
0c24bd4846 Call the kotlin compiler from within a test case.
This is a fragile first step.
2018-03-31 00:57:50 -04:00
Jesse Wilson
982f9c94f6 Fold the kotlin-codegen-runtime into Moshi itself.
Rename @MoshiSerializable to @JsonClass. Like @Json, I'm anticipating
a future where there are other interesting properties on this annotation.
Perhaps a future feature where Moshi is strict and only adapts types that
have a '@JsonClass' annotation.

Also rename MoshiKotlinCodeGenProcessor to JsonClassCodeGenProcessor. We
may later support other ways of generating code here; perhaps for regular
Java types.
2018-03-28 20:26:20 -04:00
Zac Sweers
96e074d030 Kotlin Code Gen module (#435)
* Add kotlin code gen modules

* Update kotlin to 1.2

* Add a serializable dummy class

* Try using kapt configuration from kotlin-examples repo

Still no luck!

* Use proper allocated name for assignment too

* Use selectName() API

* Clean up constructor parameter annotations & plumbing for qualifiers

* Updates poms and kotlin code gen processor to support tests.

* Ignore kotlin code gen tests for now

None of these are data classes tests right now, which is the only thing this supports right now

* Replace $ with _ in class names for consistency

* Shortcut Array types to arrayOf

* Add DataClassTest

* Try generated option first, fall back to maven after

* More idiomatic handling

* Only use nonnullable types for adapter properties

* Code dump of kotshi tests

* Comment out specifics to get compiling

* Generics support!

* Fix double primitive default

* Pick up temporary snapshot for Any fix

* Invariance should just be null

* Better handling of nullably-bound variance

* Just assume the first jvm constructor for now as jvmMethodSig is flaky

* Specify types param if needed

* Don't do lazy delegation

* Clean up nullable typevariablename boundaries

* Add type variables to extension function on companion object

* Use properties instead of allocated names for more robustness

Since we're already on a snapshot

* If there are no type variables, make it null for simpler handling

* Fix generics and Type[] handling

* Fix unnecessary as casts on primitive defaults

* Reference spec directly for possible bangs

* Use nullSafe() adapters for anything nullable or with default values

* Use object type in makeType()

Types.java cares

* Make TestPrimitiveDefaultValues work

* Re-enable TestClassWithJavaKeyword

* Ignore remaining tests that are pending decisions or JsonQualifier support

* Remove customnames test as we're just going to stick with simple @Json

* Add toString() implementations

* Reenable default values testing, adapt to kotlin lang support

* Remove primitive adapters bits since we're not using it

* Clean up a bunch of leftover comments

* Switch to only nullable handling, report missing properties

This makes all nullable handling for local properties the same, and removes defaults for primitives in the process. It simplifies the handling a lot, and leans on kotlin language features to take care of null handling (null checking and then throwing the lazily evaluated list of missing properties).

One minor change from what kotshi does - this reports the serialized name in the missing properties, not the property name. We could look at supporting this though if we want.

* Implement JsonQualifier support

* Use Kapt for AutoService/processor declaration

* Checkstyle

* Remove unused primite type checks

* Add test verifying mutable and immutable collections work

* Fix test name

* Standardize isRequired checks

* Add more nullability and mutability tests

* Kotlinpoet 0.7.0 final

* Switch to new vararg overload for annotation class adapter()

* Make suffix just JsonAdapter without underscore

* Switch to just a regular constructor for MoshiSerializableFactory

* Remove constructor caching

* Remove unnecessary framework class checks

* Nix unnecessary superclass lookups, inline constructor lookup

* Nix null token check in reads

* Nix null check in writes, do !! on first value use

* Nix null checks in favor of serializeNulls

* Inline null checks and fail eagerly

* Fix double _Adapter

* First pass at simplifying adapter names

* Inline names to options property, life into class and rm companion

* Differentiate between absent and null, use nullSafe() as needed

* Group together compile and test dependencies

* Remove incorrect comment

* Revert formatting

* Set, not mutable set

* Collapse else-if nesting to one when

* Cleaner formatting test code

* Collapse more to locals

* Collapse more

* Return a nonnullable type in fromJson

* Remove redundant out variance

* Use KClass where appropriate

* End comment in period

* Remove redundant comment

* Throw on unrecognized type in simplified name

* Use illegalargumentexception instead

* Emit a nullcheck at the beginning of toJson instead

* Remove extra newline

* Simplify processing to be less abusive

* Skip using asClassName() when possible

* Use addComment()

* Switch to declared constructors

Technically more correct since we're defining these

* Unmodifiable set

* return adapter(type, annotationTypes[0])

* Slight optimization - check if the type is parameterized first

If the type is a parameterized type, then we know they'll have the two-arg constructor. This way we don't always try and fail the single arg constructor on parameterized types

* Add test for type aliases, optimize to reuse adapters if possible

This is a tiny optimization to make type aliases (which did already work) reuse adapter properties if they already exist for the backing type. What this means is that if you have:

typealias Foo = String

and properties
foo: Foo
bar: String

you'll only get one adapter property field for String, and both will use it

* Use string templating where possible

* Remove all the kotshi tests
2018-03-11 21:17:55 -04:00
Sean Sullivan
b06f65d2e9 kotlin 1.1.60 2017-11-24 16:27:37 -05:00
Eric Cochran
b7a91e0557 Update to Error Prone 2.1.2. (#384) 2017-11-06 11:49:22 -08:00
Eric Cochran
e0ad48cd97 Update to Kotlin 1.1.51. 2017-10-28 10:07:05 +01:00