Skip to content

jakzal/gradle-structurizr-cli

Repository files navigation

Structurizr CLI Gradle plugin

Enables Gradle to run Structurizr CLI commands.

Installation

Groovy

plugins {
    id 'pl.zalas.structurizr-cli' version '<version>'
}

structurizrCli {
}

Kotlin

plugins {
    id("pl.zalas.structurizr-cli") version "<version>"
}

structurizrCli {
}

Tasks

  • structurizrCliDownload - downloads the Structurizr CLI zip file
  • structurizrCliExtract - extracts the downloaded Structurizr CLI zip file
  • structurizrCliExport - exports diagrams with Structurizr CLI
  • structurizrCliPull - pulls a workspace from the Structurizr API with Structurizr CLI
  • structurizrCliPush - pushes content to a Structurizr workspace

Configuration & usage

Version

The latest Structurizr CLI version will be downloaded by default. The version property can be used To force a specific release.

structurizrCli {
    version = "2024.02.22"
}

Export

The export task can be configured to generate a number of diagrams in formats of choice:

structurizrCli {
    export {
        format = "plantuml"
        workspace = "docs/diagrams/workspace.dsl"
    }
    export {
        format = "json"
        workspace = "docs/diagrams/workspace.dsl"
    }
    export {
        format = "plantuml"
        workspace = "docs/diagrams/workspace2.dsl"
        output = "output"
        name = "SomeCustomName"
    }
}
./gradlew structurizrCliExport

Pull

Pulls a workspace from the Structurizr API with Structurizr CLI.

./gradlew structurizrCliPull \
    --id 48582 \
    --key 6804d084-a11e-412b-8ce2-060a40557731 \
    --secret 453a265d-099e-491c-89b5-41945395bcfb

Push

Pushes content to a Structurizr workspace.

./gradlew structurizrCliPush \
    --id 48582 \
    --key 6804d084-a11e-412b-8ce2-060a40557731 \
    --secret 453a265d-099e-491c-89b5-41945395bcfb
    --workspace workspace.dsl

Download

./gradlew structurizrCliDownload

By default, the structurizr-cli zip is downloaded to the build/downloads directory.

It can be customised in relation to the project directory:

structurizrCli {
    download {
        directory = "downloads"
    }
}

Extract

./gradlew structurizrCliExtract

By default, the structurizr-cli zip is extracted to the build/structurizr-cli directory.

It can be customised in relation to the project directory:

structurizrCli {
    extract {
        directory = "structurizr-cli"
    }
}