Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle - kotlin classes missing from the jar #43242

Closed
kesslerd opened this issue Sep 12, 2024 · 21 comments · Fixed by #43329
Closed

Gradle - kotlin classes missing from the jar #43242

kesslerd opened this issue Sep 12, 2024 · 21 comments · Fixed by #43329
Labels
area/gradle Gradle area/kotlin kind/bug Something isn't working
Milestone

Comments

@kesslerd
Copy link

kesslerd commented Sep 12, 2024

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

  • Gradle with kotlin dsl
  • Java 21
  • Starter Code
  • Extensions: Rest and Kotlin

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

@kesslerd kesslerd added the kind/bug Something isn't working label Sep 12, 2024
Copy link

quarkus-bot bot commented Sep 12, 2024

/cc @geoand (kotlin)

@geoand
Copy link
Contributor

geoand commented Sep 12, 2024

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
Copy link
Contributor

geoand commented Sep 12, 2024

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.

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2024
@geoand geoand added the triage/wontfix This will not be worked on label Sep 12, 2024
@kesslerd
Copy link
Author

kesslerd commented Sep 12, 2024

@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
Copy link
Contributor

geoand commented Sep 12, 2024

So only with Kotlin classes?

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

@gsmet
Copy link
Member

gsmet commented Sep 12, 2024

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

@geoand
Copy link
Contributor

geoand commented Sep 12, 2024 via email

@kesslerd
Copy link
Author

@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
Copy link
Contributor

geoand commented Sep 12, 2024

Yup, that's what I used

@kesslerd
Copy link
Author

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

@kesslerd
Copy link
Author

@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
Copy link
Member

gsmet commented Sep 12, 2024

@aloubyansky maybe you could have a look?

@geoand
Copy link
Contributor

geoand commented Sep 12, 2024

@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 geoand reopened this Sep 12, 2024
@geoand
Copy link
Contributor

geoand commented Sep 12, 2024

@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
Copy link
Member

gsmet commented Sep 12, 2024

Could be #42496

@geoand geoand removed the triage/wontfix This will not be worked on label Sep 12, 2024
@mschorsch
Copy link
Contributor

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 #42496.

@geoand
Copy link
Contributor

geoand commented Sep 12, 2024

Thanks for that info

@geoand
Copy link
Contributor

geoand commented Sep 13, 2024

Also cc @cdsap

@gsmet
Copy link
Member

gsmet commented Sep 13, 2024

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
Copy link
Contributor

geoand commented Sep 13, 2024

Right, I saw that yesterday which is very weird

@gsmet gsmet changed the title kotlin classes missing from the jar Gradle - kotlin classes missing from the jar Sep 13, 2024
@geoand geoand added the area/gradle Gradle label Sep 13, 2024
@gsmet
Copy link
Member

gsmet commented Sep 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gradle Gradle area/kotlin kind/bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

4 participants