Skip to content

processSpring fails with "Cannot choose between the available variants of guava" #286

@eekboom

Description

@eekboom

Trying to get started with code generation.
Created a new gradle subproject with my openapi.yaml and these files straight out of the docs:

build.gradle:

plugins {
    id 'io.openapiprocessor.openapi-processor' version '2023.2'
}

openapiProcessor {
    spring {
        processor 'io.openapiprocessor:openapi-processor-spring:2024.4'
        apiPath "$projectDir/src/api/openapi.yaml"
        targetDir "$projectDir/build/openapi"
        mapping "$projectDir/mapping.yaml"
        parser "INTERNAL"
    }
}

gradle.properties:

org.gradle.jvmargs= \
  --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
  --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

mapping.yaml

openapi-processor-mapping: v7

options:
  package-name: com.acme.foo
  model-name-suffix: Resource
  model-type: record
  enum-type: string
  one-of-interface: true
  bean-validation: jakarta
  generated-date: true
  format-code: true
  javadoc: true
  clear-target-dir: false

compatibility:
  bean-validation-valid-on-reactive: false
  identifier-word-break-from-digit-to-letter: false

map:
# java type mappings

When I run gradle processSpring, this ios the result:

Execution failed for task ':data_consumer:processSpring'.
> Could not resolve all files for configuration ':data_consumer:detachedConfiguration1'.
   > Could not find com.fasterxml.jackson.module:jackson-module-kotlin:.
     Required by:
         project :data_consumer > io.openapiprocessor:openapi-processor-spring:2024.4 > io.openapiprocessor:openapi-processor-core:2024.5
   > Could not resolve com.google.guava:guava:32.1.3-jre.
     Required by:
         project :data_consumer > io.openapiprocessor:openapi-processor-spring:2024.4 > io.openapiprocessor:openapi-processor-core:2024.5
      > Cannot choose between the available variants of com.google.guava:guava:33.2.1-jre
        The only attribute distinguishing these variants is 'org.gradle.jvm.environment'. Add this attribute to the consumer's configuration to resolve the ambiguity:
          - Value: 'android' selects variant: 'androidRuntimeElements'
          - Value: 'standard-jvm' selects variant: 'jreRuntimeElements'
> There is 1 more failure with an identical cause. 

I don't know how/where to add the standard-jvm setting.

gradle 8.9, Java 21

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions