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 quarkusAppPartsBuild task failure #3565

Open
deepakkapoor23 opened this issue Jun 25, 2024 · 18 comments
Open

Gradle quarkusAppPartsBuild task failure #3565

deepakkapoor23 opened this issue Jun 25, 2024 · 18 comments
Assignees

Comments

@deepakkapoor23
Copy link

deepakkapoor23 commented Jun 25, 2024

Describe the bug

Build fails with gradle after quarkus version upgrade while it build fine with Maven

Quarkus platform and plugin version is 3.8.5

Expected behavior

Gradle build should work same as Maven and produce the same output.

Actual behavior

Gradle build fails with the following error:

Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step org.drools.quarkus.deployment.DroolsAssetsProcessor#generateSources threw an exception: java.lang.UnsupportedOperationException
at java.base/java.util.AbstractCollection.add(AbstractCollection.java:251)
at org.drools.quarkus.deployment.DroolsAssetsProcessor.generateSources(DroolsAssetsProcessor.java:116)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)

    at io.quarkus.builder.Execution.run(Execution.java:123)
    at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
    at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
    at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:330)
    ... 26 more

Caused by: java.lang.UnsupportedOperationException
at org.drools.quarkus.deployment.DroolsAssetsProcessor.generateSources(DroolsAssetsProcessor.java:116)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)

How to Reproduce?

Create a gradle project with kogito dependencies and plugin and run the build as follows:

gradlew clean build --no-build-cache --stacktrace

Output of uname -a or ver

Windows

Output of java -version

17

GraalVM version (if different from Java)

No response

Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)

999-SNAPSHOT

Build tool (ie. output of mvnw --version or gradlew --version)

gradle 8.6

Additional information

Intermittently missing classes from org.jbpm and org.drools packages are also reported in the build log with NoClassDefFoundError

@gitgabrio
Copy link
Contributor

Hi @deepakkapoor23 : could you please include a minimal reproducer, i.e. a very trimmed down project that recreates the problem you are facing ? Thanks!

@gitgabrio gitgabrio self-assigned this Jun 26, 2024
@deepakkapoor23
Copy link
Author

deepakkapoor23 commented Jun 28, 2024

kogito-reproducer.zip
Please find attached kogito-reproducer project with both maven and gradle builds. The maven build completes successfully but gradle fails for the same set of properties and dependencies.

Commands:

mvnw clean package -U

gradlew clean build --no-build-cache

@deepakkapoor23
Copy link
Author

I am seeing too many issues with gradle build that run ok with Maven, e.g.

  1. open api spec ref uri throw URISyntaxException during build with gradle but not with Maven
  2. gradle build throws "SRMSG00207: Some components are not connected to either downstream consumers" error for http connectors while it works fine with Maven

There has to be something wrong fundamentally with the gradle plugin, it may be pulling in stale dependencies.

@gitgabrio
Copy link
Contributor

@deepakkapoor23
I'll try to take a look ASAP

@deepakkapoor23
Copy link
Author

@gitgabrio did you get a chance to look into it? Its a showstopper for me if I cant build a kogito project using Gradle

@MichaelCarolan
Copy link

@gitgabrio if you can look into this it would be greatly appreciated. Our team would like to use this upcoming Kogito release, however if we cannot build using Gradle this is a major blocker for our use of the Kogito framework.

@gitgabrio
Copy link
Contributor

gitgabrio commented Jul 4, 2024 via email

@deepakkapoor23
Copy link
Author

I dont see the original error anymore (maybe some other commit fixed it already) and I am able to build the project after commenting out the following dependencies:

  1. //library('kieAddonsEventsDmn', 'org.kie', 'kie-addons-quarkus-events-decisions').versionRef('kie') - fails to inject decisionModels bean
  2. //library('kieAddonsTracingDmn', 'org.kie', 'kie-addons-quarkus-tracing-decision').versionRef('kie') - has some issue with the pom

However when I run the built binary, I have been noticing issues/inconsistencies compared to a Maven build. I listed a couple of examples in my comment earlier. Hopefully, these can be addressed before the next release.

@deepakkapoor23
Copy link
Author

@gitgabrio I tried looking at the codegen module but couldnt figure out whats different between gradle and maven builds. Would you be able to look at it and point out why they would both produce different artifacts with inconsistent behavior?
Or at least point me in some direction?

@deepakkapoor23
Copy link
Author

@fjtirado @gitgabrio See a comparison of gradle vs maven builds for generated sources for one of the examples.
The gradle build has the entire kogito directory missing and hence has no controllers or emitters for messaging.
Any idea why this could be happening?

Gradle build output:
image

Maven build output:
image

@deepakkapoor23
Copy link
Author

deepakkapoor23 commented Jul 10, 2024

The only plugin I have been applying in gradle is:
id 'io.quarkus'

and this was working ok with kogito 1.43.0 and quarkus 2.16.12

Is there and additional kogito gradle plugin that must be applied with quarkus 3?

@deepakkapoor23
Copy link
Author

deepakkapoor23 commented Jul 11, 2024

@gitgabrio looking at KogitoAssetsProcessor

Its definitely something to do with output paths.

I tried setting the system property org.gradle.appname=gradleapp which made no difference.

If I have no java source present in the project, it does not generate any files at all.
I had to place a dummy java annotation file to see what it generates and this is how it looks, the target folder below seems to be wrong (as if it was running Maven). For Gradle, these files should be under build/classes/java/quarkus-generated-sources instead of build/classes/java/main/target/generated-sources

image

No logging in KogitoAssetsProcessor makes it difficult to see whats going on and there is no way for me to debug.

Also, the one test for this class seems insufficient when its only asserting on root paths and not actually generating any sources to see if they end up at right path.

@deepakkapoor23
Copy link
Author

I managed to change the location where generated files are written to the disk by overriding these properties for GeneratedFileWriter.
But I still can't figure out why other generators like ProcessCodegen won't fire?

kogito.codegen.sources.directory=../quarkus-generated-sources/kogito
kogito.codegen.resources.directory=../quarkus-generated-resources/kogito

image

@dfiai
Copy link

dfiai commented Jul 18, 2024

I'm experiencing the same issue with version 10.x and 999 snapshots while building Serverless Workflow. The process code is not being generated... only these 4 files:

image

@dfiai
Copy link

dfiai commented Aug 5, 2024

Hi @deepakkapoor23 I have the same issue, as a workaround I did use maven-publish plugin

build.gradle.kts

val javaVersion: String by project
val quarkusVersion: String by project
val kogitoVersion: String by project
val cloudEventVersion: String by project
val kotlinVersion: String by project

plugins {
  kotlin("jvm")
  kotlin("plugin.allopen")
  id("io.quarkus")
  id("maven-publish")
}

repositories {
  mavenCentral()
  mavenLocal()
  maven {
    url = uri("https://repository.apache.org/content/groups/public")
  }
}

dependencies {
  implementation(enforcedPlatform("io.quarkus.platform:quarkus-bom:$quarkusVersion"))
  implementation("io.quarkus:quarkus-kotlin")
  implementation("io.quarkus:quarkus-arc")
  implementation("io.quarkus:quarkus-resteasy")
  implementation("io.quarkus:quarkus-resteasy-jackson")
  implementation("io.quarkus:quarkus-smallrye-health")
  implementation("io.quarkus:quarkus-smallrye-reactive-messaging-kafka")
  implementation("io.quarkus:quarkus-container-image-jib")
  implementation("io.quarkus:quarkus-opentelemetry")
  implementation("io.quarkus:quarkus-micrometer-registry-prometheus")
  implementation("io.quarkus:quarkus-smallrye-openapi")

  implementation(enforcedPlatform("org.kie.kogito:kogito-bom:$kogitoVersion"))
  implementation("org.apache.kie.sonataflow:sonataflow-quarkus")
  implementation("org.kie:kie-addons-quarkus-messaging")
  implementation("org.kie:kie-addons-quarkus-events-process")
  implementation("org.kie:kie-addons-quarkus-persistence-infinispan")
  implementation("org.kie:kie-addons-quarkus-monitoring-prometheus")
  implementation("org.kie:kie-addons-quarkus-source-files")
  implementation("org.kie:kie-addons-quarkus-process-management")

  implementation("io.cloudevents:cloudevents-kafka:$cloudEventVersion")
}

group = "io.mycompany"
version = "0.0.1-SNAPSHOT"

java {
  sourceCompatibility = JavaVersion.toVersion(javaVersion)
  targetCompatibility = JavaVersion.toVersion(javaVersion)
}

tasks.withType<Test> {
  systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
}

allOpen {
  annotation("jakarta.ws.rs.Path")
  annotation("jakarta.enterprise.context.ApplicationScoped")
  annotation("jakarta.persistence.Entity")
  annotation("io.quarkus.test.junit.QuarkusTest")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
  kotlinOptions.jvmTarget = javaVersion
  kotlinOptions.javaParameters = true
}

publishing {
  publications {
    create<MavenPublication>("maven") {
      groupId = "io.mycompany"
      artifactId = "mykogito"
      version = "0.0.1-SNAPSHOT"

      from(components["java"])

      pom.withXml {
        asNode().appendNode("repositories").apply {
          appendNode("repository").apply {
            appendNode("id", "central")
            appendNode("name", "Maven Central")
            appendNode("url", "https://repo.maven.apache.org/maven2")
          }
          appendNode("repository").apply {
            appendNode("id", "apache")
            appendNode("name", "Apache Public Repository")
            appendNode("url", "https://repository.apache.org/content/groups/public")
          }
        }
        asNode().appendNode("build").appendNode("plugins").apply {
          appendNode("plugin").apply {
            appendNode("groupId", "io.quarkus")
            appendNode("artifactId", "quarkus-maven-plugin")
            appendNode("version", quarkusVersion)
            appendNode("executions").appendNode("execution").apply {
              appendNode("goals").appendNode("goal", "build")
            }
          }
          appendNode("plugin").apply {
            appendNode("groupId", "org.jetbrains.kotlin")
            appendNode("artifactId", "kotlin-maven-plugin")
            appendNode("version", kotlinVersion)
            appendNode("executions").appendNode("execution").apply {
              appendNode("phase", "compile")
              appendNode("goals").appendNode("goal", "compile")
            }
          }
          appendNode("plugin").apply {
            appendNode("groupId", "org.jetbrains.kotlin")
            appendNode("artifactId", "kotlin-maven-allopen")
            appendNode("version", kotlinVersion)
            appendNode("configuration").apply {
              appendNode("compilerPlugins").appendNode("plugin", "all-open")
              appendNode("pluginOptions").apply {
                appendNode("option", "all-open:annotation=jakarta.ws.rs.Path")
                appendNode(
                  "option", "all-open:annotation=jakarta.enterprise.context.ApplicationScoped"
                )
                appendNode("option", "all-open:annotation=jakarta.persistence.Entity")
                appendNode("option", "all-open:annotation=io.quarkus.test.junit.QuarkusTest")
              }
            }
          }
        }
      }
    }
  }
}

gradle.properties

# Gradle properties
org.gradle.jvmargs=-Xmx2048m

javaVersion=17
cloudEventVersion=2.3.0
kogitoVersion=10.0.999-20240728-SNAPSHOT
kotlinVersion=1.9.22
quarkusVersion=3.8.4

# workaround: Quarkus Kogito plugin does not recognize Gradle build type
systemProp.org.gradle.appname=gradle

run generatePomFileFromMavenPublication to get pom.xml inside build/publications/maven
image

mvn package should output required artifacts

@mcruzdev
Copy link
Contributor

Hi @gitgabrio how are you? Are you working on this issue? If not, can I get this one?

@gitgabrio
Copy link
Contributor

gitgabrio commented Aug 20, 2024

Hi @mcruzdev please, do: it would be greatly appreciated!
I can't work at it right now.
Feel free to ping me on zulip channel whatever question you may have, or even if you want to share your initial approach before investing too much time.
My personal concern is to be able, in the long term, to unify the different code-paths (spring vs quarkus, maven vs gradle) as much as possible

@mcruzdev
Copy link
Contributor

Thank you @gitgabrio, I will take this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

5 participants