The codeās checked in but thereās some follow-ups to do before we can invite users to use it:
Add jcenter to your pom, and thereās no need for kotlin-metadata to be in maven central.
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
Sonatype OSSRH prevents release of artifacts to Maven central which point to arbitrary repositories.
We should probably generated @Generated annotations onto the adapters via https://github.com/google/auto/blob/master/common/src/main/java/com/google/auto/common/GeneratedAnnotations.java#L46-L61
This could possibly just replace the "generated code, do not edit" header bit in the list.
This would also allow for more fine-grained proguard keepnames retentions, which otherwise would have to keep all of moshi's built-in JsonAdapter-suffixed classes as well due to **JsonAdapter
-keepnames @com.squareup.moshi.<wherever this ends up>.MoshiSerializable class *
# Java < 9
-keepnames @javax.annotation.Generated class **JsonAdapter
# Java 9+
-keepnames @javax.annotation.processing.Generated class **JsonAdapter
Another one for the list: proguard will make seemingly unused constructors private, so we should defensively check in MoshiSerializableFactory if the Constructor is accessible and make it so if it's not
Iām looking into this. We need something like compile-testing for Kotlin. Otherwise we canāt test that unsupported inputs like abstract classes are handled appropriately. Right now weāre only testing inputs that can successfully generate an adapter.
@takhion has actually mentioned working on something like that recently,
not sure where it stands.
On Mar 28, 2018 at 7:39 PM, Jesse Wilson notifications@github.com wrote:
Iām looking into this. We need something like compile-testing for Kotlin.
Otherwise we canāt test that unsupported inputs like abstract classes are
handled appropriately. Right now weāre only testing inputs that can
successfully generate an adapter.
ā
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/square/moshi/issues/461#issuecomment-377102128, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABTEvtXLrys349waEfpsT7HDLLX8pK-pks5tjElRgaJpZM4Sl80x
.
@swankjesse @hzsweers
kotlin-metadata in Maven Central
everything is ready, just waiting on OSSRH-38743
constructor signature in kotlin-metadata
will be in the next major version, aaalmost there
compile-testing for Kotlin
I'm developing a prototype for kotlin-metadata based on Gradle TestKit, but it's gonna take some more time!
Any global timeline on when this feature could be available to users ? I currently have major problems with the reflection adapter factory because of proguard, and this could save my life.
@bishiboosh Kotshi can already save your life: https://github.com/ansman/kotshi
I know about kotshi, but I would rather use an officially sanctionned implementation (plus this one handles default values better, and will support qualifiers properly)
@bishiboosh FYI, Jake Wharton committed on Kotshi repo. Also, this is open source stuff, so no need for an "official" thing approved by a president š. Yes, default values are better handled there, but if you don't have too much of them, using Kotshi until this gets released might be a good solution for you.
@Takhion It seems that they are waiting for a comment response from you, there, in order to host your project on mavenCentral.
@LouisCAD DOH! Thank you, I had already preemptively replied to that question in the description, and I assumed it was just an automatic reply (which it is), but didn't see the Waiting for Response status š¤¦āāļø! Just replied, let's see...
@Takhion Your comment response definitely changed the status! Back to open now š
Kind-of stupid question, but as this is a bug in Kotshi, it may be useful here too : are @Transient field handled properly when creating the adapter ? (as in, ignored when serializing and set to default value when deserializing)
@swankjesse The checkboxes are out of date, kotlin-metadata is now on mavenCentral
Iād like to drop support for types that are subtypes of concrete types. The problem is that when we codegen a class we will need to observe the properties of its superclass. But the superclass could change (maybe itās in a different project!) and we wonāt regenerate the subclassā adapter.
This is easy with reflection (itās late binding) but nearly impossible with codegen.
Thoughts?
@swankjesse Could you illustrate what you're saying with example code snippets?
@swankjesse the annotation processor always runs (unless incremental processing is explicitly enabled) so changes to any class should always be tracked, or am I missing something?
@Takhion that seems reliant on a build system. also, somebody might distribute generated sources and not the generator.
drop support for types that are subtypes of concrete types.
...
we will need to observe the properties of its superclass. But the superclass could change (maybe itās in a different project!) and we wonāt regenerate the subclassā adapter.
Doesn't that argument apply to types that are subtypes of abstract types, too?
I'm a fan of killing off inheritance to avoid accidents. On one hand, it'd be nice to have parity with the reflective adapters. On the other, I think the annotation processor can be be more opinionated. It's a power user feature.
@NightlyNexus but that's true of every annotation processor and pretty much expected behaviour: in general you should only use it at the "final" stage of compilation (like when producing the consumer executable/app), unless you know _exactly_ what you're doing :)
Dagger and Butter Knife are two counterpoints to that.
yeah, i immediately thought of Dagger.
Itās done. Yay!
Most helpful comment
Kind-of stupid question, but as this is a bug in Kotshi, it may be useful here too : are
@Transientfield handled properly when creating the adapter ? (as in, ignored when serializing and set to default value when deserializing)