brave-planet-28195
10/05/2022, 8:44 PMpants
v1 there was a dedicated approach for managing jvm dependencies -> https://v1.pantsbuild.org/3rdparty_jvm.html
In pants
v2 a new concept of dependencies inference is introduced. (https://blog.pantsbuild.org/automatically-unlocking-concurrent-builds-and-fine-grained-caching-on-the-jvm-with-dependency-inference/)
What I'm trying to understand is how pant v2 suggests to handle transitive dependencies & conflicts? Should transitive dependencies. be listed explicitly?witty-crayon-22786
10/05/2022, 9:32 PMjvm_artifact
targets: they are available at compile time.import
statement for a thirdparty dependency, then it is not actually transitive: for inference to work, everything with an import
statement likely needs to actually have a declared jvm_artifact
brave-planet-28195
10/05/2022, 10:03 PMimport
statements can help resolve direct dependencies,
right? (scan imports and find corresponding jvm_artifacts)
but what about runtime dependencies -> they can't be inferred cause they are absent in import
statements....
For example to compile very simple Hello world application that uses cats-effect its enough to only have cats-effect
But when running that application we will face ClassNotFound
exception cause there needs to be also cats-core
in classpath.witty-crayon-22786
10/05/2022, 10:04 PMcats-core
not a dependency of cats-effect
…?brave-planet-28195
10/05/2022, 10:10 PMisnot a dependency ofcats-core
…?cats-effect
cats-effect
depends on cats-core
For example if I run same simple app via sbt
and only list cats-effect
as application dependency - cats-core
will also be loaded transitively and added to classpath (which leads to another problem of possible conflicts)witty-crayon-22786
10/05/2022, 10:13 PMcats-core
a provided
dep of cats-effect
perhaps?
which version of cats-effect
are you using, and which pants goal are you seeing this with?brave-planet-28195
10/05/2022, 10:15 PMwitty-crayon-22786
10/05/2022, 10:15 PMcats-core
is not a dep of cats-effect
afaict: https://repo1.maven.org/maven2/org/typelevel/cats-effect_3/3.4-389-3862cf0/cats-effect_3-3.4-389-3862cf0.pombrave-planet-28195
10/05/2022, 10:15 PMcats-effect_2.13: 3.3.14
witty-crayon-22786
10/05/2022, 10:16 PMbrave-planet-28195
10/05/2022, 10:18 PMcats-effect
depends on cats-effect-kernel
(compile dependency)
2. cats-effect-kernel
depends on cats-core
(compile dependency)witty-crayon-22786
10/05/2022, 10:18 PM$ cs resolve org.typelevel:cats-effect_2.13:3.3.14
org.scala-lang:scala-library:2.13.7:default
org.typelevel:cats-core_2.13:2.7.0:default
org.typelevel:cats-effect-kernel_2.13:3.3.14:default
org.typelevel:cats-effect-std_2.13:3.3.14:default
org.typelevel:cats-effect_2.13:3.3.14:default
org.typelevel:cats-kernel_2.13:2.7.0:default
org.typelevel:simulacrum-scalafix-annotations_2.13:0.5.4:default
brave-planet-28195
10/05/2022, 10:21 PMcats-core
shouldn't be defined in dependencies when running app that already has cats-effect
in dependencies
however that doesn't seem to work like that currently in pants v2witty-crayon-22786
10/05/2022, 10:22 PMbrave-planet-28195
10/05/2022, 10:22 PMrun
witty-crayon-22786
10/05/2022, 10:22 PMbrave-planet-28195
10/05/2022, 10:22 PM./pants run src/scala...../service:bin
2.13.0
witty-crayon-22786
10/05/2022, 10:24 PMpackage
instead, and then unzip the resulting jar, do you see cats-core’s classfiles in there?./pants package src/scala...../service:bin
brave-planet-28195
10/05/2022, 10:28 PMwitty-crayon-22786
10/05/2022, 10:41 PMbrave-planet-28195
10/05/2022, 10:50 PMscala-lang
) -> cats-effect
cats-core
or anything explicitly...cats-core
to 3rdparty/jvm/org/typelevel/BUILD
with version 2.8.0
- I can't run Main
anymore.
jvm_artifact(
name="cats-core",
group="org.typelevel",
artifact="cats-core_2.13",
version="2.8.0",
packages=["cats.**"],
)
Exception in thread "main" java.lang.NoClassDefFoundError: cats/kernel/Semigroup
witty-crayon-22786
10/05/2022, 10:55 PM3.3.14
must not be compatible with 2.8.0
brave-planet-28195
10/05/2022, 10:55 PM2.8.0
The thing is that cats-effect:3.3.14
depends on cats-core
2.7.0
So that creates a conflictwitty-crayon-22786
10/05/2022, 10:57 PMbrave-planet-28195
10/05/2022, 10:58 PMfs2
and rest... cats-core:2.8.0
will appear on the radar again)witty-crayon-22786
10/05/2022, 10:58 PMcoursier
brave-planet-28195
10/05/2022, 11:00 PMsbt
for example there is a StrictMode
or something like that... in that case build will failwitty-crayon-22786
10/05/2022, 11:01 PMcoursier
, but it would be fairly easy to add…brave-planet-28195
10/05/2022, 11:05 PMThe CLI now accepts options to enable and configure the new strict conflict manager.
--strict enables the strict conflict manager,
witty-crayon-22786
10/05/2022, 11:08 PMfast-nail-55400
10/06/2022, 1:24 AMbrave-planet-28195
10/06/2022, 8:56 AMcoursier
output of resolve
for dependencies of specific target./pants resolve src/scala..../service:bin
and coursier resolution tree is presented