Giter VIP home page Giter VIP logo

Comments (6)

neetopia avatar neetopia commented on August 19, 2024

I pulled your z/ksp branch to my local and ran ./gradlew :sample:compileKotlin, build is passing.

from ksp.

neetopia avatar neetopia commented on August 19, 2024

I am able to reproduce with :sample:build though.

from ksp.

ZacSweers avatar ZacSweers commented on August 19, 2024

Strange... I was running from IntelliJ, but that should be similar. I wonder if maybe there's some sort of stale state issue with local projects or incremental reruns?

from ksp.

neetopia avatar neetopia commented on August 19, 2024

Actually now I am no longer able to reproduce the issue again even with --no-build-cache clean...

:sample:build now fails at test assertions.

from ksp.

ZacSweers avatar ZacSweers commented on August 19, 2024

Away from my computer now, but what if you try an incremental build? That would be consistent with trying compileKotlin first followed by build, and similar to my workflow when I encountered it

from ksp.

neetopia avatar neetopia commented on August 19, 2024

I was able to reproduce after configured IDE to run Gradle build, AND disable incremental compilation in gradle properties. Even if I added one line in MoshiSealedSymbolProcessor incremental compilation is still not invalidated and I have to disable it in properties. Somehow command line still not work for me.

This is actually not a complete regression. There is a major issue (see android/kotlin-for-ksp#46), so in 20200626 build you should be getting No member name found for 'generator'. All arguments: [generateAdapter] for your repro repo, since KSP wasn't able to see the default annotation value at all.

There are some major efforts to address this issue, unfortunately in latest release we didn't include a fix that will address the use case of inspecting default annotation argument from Java library android/kotlin#67 . I tried the locally built KSP and it is producing the following result.

// Code generated by moshi-sealed. Do not edit.
package dev.zacsweers.moshisealed.sample

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
import kotlin.Suppress
import kotlin.collections.emptySet

class MessageJsonAdapter(
  moshi: Moshi
) : JsonAdapter<Message>() {
  @Suppress("UNCHECKED_CAST")
  private val runtimeAdapter: JsonAdapter<Message> =
      PolymorphicJsonAdapterFactory.of(Message::class.java, "type")
          .withSubtype(Message.Success::class.java, "success")
          .withSubtype(Message.Error::class.java, "error")
          .withDefaultValue(Message.Unknown)
          .create(Message::class.java, emptySet(), moshi) as JsonAdapter<Message>


  override fun fromJson(reader: JsonReader): Message? = runtimeAdapter.fromJson(reader)

  override fun toJson(writer: JsonWriter, value: Message?) {
    runtimeAdapter.toJson(writer, value)
  }
}

Let me know if you need help on how to build KSP locally, it should also work if you just treat null value from annotation argument since you know what the default value is (for now).

from ksp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.