-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Scala 2.13 support introduced in #8624 makes it impossible to use the generated code as a submodule in a 2.13 project.
openapi-generator version
5.2.0-SNAPSHOT
OpenAPI declaration file content or url
Not relevant
Generation Details
It should be possible to use the generated code as an sbt module, as documented in the openapi-generator plugin for sbt. That's however not possible since the crossScalaVersions
option was introduced. If we add a module dependency on the root project:
lazy val generated = project.in(file("generated"))
.settings(
scalaVersion := "2.13.6",
crossScalaVersions := Seq("2.13.6"),
openApiInputSpec := "conf/OpenApiSpec/v1.0/spec.yaml",
openApiConfigFile := "conf/OpenApiSpec/v1.0/config.yaml",
openApiValidateSpec := SettingDisabled,
openApiGenerateModelTests := SettingEnabled,
).enablePlugins(OpenApiGeneratorPlugin)
lazy val root = (project in file("."))
.aggregate(generated)
.dependsOn(generated)
The overrides will have no effect, and any attempt to build the project will fail due to multiple scala versions being included.
[error] (update) Conflicting cross-version suffixes in: org.openapitools:openapi-client
[my-project] $ scalaVersion
[info] generated / scalaVersion
[info] 2.12.13
[info] scalaVersion
[info] 2.13.6
Steps to reproduce
Clone master of https://github.com/OpenAPITools/sbt-openapi-generator
Update generator version in the root build.sbt to:
libraryDependencies += "org.openapitools" % "openapi-generator" % "5.2.0-SNAPSHOT"
Set scala version to 2.13.6
in src/sbt-test/sbt-openapi-generator/simple/build.sbt
Open sbt shell in root and run scripted
. The test will fail with the following error:
[error] Modules were resolved with conflicting cross-version suffixes in <edited>
[error] org.openapitools:openapi-client _2.13, _2.12
[error] stack trace is suppressed; run last update for the full output
[error] (update) Conflicting cross-version suffixes in: org.openapitools:openapi-client
Related issues/PRs
Suggest a fix
This should be possible to fix by somehow omitting the 2.12
code version from the module dependency, but I've spent a lot of time searching on a way to exclude this dependency via sbt and I can't figure out how to do it. With that said, it's probably best not to force every Scala 2.13 user to try to find out how to do it, so I'd say we should always build only one scala version, either a default one or a parent one if configured. Ideally it would something akin to:
scalaVersion := sys.props.getOrElse("SCALA_VERSION", default = "2.12.8")
Please let me know your thoughts on this, I'm happy to submit a PR with a fix, but I need some guidance on how to solve this best