Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8661175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:26:08+00:00 2026-06-12T16:26:08+00:00

How to access the map of all sbt Setting[T] or whatever container it contants

  • 0

How to access the map of all sbt Setting[T] or whatever container it contants them with all their settings dependencies?

I want to print them out, all of them and with their dependencies as well.
The output should look as follows:

setting(ScopedKey(Scope(Select(ThisBuild),Global,Global,Global),managed-directory))
    ScopedKey(Scope(Select(ThisBuild),Global,Global,Global),base-directory)
        ScopedKey(Scope(Select(ThisBuild),Global,Global,Global),this-project)
...

Below is SBT build definition I am using to do this.

The this-project key is not found in all settings. Where is it stored?

import sbt._
import sbt.Logger
import Keys._
import PlayProject._

object TheBuild extends Build {

  lazy val howItWorksProject = Project(
    id = "howItWorks",
    base = file("./modules/howItWorks")
  )

  val projDef: ProjectDefinition[_] = howItWorksProject
  var count  = 0

  def printSettingsDependencies(setting: Setting[_], settings: Seq[Setting[_]], indent: String): Unit = {
    println("debug printSettingsDependencies start" + (count+=1))
    println(setting)
    println("debug setting =" + setting)
    println("debug setting.dependencies = " + setting.dependencies)

    setting.dependencies.foreach {
      n =>
        println("debug it = " + n)
        println("debug finding ...")
        val settingOption = settings.find {
          it =>
            println("\t"+it.key.key.label + "?=" + n.key.label)
            it.key.key.label == n.key.label
        }
        println("debug found = "+settingOption)
        println(indent + settingOption)
        printSettingsDependencies(settingOption.get, settings, indent + indent)
    }
  }
}

An inspect this-project output:

> inspect this-project
[info] Setting: sbt.ResolvedProject = Project(id: howItWorks, base: C:\Users\pawel\workspace\kody\ria-template\modules\howItWorks, aggregate: List(), dependencies: List(), delegates: List(), configurations: List(compile, runtime, test, provided, optional))
[info] Description:
[info]  Provides the current project for the referencing scope.
[info] Provided by:
[info]  {file:/C:/Users/pawel/workspace/kody/ria-template/}howItWorks/*:this-project
[info] Reverse dependencies:
[info]  *:ivy-configurations
[info]  *:base-directory
[info]  *:name
[info] Delegates:
[info]  *:this-project
[info]  {.}/*:this-project
[info]  */*:this-project

An inspect base-directory output:

> inspect base-directory
[info] Setting: java.io.File = C:\Users\pawel\workspace\kody\ria-template\modules\howItWorks
[info] Description:
[info]  The base directory.  Depending on the scope, this is the base directory for the build, project, configuration, or task.
[info] Provided by:
[info]  {file:/C:/Users/pawel/workspace/kody/ria-template/}howItWorks/*:base-directory
[info] Dependencies:
[info]  *:this-project
[info] Reverse dependencies:
[info]  *:ivy-paths
[info]  *:target
[info]  *:unmanaged-base
[info]  *:runner
[info]  *:source-directory
[info] Delegates:
[info]  *:base-directory
[info]  {.}/*:base-directory
[info]  */*:base-directory
[info] Related:
[info]  {.}/*:base-directory

show sbt-version

> show sbt-version
[info] 0.11.3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:26:10+00:00Added an answer on June 12, 2026 at 4:26 pm

    I think this is what you need:

    import sbt._
    import Keys._
    
    object TheBuild extends Build {
    
        lazy val allSettings = TaskKey[Seq[sbt.Project.Setting[_]]]("all-settings", "")
    
        lazy val printIt = TaskKey[Unit]("print-it", "")
    
        lazy val testSettings = Defaults.defaultSettings ++ Seq(
            allSettings <<= (state) map { s =>
                val extracted = Project.extract(s)
                import extracted._
                structure.settings
            },
    
            printIt <<= (allSettings) map { all =>
                // there are more than one base-directories with different scopes, not all of them have the dependencies
                val baseDirectories = all.filter(s => s.key.key.label == "base-directory" && !s.dependencies.isEmpty)
                // pick the first one to demonstrate this works
                printSettingsDependencies(baseDirectories(0), all, "\t")
            })
    
        def printSettingsDependencies(setting: Setting[_], settings: Seq[Setting[_]], indent: String): Unit = {
            println(indent + setting)
    
            setting.dependencies.foreach { n =>
                val settingOption = settings.find { _.key.key.label == n.key.label }
                if (settingOption.isDefined) {
                    printSettingsDependencies(settingOption.get, settings, indent + indent)
                }
            }
        }
    
        lazy val howItWorksProject: Project = Project("howItWorks", file(".")) settings (testSettings: _*)
    }
    

    Output:

    > print-it
        setting(ScopedKey(Scope(Select(ProjectRef(file:/Users/balagez/Sites/test/,howItWorks)),Global,Global,Global),base-directory)) at NoPosition
            setting(ScopedKey(Scope(Select(ProjectRef(file:/Users/balagez/Sites/test/,howItWorks)),Global,Global,Global),this-project)) at NoPosition
    [success] Total time: 0 s, completed Oct 12, 2012 7:50:29 PM
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have the following map called allLang[:] when I print out all the
A Map maps from keys to values and provides quick access based on the
When you use a map in a program with concurrent access, is there any
We know that if we try to access a nonexistent key of std::map with
I have intialized Hash map inside static block, I need to access the hashmap
Consider a std::map<const char *, MyClass*> . How do I access a member (variable
Access denied for user 'root '@'localhost' (using password: YES) Yes, this error is all
I'm wondering if it's possible to access all of the userdata tables (is it
I have map where each key is a String. To access a value I
I'm trying to authenticate access to all resources on my server via HTTP Basic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.