JetBrains / package-search-gradle-plugins

Gradle plugins for Docker, Terraform and Liquibase.
Apache License 2.0
32 stars 8 forks source link

Coexistence with Java plugin #19

Open mranders-hltv opened 2 years ago

mranders-hltv commented 2 years ago

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?

lamba92 commented 2 years ago

Indeed it is intentional. I would recommend you to create separate modules, one for you Java project and one for Terraform. This would also make it easier to share lambdas.

mranders-hltv commented 2 years ago

Thank you for your answer. I haven't experienced this kind of issue before with other plugins like Node or Docker.

Out of curiosity, what is the reasoning for this limitation? Is it a technical thing with respect to the lambdas, or something else? Which potential issues could arise if the Terraform plugin was applied in a Gradle project that also applies the Java plugin?