When adding the Groovy plugin like:
plugins {
id "java"
id "groovy"
id "io.quarkus"
}
then quarkusDev fails with:
❯ ./gradlew clean quarkusDev
> Task :compileJava
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :quarkusDev FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Some problems were found with the configuration of task ':quarkusDev' (type 'QuarkusDev').
> Directory '/Users/marceloverdijk/workspace/demo-backend-quarkus/build/classes/groovy/main' specified for property 'workingDir' does not exist.
> Directory '/Users/marceloverdijk/workspace/demo-backend-quarkus/src/main/groovy' specified for property 'sourceDir' does not exist.
It seems the src/main/groovy folder is expected.
I'm only adding Groovy to run Spock tests from /src/test/groovy.
When creating an empty src/main/groovy folder it keeps complaining about build/classes/groovy/main.
Had a very similar, if not the same issue with Kotlin; it was fixed with 1.1.1.Final so this should be really straightforward 😉
That doesn't seem related to the Quarkus plugin. It looks like you need to set the source directories like in https://docs.gradle.org/current/userguide/groovy_plugin.html#sec:changing_groovy_project_layout
@gastaldi I never had to configure the Groovy source directories explicitly for any project so far.
And in those projects there were no src/main/groovy folders either, only src/test/groovy.
Btw even creating an empty src/main/groovy folder I still get:
Directory '/Users/marceloverdijk/workspace/demo-backend-quarkus/build/classes/groovy/main' specified for property 'workingDir' does not exist.
But I will have another look this evening.
Interesting. I'll have a closer look. Thanks for the feedback
Can you share a small reproducer project? That would help a lot.
Sure, will do it this evening.
The following build.gradle works with quarkusDev. There is not much we can do because the error comes from Gradle and happens before the quarkusDev task is executed.
plugins {
id 'java'
id 'groovy'
id 'io.quarkus'
}
repositories {
mavenLocal()
mavenCentral()
}
sourceSets {
main {
groovy {
srcDirs = ['src/main/java']
}
}
}
dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-resteasy'
implementation 'org.codehaus.groovy:groovy-all:2.4.15'
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}
group 'org.acme'
version '1.0-SNAPSHOT'
compileJava {
options.compilerArgs << '-parameters'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
@gastaldi here is an small demo project: https://github.com/marceloverdijk/quarkus-spock
./gradlew clean quarkusDev fails as stated earlier.
I also added the application plugin and executing ./gradlew clean run does not give the problem. The main class runs successfully.
Also when building the runner jar and executing the built jar no problems occur, it seems really related to the quarkusDev task. Where is this tasks based upon?
PS: check the project's README.me for the output of above mentioned commands.
Try adding the following snippet to your build.gradle file:
sourceSets {
main {
groovy {
srcDirs = ['src/main/java']
}
}
}
@gastaldi yes that works, but it is only a workaround I assume?
It also requires implementation 'org.codehaus.groovy:groovy-all:2.4.15' and that's not desired. Groovy is only needed in the test scope.
@marceloverdijk Ah I see what's wrong. I created a PR with the fix: https://github.com/quarkusio/quarkus/pull/6504
Can you give it a try and let me know if that works for you?
Thanks for the reproducer project, that helped a lot :wink:
@gastaldi I've build the code from the PR locally and now I can indeed run quarkusDev without having to define the Groovy sourceSet and adding the Groovy dependency 👍
I've also updated the spock demo project.
It uses 999-SNAPSHOT from your PR.
But adding QuarkusTest does not work unfortunately in combination with Spock.
Probably some Spock extension work is needed like Micronaut has.
I also found https://github.com/quarkusio/quarkus/issues/4797 where @geoand mentioned there is no Spock integration (yet). I spend some evenings this week experimenting with Quarkus using Java, Kotlin, Groovy (using various setups) but I have the same feeling as @mvniekerk that using anything else then Java src and Java (JUnit5) tests could be problematic at this stage. Probably needs some time... ;-)
Those cases can absolutely be made to work flawlessly, it's just that they need some extra attention :)
Yes, that's why I'm posting these issues :-)
Thank you for all your suggestions and help!