quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.54k stars 2.61k forks source link

When jackson and kotlin are used, add jackson-module-kotlin #18409

Open andreas-eberle opened 3 years ago

andreas-eberle commented 3 years ago

Description

When a Quarkus project contains the quarkus-kotlin and a jackson extension, the dependency com.fasterxml.jackson.module:jackson-module-kotlin should be added automatically. This extension allows jackson to create Kotlin specific type like data classes.

I think if a project uses Kotlin & Jackson, this dependency should automatically be added alongside the jackson dependency.

quarkus-bot[bot] commented 3 years ago

/cc @evanchooly

gastaldi commented 3 years ago

IMHO I don't think you can add dependencies dynamically like that, that's why we have the resteasy-jackson and rest-client-jackson extensions, for example.

In this case I think the best is to introduce a quarkus-kotlin-jackson extension

geoand commented 3 years ago

@aloubyansky might have some thoughts on this :)

In general I agree with George, we shouldn't go too far and start magically adding dependencies to the application just because we can :). If we however had something like George mentioned in the quarkus-kotlin-jackson extension, we could engage it automatically if the quarkus-jackson and quatrkus-kotlin where part of the application.

aloubyansky commented 3 years ago

Right, in can only be done if there is a corresponding Quarkus Kotlin extension. An alternative way to the RR Kotlin support modelling it would be to create Kotlin area-specific (e.g. jackson, etc) extensions that would be configured with a condition on the presence of a specific artifact on a classpath. Then quarkus-kotlin extension would add optional dependencies on those Kotlin area-specific extensions. So, if an app includes quarkus-kotlin extension and artifacts satisfying one (or more) Kotlin area-specific extensions are present, those Kotlin area-specific extensions would be enabled automatically.

geoand commented 3 years ago

Thanks @aloubyansky for the insight!

So let's close this for now, but keep in mind what is now possible due to your improvements in the bootstrap process

andreas-eberle commented 3 years ago

Sorry, I'm not sure if I did understand all the deep down Quarkus details...

aloubyansky commented 3 years ago

Sorry, I'm not sure if I did understand all the deep down Quarkus details...

  • Do you agree that this should be added automatically?

IMO, that's a reasonable feature request.

  • ~Did I get it right, that there is a technical limitation that does not allow to do it?~

In traditional Maven/Gradle world, it is. In Quarkus 2.0 we introduced a Quarkus bootstrap feature that should allow us make it possible.

  • So we would need a quarkus-kotlin-jackson extension that only contains the dependency to the com.fasterxml.jackson.module:jackson-module-kotlin? And then you could wire this up?

This could be a way. I think we should review the whole Kotin dependency model from this perspective to have a bigger picture.

andreas-eberle commented 3 years ago

Should we keep this issue open then? I mean, since it seems to be a reasonable request and technically possible. It looks to me this "only" requires clarification on how Quarkus wants to handle Kotlin specific dependencies over all. Therefore I think it would make sense to have this issue reopened and maybe linked to an issue that focuses on the Kotlin dependencies discussion.

aloubyansky commented 3 years ago

Isn't this issue the same as https://github.com/quarkusio/code.quarkus.io/issues/426 ?

aloubyansky commented 3 years ago

Ah, it's different repo.

aloubyansky commented 3 years ago

The code.quarkus one should be closed, imo.

aloubyansky commented 3 years ago

Yes, I'd agree to keep it open.

andreas-eberle commented 3 years ago

I agree, a fix of this issue would make https://github.com/quarkusio/code.quarkus.io/issues/426 obsolete.

geoand commented 2 years ago

https://github.com/quarkusio/quarkus/issues/23342 is another manifestation of this.

I wonder if I should add a quarkus-resteasy-reactive-jackson-kotlin extension that will get enabled automatically if quarkus-resteasy-reactive-jackson and quarkus-kotlin are present...