sbt

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sbt reads the dependency data of sbt builds.

An sbt build is Scala code: what it depends on is only known once sbt has loaded the build and resolved it. The decomposer does not do that. It reads the dependency snapshot sbt-dependency-submission writes for GitHub (githubGenerateSnapshot), which sbt produced from its own resolution, and so it only runs when pointed at one.

Index

Constants

View Source
const (
	RelationshipDirect   = "direct"
	RelationshipIndirect = "indirect"

	ScopeRuntime     = "runtime"
	ScopeDevelopment = "development"
)

The relationships and scopes a resolved dependency can have.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decomposer

type Decomposer struct {
	// SnapshotPath is the dependency snapshot of the build.
	SnapshotPath string
	// contains filtered or unexported fields
}

Decomposer reads the dependency data of sbt builds from a GitHub dependency snapshot.

func New

func New(snapshotPath string) *Decomposer

New returns an sbt decomposer reading the dependency snapshot at snapshotPath.

func (*Decomposer) DefaultOptions

func (d *Decomposer) DefaultOptions() any

DefaultOptions returns nothing: the decomposer takes no driver options, the snapshot is what configures it.

func (*Decomposer) Extract

func (d *Decomposer) Extract(opts *api.DecomposerOptions) (*sbom.NodeList, error)

Extract builds the dependency graph of the build from the snapshot.

func (*Decomposer) FindCodeBases

func (d *Decomposer) FindCodeBases(index *code.PathIndex) ([]string, error)

FindCodeBases locates the build the snapshot describes.

A tree can hold many sbt builds (scripted test fixtures carry their own build.sbt) but a snapshot describes one. Its manifests name the build file relative to the workspace, so the candidates are the directories holding a build.sbt at that path, and of those the shallowest: the workspace itself when the build is at its root.

func (*Decomposer) Requirements

func (d *Decomposer) Requirements(_ *api.DecomposerOptions) []api.Requirement

Requirements returns nothing: sbt already ran, reading its output is pure Go and offline.

type DependencyNode

type DependencyNode struct {
	PackageURL   string         `json:"package_url"`
	Metadata     map[string]any `json:"metadata,omitempty"`
	Relationship string         `json:"relationship,omitempty"`
	Scope        string         `json:"scope,omitempty"`
	Dependencies []string       `json:"dependencies,omitempty"`
}

DependencyNode is one resolved module. Its dependencies are keys of the manifest's resolved map, as sbt references modules (organization:name:revision).

type Detector

type Detector struct {
	Name    string `json:"name"`
	URL     string `json:"url"`
	Version string `json:"version"`
}

Detector names the tool that generated the snapshot.

type FileInfo

type FileInfo struct {
	SourceLocation string `json:"source_location,omitempty"`
}

FileInfo points to the build file the manifest was read from, relative to the workspace root.

type Job

type Job struct {
	Correlator string `json:"correlator"`
	ID         string `json:"id"`
	HTMLURL    string `json:"html_url,omitempty"`
}

Job identifies the workflow run that generated the snapshot.

type Manifest

type Manifest struct {
	Name     string                     `json:"name"`
	File     *FileInfo                  `json:"file,omitempty"`
	Metadata map[string]any             `json:"metadata,omitempty"`
	Resolved map[string]*DependencyNode `json:"resolved"`
}

Manifest is the resolution of one project of the build. sbt names it after the project's module, as organization:name:revision with the name cross-versioned (org.scala-lang:scala3-compiler_3:3.9.0).

type Snapshot

type Snapshot struct {
	Version   int                  `json:"version"`
	Job       *Job                 `json:"job,omitempty"`
	Sha       string               `json:"sha"`
	Ref       string               `json:"ref"`
	Detector  *Detector            `json:"detector,omitempty"`
	Manifests map[string]*Manifest `json:"manifests"`
	Scanned   string               `json:"scanned,omitempty"`
}

Snapshot is a dependency snapshot of a build at one commit.

func ParseSnapshot

func ParseSnapshot(r io.Reader) (*Snapshot, error)

ParseSnapshot decodes a dependency snapshot. Only version 0 of the format exists; anything else is refused rather than half read.

func ReadSnapshot

func ReadSnapshot(path string) (*Snapshot, error)

ReadSnapshot reads a dependency snapshot from a file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL