How to get setting value of another project in multi-project build

0

I`m not sure that I get right the concept of sbt workflow. I have multi-project structure of an arbitrary depth in my build.sbt Now I want to define task which can show me library dependencies of project current subprojects depends on. Or, in common: is there any way to get setting value of another project?

I`m trying to do somthing like this:

val hierarchyDeps = taskKey[Seq[ModuleID]]("")
val hierarchyDepsImpl = Def.task {
  loadedBuild.value.allProjectRefs.flatMap { case (projectRef, resolvedProject) =>
    (projectRef / libraryDependencies).value
  }
}

val cmn = project.in(file("cmn"))
val subA = project.in(file("sub_a")).dependsOn(cmn).settings(hierarchyDeps := hierarchyDepsImpl.value)
val subB = project.in(file("sub_b")).dependsOn(cmn).settings(hierarchyDeps := hierarchyDepsImpl.value)

but getting java.lang.IllegalArgumentException:

java.lang.IllegalArgumentException: Could not find proxy for val projectRef: sbt.ProjectRef in List(value projectRef, value $anonfun, method $anonfun$hierarchyDepsImpl$1, value hierarchyDepsImpl, object $5879c5c8d08c0b0b007a, package <empty>, package <root>) (currentOwner= value hierarchyDepsImpl )
sbt scala
2021-11-24 06:33:05
1

0

I think you are trying to do something outside of sbt philosophy.

You should define a task for each project that does something. Then add aggregate to your root project with the list of all sub-projects. Thus, when you call sbt taskName, it will call taskName for all sub-projects in aggregate.

Also, what you want to do can be just done with following

sbt "show libraryDependencies"

given that you defined aggregate for your root project

val root = project.in(file(".")).aggregate(cmn, subA, subB)

2021-11-24 09:35:32

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................