-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: failure to run or build #1374
Comments
I've debugged the I'm trying to figure out how to fix it.
|
I've submitted the PR quarkusio/quarkusio.github.io#135 to improve the Gradle guide. |
That NoClassDefFound is very weird.. @jnizet @renannprado Do you have the final Gradle config that causes the problem? Is there any difference in the dependency tree between the Maven and the Gradle projects? |
@geoand Here's output of Gradle version:
Java version:
|
@renannprado Thanks! Do you have a Gradle project that you could include so I can debug use locally and debug? |
@geoand A complete project reproducing the issue is available at https://github.com/jnizet/quarkustest |
@jnizet Thanks! I will check it out in a few hours |
First of all it was weird that the compilation was being triggered even for the first request.
Now the compilation problem obviously remains and I'll continue to look into it |
I was able to get this work by adding the following dependencies:
It seems like for some reason the process that creates the devjar does not resolve the correct dependencies (for the Kotlin compiler) when launched via the Gradle plugin - cc @aloubyansky. The fact that there is work actively being done for bootstrapping makes me reluctant to dig into this more. It's probably best that we reexamine this once that works lands. |
@geoand do you know anything about the |
@renannprado I do not unfortunately, I haven't had time to look into that yet, but hopefully I will soon enough. |
@renannprado @jnizet setting |
@geoand I've tried to put the version in all quarkus dependencies and run Could it be it's trying to open the TL;DR:
Full stacktrace:
|
@renannprado Yeah, I got the same error as well and to be honest I though it was a corrupted cache on my machine - obviously with this happening to you as well that's not the case. |
One more step down the rabbit hole is to add:
and make all quarkus deps exclude the svm dependency like so:
I saw another problem after that but I'm not sure it's just me or if it's a general problem. Again am reluctant to go any deeper at this point since the changes to bootstrapping and dependency resolution that are in the pipeline might fix things |
It seems like the |
@geoand with this fix we will still need all the stuff we discussed so far + upgrading quarkus dependencies? or there something else we will be able to avoid? |
@renannprado No, it will only fix the |
@renannprado @geoand FYI Gradle QuickStart (with Java, not Kotlin) in quarkusio/quarkus-quickstarts#75 ... |
I've reopened my PR regarding the Gradle documentation on this repo (#1403), without using the BOM, and using compileOnly dependencies instead of implementation dependencies. This looks very counter-intuitive to me: given that quarkus-resteasy is what brings resteay to a project, and given that resteasy is needed at compile-time and at runtime, it is really weird to make it a compileOnly dependency. compileOnly is normally used for dependencies whish are only needed at compile-time (like for example annotations that are used by a static code analysis tool like FindBugs). |
@jnizet @renannprado once you've figured this all out 😄 what could perhaps be useful for future automated non-regression would be if you were motivated to contribute a Gradle + Kotlin Quick Start (over in https://github.com/quarkusio/quarkus-quickstarts) or an Integration Test for Gradle + Kotlin here in this main quarkus repo (better). Just FYI, in case you're interested, there is something like that for the Maven integration in https://github.com/quarkusio/quarkus/tree/master/devtools/maven/src/test/resources/projects/classic-kotlin, and in #1405 for #1396 I'm proposing an IT for Gradle (non-Kotlin, but you could follow-up to and extend that, if this topic is dear to you). |
It takes getting used to for sure, but like I said the build process uses these dependencies to create the custom jars. Also this might be changing in the future |
With the latest changes in master (which will be available in the next release scheduled for today) Quarkus now also runs the native/substrate tests with Gradle. - you however need to separate the substrate tests and the quarkus tests in different folders since Quarkus do not allow them being run in the same session. |
👋 everyone ! I'm trying to give gradle & kotlin a try (
It doesn't for me :( (using your github reproducer here : https://github.com/jnizet/quarkustest Is it the same for you ? |
@aesteve Hi. Have you tried applying the various fixes I documented in this issue? |
I did indeed. Here's a repo containing my experiments if you're interested : https://github.com/aesteve/quarkus-kotlin-todobackend/blob/master/build.gradle.kts :) |
Same as @cypressious I tried cloning your repo @renannprado but the |
Gradle support has received a lot of fixes in the latest release, I suggest you give |
I was editing my comment when you posted. Thank you for your work to support Gradle + kotlin. |
Great to hear! |
Unfortunately no, it doesn't work, I can't figure out why :( I'm alternating between many errors, mainly:
If I'm adding
Then I'm facing another issue :
So I tried:
But then in my Gonna give up for now, waiting for 0.19.0! I pushed my attempts here : https://github.com/aesteve/quarkus-test |
I'll try and check it out later |
Having the same problem! |
Can we get the issue reopened? |
Versions 0.19.0 will be released today most likely. |
The problem persists. You can verify that if you build this repo: https://github.com/hmarcelino/millions |
There is a regression in 0.19.0 WRT Gradle and 0.19.1 will follow soon. Lets reexamine your reproducer once that is ready |
This is not fixed yet. The problem might be related with the fact that I have multiple source roots. I'm testing this with a java + kotlin. I was able to not have any problem if I set the sourceDir to:
But this will ignore kotlin src directory. I'll wait a little bit more before start using it. |
@hugomarcelino-spotqa AFAIK, multiple source roots won't work in the current implementation - definitely something to be fixed |
Not fixed for me neither in 0.19.1. I pushed my latest experiments here. The
I also pushed a working Java version Major EDIT: It's hacky obviously, but works on my laptop at least. I tried looking at the plugin source code to understand a bit how things are resolved, but unfortunately, putting a breakpoint in the plugin code in IntelliJ and running For sure the key lies here. I tried to find on codata how people did to not rely on Maybe there's another kotlin plugin to add than the JVM one. I'm confused :\ Sorry can't add more info for a while (5 days or so). Thanks for your help and work |
Thanks for all the info. Hopefully I'll take a look in a few days |
Not sure it's relevant, it looks like the Kotlin plugin does this not sure when it does it, or if it does at all, but it looks like it adds a convention somehow at some time. Hope you'll figure out either a misconception or something I did wrong. I don't really understand how plugins work with one another. Indeed at the time the |
@aesteve I was able to launch your application by adding:
to |
Thank you. That’s less « hacky » than what I mentioned earlier in the thread indeed. 👍 |
That said, we want to improve the Gradle support moving forward |
Is there an issue / pull-request where we can follow your progress, help investigations or maybe review ? I didn't find a lot of things while investigating, but maybe It'd help in some way (and now that I dug a bit into the source, I'm interested :D ) Let me know. |
To be honest I haven't really worked on it nor I have I followed the latest developments on Quarkus - Gradle integration. @aloubyansky would know more :) |
Thank you for the workaround here I did short it to
EDIT: Sadly including java code doesn't work. |
@jnizet what's the current workaround for Quarkus 1.1.0? |
@MartinX3 I propose that you generate a project using
to see what the proposed configuration looks like |
Thank you for your response @geoand I fixed it now in my build.gradle.kts with
Should I still execute this command? |
Which command is that? |
I mean if I should still execute |
That command was just to create a new project that is properly configured so you can compare. |
Thanks for your investigations @MartinX3 I did upgrade my example repo to 1.0.1.Final |
I optimized it based on the generated quarkus example project
|
I've tried setting up a minimal project with Gradle (5.2.1) and Kotlin (1.3.21) and of course Quarkus (0.11.0), but it failed with many issues.
The complete project is available at https://github.com/jnizet/quarkustest
Here are the various issues I faced during this experiment.
First, the guide about Gradle promotes quite discouraged practices, like applying plugins imperatively rather than using the
plugins
block, which is necessary to benefit from the generated type-safe extensions when using the Gradle Kotlin DSL. Or using deprecated configurations, liketestCompile
. I know how to fix that, so it's not a big issue for me, but the Gradle guide could be improved.The Kotlin guide doesn't explain how to use configure a Kotlin Quarkus project with Gradle. So I had to make guesses based on the Maven instructions and on the source code of the gradle plugin. This could be improved too. I don't have numbers, but Kotlin developers probably use Gradle more than Maven, so having a guide showing the usage of both together would be nice. In particular, one thing that is not obvious is how to do the equivalent of the following:
Executing
./gradlew tasks
to know what the gradle plugin does gives the following:The descriptions don't seem correct and clear to me, especially the one of
quarkus-dev
task.Two other things that look weird to me is that the standard Gradle lifecycle and conventions don't seem to be respected:
./gradlew assemble
should build the final runnable jar fileIf the Quarkus plugin is applied, but the quarkus gradle extension is not configured, running
./gradlew quarkus-dev
gives the following:That's weird: I shouldn't have to create such a directory if using Kotlin only. And BTW, creating the
src/main/java
directory has absolutely no effect: the same error message is still generated if I do.So I thought this must have to do with the sourceDirectory, that is changed to src/main/kotlin in the Maven instructions. Reading the Gradle plugin source code, my guess was that I had to add this to the gradle build script:
That makes the
quarkus-dev
task work (sort of): it doesn't throw any error, and gives the same output as when using Java. But navigating tohttp://localhost:8080/
then gives the following error message:I have no idea how to fix that issue. So I tried to execute the
quarkus-build
task (after a clean), and it gave the following exception:At that point, I'm stuck.
The text was updated successfully, but these errors were encountered: