package-search-gradle-plugins icon indicating copy to clipboard operation
package-search-gradle-plugins copied to clipboard

Coexistence with Java plugin

Open mranders-hltv opened this issue 2 years ago • 2 comments

I ran into an issue when attempting to apply both the Java and Terraform plugins, and declaring an implementation dependency:

plugins {
    id("java")
    id("org.jetbrains.gradle.terraform") version "1.4.2"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
}

This fails with the following error:

Could not create task ':generateMainExecutionContext'.
Could not resolve all files for configuration ':terraformMainRuntimeElements'.
No variants of org.junit.jupiter:junit-jupiter-api:5.8.2 match the consumer attributes:
  - org.junit.jupiter:junit-jupiter-api:5.8.2 variant samplessources:
      - Incompatible because this component declares a runtime of a component, packaged as a jar and the consumer needed a usage of 'terraform' of a component, with the library elements 'tf-zip-archive'

I guess it is because the Terraform plugin uses the implementation configuration (like the Java plugin does), and becomes confused when a non-Terraform project is added.

In the ideal world, I would like to have a main module, which depends on the required Java/Kotlin modules, and also describes the terraform structure needed to deploy the code, along with the appropriate Gradle tasks for doing so.

Is it intentional that the plugin can't coexist with the Java plugin?

mranders-hltv avatar May 24 '22 12:05 mranders-hltv