* Switch to the Vanniktech base plugin for publishing
Move configuration out of build.gradle files and into build.gradle.kts files.
Sign published builds.
Support publishing release builds from GitHub actions.
* Update build.gradle.kts
Co-authored-by: Zac Sweers <zac.sweers@gmail.com>
Co-authored-by: Zac Sweers <zac.sweers@gmail.com>
Without this we get an AssertionError, which is the wrong exception
type for a JSON schema mismatch:
java.lang.AssertionError: java.lang.NullPointerException: Cannot invoke "java.lang.Number.intValue()" because the return value of "sun.invoke.util.ValueConversions.primitiveConversion(sun.invoke.util.Wrapper, Object, boolean)" is null
at com.squareup.moshi.RecordJsonAdapter.fromJson(RecordJsonAdapter.java:168)
at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:70)
at com.squareup.moshi.records.RecordsTest.absentPrimitiveFails(RecordsTest.java:257)
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Number.intValue()" because the return value of "sun.invoke.util.ValueConversions.primitiveConversion(sun.invoke.util.Wrapper, Object, boolean)" is null
at java.base/sun.invoke.util.ValueConversions.unboxInteger(ValueConversions.java:81)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
at com.squareup.moshi.RecordJsonAdapter.fromJson(RecordJsonAdapter.java:156)
... 46 more
Without the fix the test fails like so:
No JsonAdapter for T (with no annotations)
for T
for java.util.List<T>
for com.squareup.moshi.records.RecordsTest$IndirectGenerics<java.lang.Long>
for class com.squareup.moshi.records.RecordsTest$HasIndirectGenerics
java.lang.IllegalArgumentException: No JsonAdapter for T (with no annotations)
for T
for java.util.List<T>
for com.squareup.moshi.records.RecordsTest$IndirectGenerics<java.lang.Long>
for class com.squareup.moshi.records.RecordsTest$HasIndirectGenerics
at com.squareup.moshi.Moshi$LookupChain.exceptionWithLookupStack(Moshi.java:389)
at com.squareup.moshi.Moshi.adapter(Moshi.java:158)
at com.squareup.moshi.Moshi.adapter(Moshi.java:106)
at com.squareup.moshi.Moshi.adapter(Moshi.java:75)
R8 3.1 in full mode have made improvements to annotation removal.
Current rules are not enough to ensure that JsonQualifier annotatated class are kept.
See https://issuetracker.google.com/issues/206656057
* Default Json.name to an unset value
* Promote shared transient tests to DualKotlinTest
* Add new ignore property to Json
* Support it in ClassJsonAdapter
* Mention no enum/record support
* Support in KotlinJsonAdapter
* Rework code gen API to know of "ignored"
* Support in apt code gen
* Support in KSP
* Update old non-working transient example test
* Synthetic holders
* Use field on both
* Standardize around JDK 8
* Update GJF to support newer JDKs
* Fix misc java 8 issues in tests
* Prepare java 16/records checking at runtime
* Implement real RecordJsonAdapter
* Spotless
* Prepare build for JDK 16+
* Fix property name for kapt
* Small cleanup
* Make FallbackEnum java-8 happy
* Remove animalsniffer
* Fix format
* Add opens for ExtendsPlatformClassWithProtectedFields
* Return null every time in shim for main tests
* Use JDK 16 + release 8 to replace animalsniffer
* Simplify accessor accessible handling
* Remove manifest attrs
* Fix typo
* Fix KCT tests + upgrade it
* Cover another
* Try explicit kotlin daemon args for java 17?
* Disable 17-ea for now until kotlin 1.5.30
* Add JsonQualifier and Json(name) tests + fix qualifiers
* Ensure constructor is accessible
* GJF it properly
* GJF 1.11
* Unwrap InvocationTargetException
* Use MethodHandle for constructor
* Use MethodHandle for accessor too
* Revert "Remove manifest attrs"
This reverts commit 3eb768fd6904bb5c979aa01c3c182e0fb9329d62.
* Proper MR jar
* *actually* fix GJF, which wasn't getting applied before
We can just enable this everywhere now since we require JDK 16 anyway
* Make IDE happy about modules access
* Fixup records tests to play nice with modules
Gotta be public
* Add complex smoke test
* Remove comment
Not a regression test in this case
* Make moshi-root a kotlin project
* Move moshi kotlin extensions to moshi core
* Add appropriate experimental annotations
* Add nextAdapter helper
* Add explicit return type on addAdapter
* Expression body for adapter
* Use nextAdapter helper
* Opportunistically fix a couple Util warnings
* Add Types extensions
* Spotless
* Use extensions in more places for added coverage
* Apply java versions on any java plugin type
This way the kotlin projects get this too
* Fix circularAdapters test?
* Use java 8 in java for code gen too
* Fixup with CircularAdaptersTest
* Add coverage for remaining
* Remove nextAdapter
* Remove leftover function
* Use asserts
left checkNotNull for the contract
* boxIfPrimitive
* Fixup docs
* Copyright fixes
* Add parameterized addAdapter
* Switch to using native javaType API
* Spotless
* Back to 2019
* Spotless
* Use rawType extension
* Fix rebase issues
* Update spotless and enable copyright header bits again
* Reformat square copyright headers
* Create separate format configuration for external files
* Update CI to use java 15 final
* include stacktrace in ci failures
* Update ktlint to 0.39
* Disable java formatting on JDK 15
* Fix google header
* Introduced tags to reader/writers
* Removed getTags method
* Added type safety to tag methods
* Changed to explicit class comparison
* Removed ? extends for tags
* Switched to LinkedHashMap
* Allowed polymorphism for tag values
* Simplified tags tests
* Start gradle root
* Clean up test API ambiguities
These don't compile in gradle anymore and the team[] warns
* Exclude .gradle dirs in git
* Set up moshi module
* Set up moshi-adapters
* Add repositories to subprojects
* Set target/source compatibility
* Set up examples
* Fix location of reflect/test dir
* Set up moshi-kotlin
* Set up code gen
* Opportunistic update code gen deps
* Fix up with code gen
* Set up kotlin tests
* Update snapshots
* Update travis build
* Configure checkstyle
* Cache gradle
* Finish fixing up checkstyle
* Now disable checkstyle until we can fix them all :|
* Update contributing
* Fix tests in codegen
* Remove unnecessary annotation
* Remove maven stuff!
* Suppress warning
* Remove jcenter
* Consolidate dependencies
* Revert "Clean up test API ambiguities"
This reverts commit 3ead69b844b5d7f66134b721e95581f5df1cccd6.
* Fix incap dep
* Opportunistically fix some small kotlinpoet deprecations
* Automatically apply the stdlib to all kotlin projects
* Opportunistic move to opt-in and remove unnecessary annotations
The kotlin maven plugin didn't handle these well in the IDE, gradle does
* Fix Type doc warning
* Fix okio version
* Fix dokka support
* Fix copypasta
* Use new snapshot
* Kotlin 1.4.0
* Expose getStrings() option on JsonReader.Options
Resolves#1173
* Fix clone
Co-authored-by: Jake Wharton <github@jakewharton.com>
* Add mutation check
* Use set and make it unmodifiable
* Back to list
* strings()
* No clone()
Co-authored-by: Jake Wharton <github@jakewharton.com>
This makes application build with Moshi to keep unwanted Kotlin Metadata that have a huge impact on APK size.
After discussion with R8 team, there's currently no solution to avoid this other than using the trick in this PR.
Fixes https://github.com/square/moshi/issues/1115
A new user of Moshi might try to make a class like
data class Response (
val users: ArrayList<User>
)
Then when trying to create a JsonAdapter for it, they get an unhelpful error
message like
Platform class java.util.ArrayList in java.util.ArrayList<java.lang.String>
requires explicit JsonAdapter to be registered
which doesn't explain what they should do to fix the problem. In fact what it
hints towards is that the user should implement a JsonAdapter for ArrayList,
when really they just need to change the type to List!
Now the error looks like
No JsonAdapter for java.util.ArrayList<java.lang.String>, you should use
List instead of ArrayList (Moshi only supports the collection interfaces
by default).
* 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
Reported by a Googler - We currently gate the lookup of the class on the presence of `Metadata`. However, `Metadata` might be justifiably stripped by Proguard/R8, even though `DefaultConstructorMarker` might still be present. This means Moshi's defaults invocation is likely broken on (at least) R8 builds without this.
Workaround until next release is to keep Metadata annotations
* Fix broken test
This test suite doesn't run on CI builds but fails locally since the method was moved
* Add multiple constructors test case
* Implement TypeName.asTypeBlock()
* Make DEFAULT_CONSTRUCTOR_MARKER public
* Look up constructor via getDeclaredConstructor with exact param types
Resolves#975
* Remove dead code