Quarkus: Gradle integration is hard-coded for single-project using Java

Created on 20 Mar 2019  路  13Comments  路  Source: quarkusio/quarkus

The changes made to fix #1532 still hardcodes a single default location for the classes.
This location is incorrect if Kotlin is used.
And if both Java and Kotlin are used, Gradle will store classes in two separate directories, not just one.
I don't know why the locations need to be verified that way because I have no idea of what Quarkus needs to do with these classes, but apparently:

  • given that these locations are hardcoded that way, you can't run tests from the IDE (since it stores classes in a different directory than Gradle/Maven)
  • you can't use any other language than Java (and Kotlin if fixed for Kotlin)
  • you can't have classes and test classes in separate Gradle/Maven projects/modules
arebuild aregradle kinbug triagduplicate

Most helpful comment

Yes, that is true. We're looking into improving this inside Quarkus, but it will not be included in the upcoming release unfortunately.

All 13 comments

Hi, yes there are hardcoded locations for the tests in Quarkus in it's current state. This is something we will try to address asap, but it won't happen in the next release (scheduled for today). The change we've done should work for the default location though, so hopefully that works for the majority of the users.

From the latest changes in master (with this pr #1583) I successfully run the getting-started QuarkusTests from Intellij. I do not have any experience with Kotlin I'm afraid.

...looks like Gradle's quarkusDev task also follows the same trend; maybe this can be fixed along with the reported one :sunglasses:

[x80486@uplink kotlin-quarkus]$ ./gradlew quarkusDev
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.3/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
> Task :compileKotlin UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :quarkusDev FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':quarkusDev'.
> The `src/main/java` directory is required, please create it.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
4 actionable tasks: 1 executed, 3 up-to-date

In master, with this block in your build file:

quarkus {
    setSourceDir("src/main/kotlin")
    resourcesDir().add(File("src/main/resources"))
    setOutputDirectory("build/classes/kotlin/main")
}

Running gradle quarkusDev works, atm we're looking into fixing the plugin to work with the default values as well.

Running gradle quarkusDev works, atm we're looking into fixing the plugin to work with the default values as well.

It is working with Kotlin only. But if one needs to use Kotlin and Java in one Project, this is still a big Problem.

Yes, that is true. We're looking into improving this inside Quarkus, but it will not be included in the upcoming release unfortunately.

In master, with this block in your build file:

quarkus {
    setSourceDir("src/main/kotlin")
    resourcesDir().add(File("src/main/resources"))
    setOutputDirectory("build/classes/kotlin/main")
}

Running gradle quarkusDev works, atm we're looking into fixing the plugin to work with the default values as well.

Yeah, that works nice for kotlin, but i still can't seem to the get the tests running, as i can't configure the "build/classes/kotlin/test" folder for test classes anywhere. Could you please make sure to include test class configuration as well? :-)

@jkopcsek stumbled upon the same... so the problem does actually exist. I though my setup is incorrect. The build is rather complex, and uses many gradle features. My guess is quarkus generally not going well with multi-module builds. Think this is the first issue to address here.

Here is a setup of a gradle/kotlin test that is not being recognized: https://github.com/jkopcsek/quarkus-kotlin-gradle-demo/tree/bug/quarkus-test-not-found

It is not found at all in quarkusBuild and when executing the test in IntelliJ the following error pops up:
Caused by: java.lang.RuntimeException: The test class class qkg.demo.PingResourceTest is not located in any of the directories [classes/java/test, /test-classes, bin/test] at io.quarkus.test.common.PathTestHelper.getTestClassesLocation(PathTestHelper.java:57) at io.quarkus.test.common.TestResourceManager.indexTestClasses(TestResourceManager.java:123) at io.quarkus.test.common.TestResourceManager.getTestResources(TestResourceManager.java:88) at io.quarkus.test.common.TestResourceManager.<init>(TestResourceManager.java:47) at io.quarkus.test.junit.QuarkusTestExtension.createTestInstance(QuarkusTestExtension.java:288) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeTestInstanceFactory(ClassTestDescriptor.java:299)

The test classes are located in build/classes/kotlin/test

Did you find a way to fix this issue ? I have the same problem. I can't run my tests.

Also Quarkus doesn't support advanced Gradle configurations. Like if you put everything in implementation instead of compile it won't work (at least for sub-project/module). And https://docs.gradle.org/current/userguide/feature_variants.html
Feature variants are not supported. If I declare quarkus runtime as a feature, the server starts-up with zero extensions included. So, Gradle finds the stuff to compile, but apparently Quarkus plugin resolves configurations by name!! instead asking Gradle. So, if config name is not "compile" it doesn't consider it.

Has anyone found a way to fix this?
I'm having the same problem but with project with only Java code. Don't know if it has to do with having MapStruct as apt, but it may be the case where Quarkus Gradle plugin uses only one source directory; it should be changed in a way that it can handle multiple source dirs (eq. source/dirA:source/dirB)

EDIT: Just found out that test passes if running test from terminal. Error is present only if I run platform test with IDEA, but it dissapears when I run it as Gradle test from IDEA.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you!
We are doing this automatically to ensure out-of-date issues does not stay around indefinitely.
If you believe this issue is still relevant please put a comment on it on why and if it truly needs to stay request or add 'pinned' label.

We are making improvements to the Gradle support in other issues. I think this one will be fixed.

Was this page helpful?
0 / 5 - 0 ratings