Skip to content

ConditionalDependenciesKotlinTest fails if gradlePluginPortal() appears before mavenLocal() #46954

Open
@jskillin-idt

Description

@jskillin-idt

Describe the bug

First, an apology: I normally like to write a bug when I have a probable root cause, but in this case I do not fully understand what is happening. This bug will require further investigation and time investment, which I understand is at a premium. :(

The bug is that Quarkus' ConditionalDependenciesKotlinTest integration tests fail to run in an environment where there are alternative repositories configured, in my case via Gradle's initialization scripts.

A rudimentary glance at the output from Gradle shows that it is trying to pull Kotlin 2.0.21 and 1.9.23 libraries, when it should only be pulling one version.

I've had my own trouble in which Gradle effectively ignores the requested Kotlin plugin version, so I personally abandoned trying to use Kotlin with Gradle. I suspect this may be another casualty of the tight version coupling between Gradle and Kotlin.

I am currently completely unaware as to why the Kotlin libraries pull incorrectly when the repository order is changed, and it may be a misunderstanding on my part that ultimately closes this bug.

Expected behavior

The ConditionalDependenciesKotlinTest passes regardless of the order of repositories.

Actual behavior

ConditionalDependenciesKotlinTest fails:

FAILURE: Build failed with an exception.                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                          
* What went wrong:                                                                                                                           
COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM                                                                                                  
                                                                                                                                             
* Try:                                                                                                                                                                                                                                                                                    
> Run with --debug option to get more log output.                                                                                                                                                                                                                                         
> Run with --scan to get full insights.                                                                                                                                                                                                                                                   
> Get more help at https://help.gradle.org.                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                          
* Exception is:                                                                                                                                                                                                                                                                           
java.lang.NoSuchFieldError: COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM                                                                      
        at org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.getUseClasspathSnapshot(PropertiesProvider.kt:171)                                                                                                                                                                       
        at org.jetbrains.kotlin.gradle.tasks.configuration.BaseKotlinCompileConfig$1.invoke(KotlinCompileConfig.kt:39)                                                                                                                                                                    
        at org.jetbrains.kotlin.gradle.tasks.configuration.BaseKotlinCompileConfig$1.invoke(KotlinCompileConfig.kt:38)                       
        at org.jetbrains.kotlin.gradle.tasks.configuration.TaskConfigAction.execute(AbstractKotlinCompileConfig.kt:188)                                                                                                                                                                   
        at org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider.registerKotlinJVMTask(TasksProvider.kt:102)                                                                                                                                                                              
        at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor.doRegisterTask(Kotlin2JvmSourceSetProcessor.kt:35)                                                                                                                                                             
        at org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor.prepareKotlinCompileTask(KotlinSourceSetProcessor.kt:49)              
        at org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor.<init>(KotlinSourceSetProcessor.kt:39)                                

How to Reproduce?

  1. Edit integration-tests/gradle/src/main/resources/conditional-dependencies-kotlin/settings.gradle.kts and move gradlePluginPortal() to the top of the repository list.
  2. In a clean checkout of Quarkus, run ./mvnw -f devtools/gradle install && ./mvnw -f integration-tests/gradle -Dtest=io.quarkus.gradle.ConditionalDependenciesKotlinTest install

Alternatively, more real to my particular scenario, in place of step 1, if you store this in ~/.gradle/init.gradle and then run step 2, you'll get the same error:

gradle.beforeSettings { settings ->
  settings.pluginManagement {
      repositories {
        gradlePluginPortal()
      }
  }
}

Output of uname -a or ver

Linux 6.6.83 #1-NixOS SMP PREEMPT_DYNAMIC Thu Mar 13 11:58:41 UTC 2025 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.9" 2023-10-17 OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9) OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode, sharing)

Quarkus version or git rev

3.21.0

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

Apache Maven 3.9.9 / Gradle 8.13

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions