quarkusio / quarkus

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

Gradle - kotlin classes missing from the jar #43242

Closed kesslerd closed 1 month ago

kesslerd commented 1 month ago

Describe the bug

Kotlin classes are missing from the jar used for the docker build

I created a new project on https://code.quarkus.io/ using

Using the dev server I can access the GreetRessource, however, when I build a docker image(Dockerfile.jvm) I get the "Resource not found" message.

When adding a new endpoint using a java class the endpoint is both accessible using the dev server and the docker image

Expected behavior

Kotlin and Java resources should work

Actual behavior

Kotlin resources are missing

How to Reproduce?

https://github.com/kesslerd/kotlin-docker-test

  1. create a docker image based on https://github.com/kesslerd/kotlin-docker-test/blob/main/src/main/docker/Dockerfile.jvm
  2. Check if the endpoints /hello and /hello-java work

Output of uname -a or ver

23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 arm64

Output of java -version

openjdk 21.0.4 2024-07-16 LTS OpenJDK Runtime Environment Zulu21.36+17-CA (build 21.0.4+7-LTS) OpenJDK 64-Bit Server VM Zulu21.36+17-CA (build 21.0.4+7-LTS, mixed mode, sharing)

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.8

Additional information

No response

quarkus-bot[bot] commented 1 month ago

/cc @geoand (kotlin)

geoand commented 1 month ago

So the problem is that when both Java and Kotlin sources exist, the production artifact does not include the kotlin stuff.

BTW, this happens not only with a docker build, but with a plain jar build as well.

geoand commented 1 month ago

The problem can actually be overcome if you use different package for Java and Kotlin source code - which you should probably do anyway, so I am going to close this as won't fix.

kesslerd commented 1 month ago

@geoand It also happens for me if there is no java class in the project and also in the plain jar Build both classes are included

geoand commented 1 month ago

So only with Kotlin classes?

I have not seen that, and we have plenty of people using only Kotlin with Quarkus

gsmet commented 1 month ago

I think I have seen some reports of weird things happening with Kotlin + Gradle but only in dev mode.

geoand commented 1 month ago

In this case, dev mode worked just fine

On Thu, Sep 12, 2024, 18:16 Guillaume Smet @.***> wrote:

I think I have seen some reports of weird things happening with Kotlin + Gradle but only in dev mode.

— Reply to this email directly, view it on GitHub https://github.com/quarkusio/quarkus/issues/43242#issuecomment-2346584500, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBMDP3PLRE7TLGNO73DTTLZWGV5RAVCNFSM6AAAAABODGRIYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBWGU4DINJQGA . You are receiving this because you were mentioned.Message ID: @.***>

kesslerd commented 1 month ago

@geoand I attached two screenshots of the contents of the jars I get.

./gradlew jar (build/libs) jar

./gradlew build (build/quarkus-app/app) quarkus-app-jar

Out of curiosity did you use the linked project to reproduce?

geoand commented 1 month ago

Yup, that's what I used

kesslerd commented 1 month ago

using maven instead of gradle on code.quarkus.io is working fine. However, I would prefer to use gradle

kesslerd commented 1 month ago

@geoand When I change the quarkus version to 3.14.2 in the gradle properties the jar gets correctly generated. I verified this claim by switching several times between 3.14.2 and 3.14.3

gsmet commented 1 month ago

@aloubyansky maybe you could have a look?

geoand commented 1 month ago

@geoand When I change the quarkus version to 3.14.2 in the gradle properties the jar gets correctly generated. I verified this claim by switching several times between 3.14.2 and 3.14.3

I can confirm this, so I'll reopen it

geoand commented 1 month ago

@aloubyansky maybe you could have a look?

Nothing jumps out as the culprt in the release notes, so I would appreciate your help here @aloubyansky

gsmet commented 1 month ago

Could be https://github.com/quarkusio/quarkus/pull/42496

mschorsch commented 1 month ago

BTW I'm not sure this is the same issue but theres definitly something wrong with Quarkus 3.14.3 using Gradle and Kotlin. In all of our Quarkus projects we have failing ci builds, failing/dubious Intellij builds and services not starting due to class not being found since Quarkus 3.14.3. Quarkus 3.14.2 works fine. I'm working on a reproducer and will open a new issue.

I suspect it's due to https://github.com/quarkusio/quarkus/pull/42496.

geoand commented 1 month ago

Thanks for that info

geoand commented 1 month ago

Also cc @cdsap

gsmet commented 1 month ago

What's interesting is that the classes are actually compiled. I can see them in the build directory but they are not included in the jar.

geoand commented 1 month ago

Right, I saw that yesterday which is very weird

gsmet commented 1 month ago

3.14.4 released today should address the issue. Let's keep this issue open as I only reverted the changes in 3.14/3.15 and we still need to fix the issue in main as we want to keep the enhancement that introduced the regression long term.