# spockframework/spock-example architecture

> Architecture diagram of the GitHub repository spockframework/spock-example, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spockframework/spock-example
- Repository: https://github.com/spockframework/spock-example

## Overview

##### Project Type and Purpose
- This is an **open-source example project** demonstrating how to write and run Spock specifications using **Gradle** and **Maven**.
- It contains **test code only** (under `src/test/groovy`) and build/configuration scripts (`build.gradle`, `pom.xml`, Ivy files, wrappers).

##### File Structure
- Top-level build configs:
- `build.gradle` + `gradlew` wrappers + Gradle wrapper files
- `pom.xml` + `mvnw` wrappers + Maven wrapper files
- `ivy.xml` + `ivysettings.xml`
These configure dependency management and test execution.
- Source tree:
- `src/test/groovy/` – Spock specification classes
- `src/test/resources/` – test configs (e.g., `IncludeFastConfig.groovy`)
- No runtime application code—focus is on build & test.

##### Extract Insights from the README
- Frameworks & platforms: **Spock 2.0**, **JUnit Platform**, **Groovy**, **Gradle**, **Maven**.
- IDE integration: **Eclipse (Buildship plugin)** and **IntelliJ IDEA**.
- Workflow: clone → run `./gradlew clean test` or `./mvnw clean test` → download dependencies → compile → execute specs.

##### Main Components & Their Relationships
a. Developer Environment
- IDE or CLI shell
- JDK 8+ installed
b. Build Tool Wrappers
- Gradle wrapper (`gradlew`) bootstraps Gradle distribution
- Maven wrapper (`mvnw`) bootstraps Maven
c. Build Configurations
- `build.gradle`, `settings.gradle`, Gradle wrapper files
- `pom.xml`, `ivy.xml`, `ivysettings.xml`, Maven wrapper files
d. Dependency Repositories
- Remote (Maven Central, Gradle plugin portal)
- Local caches (`~/.m2/repository`, `~/.gradle`)
e. Compilation & Test Execution
- Groovy compiler
- JUnit Platform launcher
- Spock framework runtime
f. Test Sources & Resources
- Spec files in `src/test/groovy`
- Configs in `src/test/resources`
g. Outputs
- Test reports
- Build logs

##### Architectural Patterns & Design Principles
- **Wrapper-based bootstrap**: eliminates requirement for pre-installed build tools.
- **Convention over configuration**: Gradle and Maven default project layouts.
- **Plugin architecture**: Spock integrates as a test engine plugin on JUnit Platform.
- **Separation of concerns**: build scripts (in project root) vs. test code (under `src/test`).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Environment
    Developer["Developer"]:::actor

    %% Paths: CLI and IDE
    subgraph "Interaction"
        CLI["CLI Shell"]:::cli
        IDE["IDE (Buildship / IDEA)"]:::ide
    end

    Developer -->|uses| CLI
    Developer -->|uses| IDE

    %% Build Tool Wrappers and Configs
    subgraph "Build Tool Bootstrap"
        GradleWrapper["Gradle Wrapper"]:::wrapper
        MavenWrapper["Maven Wrapper"]:::wrapper
        GradleConfig["build.gradle / settings.gradle"]:::config
        MavenConfig["pom.xml"]:::config
        IvyConfig["ivy.xml / ivysettings.xml"]:::config
    end

    CLI --> GradleWrapper
    CLI --> MavenWrapper
    IDE --> GradleWrapper
    IDE --> MavenWrapper

    GradleWrapper --> GradleConfig
    MavenWrapper --> MavenConfig
    MavenWrapper --> IvyConfig

    %% Dependency Resolution
    subgraph "Dependency Resolution"
        RemoteRepos["Remote Repositories\n(Maven Central, Plugin Portal)"]:::cloud
        LocalCache["Local Caches\n(~/.m2, ~/.gradle)"]:::cylinder
    end

    GradleWrapper -->|resolves deps| RemoteRepos
    MavenWrapper -->|resolves deps| RemoteRepos
    RemoteRepos -->|caches| LocalCache

    %% Compilation & Test Execution
    subgraph "Compile & Test"
        GroovyCompiler["Groovy Compiler"]:::process
        JUnitPlatform["JUnit Platform Launcher"]:::process
        SpockEngine["Spock Engine Plugin"]:::plugin
        TestSources["Test Sources\n(src/test/groovy/)"]:::folder
        TestResources["Test Resources\n(src/test/resources/)"]:::folder
    end

    GradleWrapper --> GroovyCompiler
    GradleWrapper --> JUnitPlatform
    MavenWrapper --> GroovyCompiler
    MavenWrapper --> JUnitPlatform

    JUnitPlatform --> SpockEngine
    GroovyCompiler --> TestSources
    JUnitPlatform --> TestSources
    JUnitPlatform --> TestResources

    %% Outputs
    subgraph "Outputs"
        TestReports["Test Reports"]:::output
        ConsoleLogs["Console Logs"]:::output
    end

    JUnitPlatform --> TestReports
    JUnitPlatform --> ConsoleLogs

    %% Documentation & CI
    subgraph "Project Files"
        README["README"]:::doc
        License["LICENSE / NOTICE"]:::doc
        CI["CI Workflow (.github/workflows/main.yml)"]:::doc
        GitIgnore[".gitignore / .gitattributes"]:::doc
    end

    GradleConfig --> README
    MavenConfig --> README
    IvyConfig --> README
    README --> CI
    README --> GitIgnore

    %% Click Events
    click GradleWrapper "https://github.com/spockframework/spock-example/tree/master/gradlew"
    click MavenWrapper "https://github.com/spockframework/spock-example/tree/master/mvnw"
    click GradleConfig "https://github.com/spockframework/spock-example/blob/master/build.gradle"
    click MavenConfig "https://github.com/spockframework/spock-example/blob/master/pom.xml"
    click IvyConfig "https://github.com/spockframework/spock-example/blob/master/ivy.xml"
    click TestSources "https://github.com/spockframework/spock-example/tree/master/src/test/groovy/"
    click TestResources "https://github.com/spockframework/spock-example/blob/master/src/test/resources/IncludeFastConfig.groovy"
    click README "https://github.com/spockframework/spock-example/blob/master/README.adoc"
    click License "https://github.com/spockframework/spock-example/tree/master/LICENSE"
    click CI "https://github.com/spockframework/spock-example/blob/master/.github/workflows/main.yml"
    click GitIgnore "https://github.com/spockframework/spock-example/blob/master/.gitignore"

    %% Styles
    classDef actor fill:#FFD966,stroke:#333,stroke-width:1px;
    classDef cli fill:#CFE2F3,stroke:#333,stroke-width:1px;
    classDef ide fill:#D9EAD3,stroke:#333,stroke-width:1px;
    classDef wrapper fill:#F4CCCC,stroke:#333,stroke-width:1px;
    classDef config fill:#FFE699,stroke:#333,stroke-width:1px;
    classDef cloud fill:#D9D2E9,stroke:#333,stroke-width:1px;
    classDef cylinder fill:#B4A7D6,stroke:#333,stroke-width:1px;
    classDef process fill:#B6D7A8,stroke:#333,stroke-width:1px;
    classDef plugin fill:#A4C2F4,stroke:#333,stroke-width:1px;
    classDef folder fill:#FFF2CC,stroke:#333,stroke-width:1px;
    classDef output fill:#F9CB9C,stroke:#333,stroke-width:1px;
    classDef doc fill:#D5A6BD,stroke:#333,stroke-width:1px;
```
