2
votes

I am trying to run the simple 'getting-started'-type gradle project with quarkus and my unit test fails everytime with this error

Caused by: io.quarkus.bootstrap.BootstrapException: Failed to locate project pom.xml for C:\Users\myuser\IdeaProjects\myproj\build\classes\java\main

Followed instructions here https://quarkus.io/guides/gradle-tooling Any suggestions or thoughts on what is going on?

Gradle version details

Gradle 5.4

Build time:   2019-04-16 02:44:16 UTC
Revision:     a4f3f91a30d4e36d82cc7592c4a0726df52aba0d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          11.0.2 (Oracle Corporation 11.0.2+9)
OS:           Windows 10 10.0 amd64
1
Version 0.14.0 is going to be released soon which I think fixes the problem. - geoand
Thanks @geoand. I tried that too today and same behavior. - vpram86
Could then open an issue please if there isn't already one? - geoand
Ok I opened one ty @geoand - vpram86
Thanks! Just for reference, here is the issue: github.com/quarkusio/quarkus/issues/2307 - geoand

1 Answers

1
votes

btw. the problem is still open (current version 0.19.1) and issue (2307) is still unresolved.

The reason is that @QuarkusTest points to the QuarkusTestExtension, which in BootstrapClassLoaderFactory.newDeploymentClassLoader attempts to resolve local project with Maven.

We have options:

  • wait for official solution (see issue)
  • write own extension overriding BootstrapClassLoaderFactory to "understand" gradle project structure
  • apply a workaround (for time being), i.e. generate pom.xml from gradle build

Workaround

in build.grade:

plugins {
    id 'java'
    id 'io.quarkus' version '0.19.1'
    // ...
    id 'maven-publish'
}
// ...
publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            // augment your pom here if necessary
        }
    }
}
// ...
task createPom(type: Copy) {
    description 'This is workaround to generate pom.xml, needed for @QuarkusTest tests.'
    dependsOn('generatePomFileForMavenJavaPublication')
    from "$buildDir/publications/mavenJava/pom-default.xml"
    into '.'
    rename('pom-default.xml', 'pom.xml')
}

Note:

  • use 'maven-publish', not obsolete 'maven' plugin.
  • do not forget to apply ./gradlew createPom on dependencies changes