forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support explicit dependencies with scala_artifact (pantsbuild#19187)
This PR prevents scala_artifacts to be matched by the JvmArtifactFieldSet and provides with an implementation of ClasspathEntryRequest
- Loading branch information
1 parent
a34feab
commit 8d0a4ce
Showing
4 changed files
with
252 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# This lockfile was autogenerated by Pants. To regenerate, run: | ||
# | ||
# pants internal-generate-test-lockfile-fixtures :: | ||
# | ||
# --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE --- | ||
# { | ||
# "version": 1, | ||
# "generated_with_requirements": [ | ||
# "org.scala-lang:scala-library:2.13.8,url=not_provided,jar=not_provided", | ||
# "org.typelevel:cats-core_2.13:2.9.0,url=not_provided,jar=not_provided" | ||
# ] | ||
# } | ||
# --- END PANTS LOCKFILE METADATA --- | ||
|
||
[[entries]] | ||
directDependencies = [] | ||
dependencies = [] | ||
file_name = "org.scala-lang_scala-library_2.13.10.jar" | ||
|
||
[entries.coord] | ||
group = "org.scala-lang" | ||
artifact = "scala-library" | ||
version = "2.13.10" | ||
packaging = "jar" | ||
[entries.file_digest] | ||
fingerprint = "e6ca607c3fce03e8fa38af3374ce1f8bb098e316e8bf6f6d27331360feddb1c1" | ||
serialized_bytes_length = 5949244 | ||
[[entries]] | ||
file_name = "org.typelevel_cats-core_2.13_2.9.0.jar" | ||
[[entries.directDependencies]] | ||
group = "org.scala-lang" | ||
artifact = "scala-library" | ||
version = "2.13.10" | ||
packaging = "jar" | ||
|
||
[[entries.directDependencies]] | ||
group = "org.typelevel" | ||
artifact = "cats-kernel_2.13" | ||
version = "2.9.0" | ||
packaging = "jar" | ||
|
||
[[entries.dependencies]] | ||
group = "org.scala-lang" | ||
artifact = "scala-library" | ||
version = "2.13.10" | ||
packaging = "jar" | ||
|
||
[[entries.dependencies]] | ||
group = "org.typelevel" | ||
artifact = "cats-kernel_2.13" | ||
version = "2.9.0" | ||
packaging = "jar" | ||
|
||
|
||
[entries.coord] | ||
group = "org.typelevel" | ||
artifact = "cats-core_2.13" | ||
version = "2.9.0" | ||
packaging = "jar" | ||
[entries.file_digest] | ||
fingerprint = "1a4beb49987dea5c5028b2950a1fbc23c43978f247b43b4f8f21d1613870565a" | ||
serialized_bytes_length = 6055599 | ||
[[entries]] | ||
file_name = "org.typelevel_cats-kernel_2.13_2.9.0.jar" | ||
[[entries.directDependencies]] | ||
group = "org.scala-lang" | ||
artifact = "scala-library" | ||
version = "2.13.10" | ||
packaging = "jar" | ||
|
||
[[entries.dependencies]] | ||
group = "org.scala-lang" | ||
artifact = "scala-library" | ||
version = "2.13.10" | ||
packaging = "jar" | ||
|
||
|
||
[entries.coord] | ||
group = "org.typelevel" | ||
artifact = "cats-kernel_2.13" | ||
version = "2.9.0" | ||
packaging = "jar" | ||
[entries.file_digest] | ||
fingerprint = "e43384e88928788c7eb6aadf6999e94d4f25d8a9068055636228af0ebbaec0c9" | ||
serialized_bytes_length = 3578309 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import annotations | ||
|
||
from pants.backend.scala.target_types import ScalaArtifactFieldSet | ||
from pants.engine.fs import EMPTY_DIGEST | ||
from pants.engine.rules import Get, collect_rules, rule | ||
from pants.engine.unions import UnionRule | ||
from pants.jvm.compile import ( | ||
ClasspathDependenciesRequest, | ||
ClasspathEntry, | ||
ClasspathEntryRequest, | ||
CompileResult, | ||
FallibleClasspathEntries, | ||
FallibleClasspathEntry, | ||
) | ||
|
||
|
||
class ScalaArtifactClasspathEntryRequest(ClasspathEntryRequest): | ||
field_sets = (ScalaArtifactFieldSet,) | ||
|
||
|
||
@rule | ||
async def scala_artifact_classpath( | ||
request: ScalaArtifactClasspathEntryRequest, | ||
) -> FallibleClasspathEntry: | ||
fallible_entries = await Get(FallibleClasspathEntries, ClasspathDependenciesRequest(request)) | ||
classpath_entries = fallible_entries.if_all_succeeded() | ||
if classpath_entries is None: | ||
return FallibleClasspathEntry( | ||
description=str(request.component), | ||
result=CompileResult.DEPENDENCY_FAILED, | ||
output=None, | ||
exit_code=1, | ||
) | ||
return FallibleClasspathEntry( | ||
description=str(request.component), | ||
result=CompileResult.SUCCEEDED, | ||
output=ClasspathEntry(EMPTY_DIGEST, dependencies=classpath_entries), | ||
exit_code=0, | ||
) | ||
|
||
|
||
def rules(): | ||
return [ | ||
*collect_rules(), | ||
UnionRule(ClasspathEntryRequest, ScalaArtifactClasspathEntryRequest), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters