<#20965 OpenAPI classpath source ambiguity> Issue ...
# github-notifications
c
#20965 OpenAPI classpath source ambiguity Issue created by alonsodomin Describe the bug When having OpenAPI documents with Java codegen enabled Pants throws a
ClasspathSourceAmbiguity
exception when building the classpath for sources that depend on the Java generated code.
Copy code
ClasspathSourceAmbiguity: More than one JVM classpath provider (CompileJavaSourceRequest, CompileScalaSourceRequest, CoursierFetchRequest, DeployJarClasspathEntryRequest, JvmResourcesRequest, NoopClasspathEntryRequest, ScalaArtifactClasspathEntryRequest) was compatible with the inputs:
  * src/openapi:spec  (openapi_document)
To reproduce this requires (at least) the following backends to be enabled:
Copy code
backend_packages = [
  "pants.backend.experimental.java",
  "pants.backend.experimental.openapi",
  "pants.backend.experimental.openapi.codegen.java",
]
And then having the following targets:
src/openapi/BUILD
Copy code
openapi_document(name="spec", source="openapi_spec.yaml")
`src/java/foo/BUILD`:
Copy code
java_sources(dependencies=["//src/openapi:spec"])
The exception is thrown when running
pants check ::
. I believe this was added after #20695. Pants version 2.22.x (main) OS both Additional info The error message thrown should also be improved as it is showing a list of all the supported
ClasspathEntryRequest
implementations available in Pants, while the ambiguity is created by the fact that
CompileJavaSourceRequest
and
JvmResourcesRequest
are the ones capable of providing a valid classpath entry for the
openapi_document
target. pantsbuild/pants