Sign in

    smithy-build

    Smithy build projections and plugins

    smithy
    build
    projection
    moonbit
    Download zip
    Author
    Version
    0.3.0
    License
    Apache-2.0
    Last updated
    5 hours ago
    Downloads
    4

    #Smithy build

    Parses smithy-build.json, applies model projections and invokes registered plugins. BuildRunner::run returns relative artifact paths and contents; the CLI writes them to the configured output directory.

    run_result also returns errors and keeps successful projection artifacts. An invalid projected model writes build information, while plugins that require a valid model are skipped. run raises when any projection fails.

    Local sources and imports are loaded by the CLI. Maven dependencies are reported as unsupported. The runner includes the source projection and the model, sources and build-info plugins for each concrete projection.

    BuildConfig::parse accepts an environment map for ${NAME} substitutions in string values and object keys. Undefined variables fail configuration loading; \${NAME} keeps a literal placeholder. The CLI uses process variables and sets SMITHY_ROOT_DIR to its current working directory.

    Local JAR inputs load the IDL and JSON files listed in META-INF/smithy/manifest. archive_models decodes stored and deflated entries without extracting files. Source artifacts retain their manifest paths under the JAR filename without its extension.

    Call add_projection_import to supply inputs for a projection when using the runner directly. add_source marks files for source artifacts; its optional source_file argument identifies the original model filename when the artifact uses a relative name. Projected sources contain source shapes and metadata, including newly created shapes, and omit imported definitions.

    apply_transform applies a single built-in transform without running validation or plugins.

    Use plugin::artifactName to run a plugin with separate settings and an output directory of its own. Artifact names must be unique within a projection, including the default model, sources and build-info artifacts. Registered plugins return relative filenames; absolute paths and parent traversal are rejected.

    BuildError

    pub(all) suberror BuildError {
    InvalidBuildConfig(String)
    } derive(Eq,
    Debug
    )

    BuildConfig

    pub(all) struct BuildConfig {
    version : String
    sources : Array[String]
    imports : Array[String]
    output_directory : String
    projections : Array[ProjectionConfig]
    plugins : Map[String, Json]
    ignore_missing_plugins : Bool
    } derive(Eq,
    Debug
    )

    BuildConfig::parse

    fn BuildConfig::parse(source : String, environment? : Map[String, String]) -> BuildConfig raise BuildError

    BuildResult

    pub(all) struct BuildResult {
    artifacts : Map[String, String]
    errors : Array[String]
    } derive(
    Debug
    )

    Artifacts from successful plugins and failures reported by the build.

    BuildRunner

    pub struct BuildRunner {
    config : BuildConfig
    plugins : Map[String, (
    Model
    , Json) -> Map[String, String] raise BuildError]
    sources : Map[String, String]
    source_conflicts : Array[String]
    source_origins :
    Set
    [String]
    source_metadata :
    Set
    [String]
    projection_imports : Map[String, Array[
    ModelInput
    ]]
    }

    BuildRunner::add_projection_import

    fn BuildRunner::add_projection_import(self : BuildRunner, projection : String, input :
    ModelInput
    ) -> BuildRunner

    Supply local projection imports; the caller owns file access.

    BuildRunner::add_source

    fn BuildRunner::add_source(self : BuildRunner, name : String, content : String, source_file? : String?) -> BuildRunner

    BuildRunner::new

    fn BuildRunner::new(config : BuildConfig) -> BuildRunner

    BuildRunner::register_plugin

    fn BuildRunner::register_plugin(self : BuildRunner, name : String, execute : (
    Model
    , Json) -> Map[String, String] raise BuildError) -> BuildRunner

    Register a plugin that writes relative filenames for a projected model.

    BuildRunner::run

    fn BuildRunner::run(self : BuildRunner, model :
    Model
    ) -> Map[String, String] raise BuildError

    Produce artifacts, raising if any projection failed.

    BuildRunner::run_result

    Preserve successful projections and build information when another projection fails.

    ProjectionConfig

    pub(all) struct ProjectionConfig {
    name : String
    is_abstract : Bool
    imports : Array[String]
    transforms : Array[TransformConfig]
    plugins : Map[String, Json]
    } derive(Eq,
    Debug
    )

    TransformConfig

    pub(all) struct TransformConfig {
    name : String
    args : Json
    } derive(Eq,
    Debug
    )

    apply_transform

    Apply one built-in transform without validating or running plugins.

    archive_models

    fn archive_models(data : Bytes, origin : String) -> Map[String, String] raise BuildError

    Discover models listed by META-INF/smithy/manifest in a local JAR or ZIP. Keys are relative to META-INF/smithy; no archive files are extracted.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io