Landzcape Discovery Gradle Plugin

Landzcape Discovery Plugin for Gradle

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

io.landzcape
ArtifactId

ArtifactId

discovery-gradle-plugin
Last Version

Last Version

0.0.25
Release Date

Release Date

Type

Type

jar
Description

Description

Landzcape Discovery Gradle Plugin
Landzcape Discovery Plugin for Gradle
Project URL

Project URL

https://www.landzcape.io
Source Code Management

Source Code Management

https://github.com/landzcape/landzcape

Download discovery-gradle-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/io.landzcape/discovery-gradle-plugin/ -->
<dependency>
    <groupId>io.landzcape</groupId>
    <artifactId>discovery-gradle-plugin</artifactId>
    <version>0.0.25</version>
</dependency>
// https://jarcasting.com/artifacts/io.landzcape/discovery-gradle-plugin/
implementation 'io.landzcape:discovery-gradle-plugin:0.0.25'
// https://jarcasting.com/artifacts/io.landzcape/discovery-gradle-plugin/
implementation ("io.landzcape:discovery-gradle-plugin:0.0.25")
'io.landzcape:discovery-gradle-plugin:jar:0.0.25'
<dependency org="io.landzcape" name="discovery-gradle-plugin" rev="0.0.25">
  <artifact name="discovery-gradle-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.landzcape', module='discovery-gradle-plugin', version='0.0.25')
)
libraryDependencies += "io.landzcape" % "discovery-gradle-plugin" % "0.0.25"
[io.landzcape/discovery-gradle-plugin "0.0.25"]

Dependencies

compile (5)

Group / Artifact Type Version
io.landzcape : discovery-domain jar 0.0.25
com.fasterxml.jackson.core : jackson-databind jar 2.9.9.3
com.fasterxml.jackson.module : jackson-module-kotlin jar 2.9.7
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.21
org.jetbrains.kotlin : kotlin-reflect jar 1.3.21

Project Modules

There are no modules declared in this project.

Landzcape

CircleCI

Landzcape visualizes components and their dependencies. This structure can be discovered using plugins for Angular, Gradle and/or Maven.

Available plugin tasks

Task Gradle Maven Angular
Discover Yes Yes Yes
Merge Yes Yes No
ExtractExplorer Yes Yes No

Discovery

In essence the discovery process will scan your code, extract the module structure and write it to a file named landscape.json. The generated landscape.json will be the source for visualizing your module landscape.

Discovery with Maven

The discovery plugin needs to be run in the root pom.xml of your multi-module maven project.

<build>
    <plugins>
        <plugin>
            <groupId>io.landzcape</groupId>
            <artifactId>discovery-maven-plugin</artifactId>
            <version>1.0</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>discover</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <context>surfshop</context>
                <domain>surfing</domain>
                <includes>
                    <include>com.surfshop::</include>
                </includes>
                <excludes>
                    <exclude>com.surfshop:excluded-module:</exclude>
                </excludes>
                <contexts>
                    <context>
                        <name>surfshop</name>
                        <label>My Surfshop!</label>
                    </context>
                </contexts>
                <domains>
                    <domain>
                        <name>surfing</name>
                        <label>Surfing</label>
                        <context>surfshop</context>
                    </domain>
                </domains>
                <layers>
                    <layer>
                        <name>es</name>
                        <label>Edge Service</label>
                        <matching>*-es</matching>
                        <order>1</order>
                    </layer>
                    <layer>
                        <name>cs</name>
                        <label>Core Service</label>
                        <matching>*-cs</matching>
                        <order>2</order>
                    </layer>
                </layers>
            </configuration>
        </plugin>
    </plugins>
</build>

The plugin's configuration can be overridden in sub-projects. Example:

<build>
    <plugins>
        <plugin>
            <groupId>io.landzcape</groupId>
            <artifactId>discovery-maven-plugin</artifactId>
            <version>1.0</version>
            <inherited>false</inherited>
            <configuration>
                <type>common</type>
            </configuration>
        </plugin>
    </plugins>
</build>

If you want to skip the discovery process conditionally, use <skipDiscovery>true</skipDiscoveryskipDiscovery>.

Discovery with Gradle

The discovery plugin needs to be configured in the root build.gradle of your multi-module gradle project. Just import the plugin ...

buildscript {
    repositories { ...  }

    dependencies {
        classpath 'io.landzcape:discovery-gradle-plugin:1.0'
    }
}

apply plugin: 'io.landzcape.discovery'

... and configure it to your needs ...

landscape {
    context = 'surfshop'
    domain = 'surfing'
    includes = ['com.surfshop::']
    excludes = ['com.surfshop:excluded-module:']

    contexts {
        context name: 'surfshop', label: 'My Surfshop!'
        context name: 'kiteshop', label: 'My Kiteshop'
    }

    domains {
        domain name: 'surfing', label: 'Surfing', context: 'surfshop'
    }

    layers {
        layer name: 'es', label: 'Edge Service', matching: '*-es', order: 1
        layer name: 'cs', label: 'Core Service', matching: '*-cs', order: 2
    }
}

The plugin's configuration can be overridden in sub-projects.

Execute the discover task to run start the discovery process.

Discovery with Angular

In your package.json add ...

"devDependencies": {
    "@landzcape/discovery-angular": "1.0.0",
    ...
}

... to import the dependency. The configuration goes into files named discover.json. As an example, you could have a discover.json in your root directory (next to tsconfig.json) that defines your layers ...

{
  "context": "surfshop",
  "domain": "surfing",
  "layer": "ui"
}

... and a separate discover.json in your shared folder to mark all your shared modules with the type COMMON.

{
  "type": "COMMON"
}

To start the discovery, invoke this command using a terminal or npm build script:

landzcape-discovery-angular

As an optional argument you can specify the location of the projects tsconfig.json.

Merging

Already discovered landscape.json files can be merged for visualization.

Merging with Maven

<build>
    <plugins>
        <plugin>
            <groupId>io.landzcape</groupId>
            <artifactId>discovery-maven-plugin</artifactId>
            <version>1.0</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>merge</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <discoveries>
                    <discovery>first/landscape.json</discovery>
                    <discovery>second/landscape.json</discovery>
                </discoveries>
                <mergeTo>landscape.json</mergeTo>
            </configuration>
        </plugin>
    </plugins>
</build>

If you want to skip the merge conditionally, use <skipMerge>true</skipMerge>.

Merging with Gradle

import io.landzcape.gradle.MergeTask

...

apply plugin: 'io.landzcape.discovery'

task merge(type: MergeTask) {
    discoveries = ['first/landscape.json', 'second/landscape.json']
    mergeTo = 'landscape.json'
}

Visualization

Landzcape Explorer is a web application that visualizes your landscape. It is bundled with the Gradle and Maven discovery plugin. It can be extracted during the build process and deployed with any HTTP server.

Example using nginx

Assuming that you already discovered your landscape and your landscape.json is ready.

1. Extract the visualization application

You can either use Maven to extract the visualization application ...

<build>
    <plugins>
        <plugin>
            <groupId>io.landzcape</groupId>
            <artifactId>discovery-maven-plugin</artifactId>
            <version>1.0</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>extractExplorer</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <extractTo>explorer</extractTo>
            </configuration>
        </plugin>
    </plugins>
</build>

... or do the same with gradle ...

import io.landzcape.gradle.ExtractExplorerTask

...

apply plugin: 'io.landzcape.discovery'

task extract(type: ExtractExplorerTask) {
    extractTo = 'explorer'
}

If you want to skip the extraction conditionally, use <skipExtraction>true</skipExtraction>.

2. Bundle application and landscape with nginx

FROM nginx
COPY explorer /usr/share/nginx/html
COPY landscape.json /usr/share/nginx/html

3. Build, deploy and run ...

... the docker image. Preferably all automated, so you always have an updated architecture visualization :)

Versions

Version
0.0.25
0.0.24
0.0.23
0.0.22
0.0.21
0.0.19
0.0.18
0.0.17
0.0.16
0.0.15
0.0.13
0.0.12
0.0.11
0.0.10