diff --git a/build.gradle b/build.gradle index c934a44..d5191c6 100644 --- a/build.gradle +++ b/build.gradle @@ -9,8 +9,8 @@ repositories { } dependencies { - api 'com.structurizr:structurizr-client:1.24.1' api 'com.structurizr:structurizr-import:1.4.1' + api 'com.structurizr:structurizr-client:1.25.0' testImplementation 'org.codehaus.groovy:groovy-jsr223:3.0.16' testImplementation 'org.jetbrains.kotlin:kotlin-scripting-jsr223:1.7.22' @@ -27,7 +27,7 @@ targetCompatibility = 11 description = 'Structurizr DSL' group = 'com.structurizr' -version = '1.30.4' +version = '1.31.0' test { useJUnitPlatform() diff --git a/docs/changelog.md b/docs/changelog.md index b33f9b3..a9aa935 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,8 +1,9 @@ # Changelog -## (unreleased to Maven Central) +## 1.31.0 (25th July 2023) - Adds support for passing parameters to external scripts. +- Updates dependencies. ## 1.30.4 (17th July 2023) diff --git a/src/main/java/com/structurizr/dsl/AbstractViewParser.java b/src/main/java/com/structurizr/dsl/AbstractViewParser.java index ffa550f..8f66d3e 100644 --- a/src/main/java/com/structurizr/dsl/AbstractViewParser.java +++ b/src/main/java/com/structurizr/dsl/AbstractViewParser.java @@ -1,32 +1,4 @@ package com.structurizr.dsl; -import com.structurizr.Workspace; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.text.DecimalFormat; -import java.text.NumberFormat; - abstract class AbstractViewParser extends AbstractParser { - - private static final Log log = LogFactory.getLog(AbstractViewParser.class); - - protected String generateViewKey(Workspace workspace, String prefix) { - NumberFormat format = new DecimalFormat("000"); - int counter = 1; - String key = prefix + "-" + format.format(counter); - - while (hasViewWithKey(workspace, key)) { - counter++; - key = prefix + "-" + format.format(counter); - } - - log.warn(key + " is an automatically generated view key - you will likely lose manual layout information when using automatically generated view keys."); - return key; - } - - protected boolean hasViewWithKey(Workspace workspace, String key) { - return workspace.getViews().getViews().stream().anyMatch(view -> view.getKey().equals(key)); - } - } \ No newline at end of file diff --git a/src/main/java/com/structurizr/dsl/ComponentViewParser.java b/src/main/java/com/structurizr/dsl/ComponentViewParser.java index f9fefbb..3acd886 100644 --- a/src/main/java/com/structurizr/dsl/ComponentViewParser.java +++ b/src/main/java/com/structurizr/dsl/ComponentViewParser.java @@ -45,7 +45,7 @@ ComponentView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/ContainerViewParser.java b/src/main/java/com/structurizr/dsl/ContainerViewParser.java index 16ec414..b1033eb 100644 --- a/src/main/java/com/structurizr/dsl/ContainerViewParser.java +++ b/src/main/java/com/structurizr/dsl/ContainerViewParser.java @@ -45,7 +45,7 @@ ContainerView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/CustomViewParser.java b/src/main/java/com/structurizr/dsl/CustomViewParser.java index c33c2df..5aedf5d 100644 --- a/src/main/java/com/structurizr/dsl/CustomViewParser.java +++ b/src/main/java/com/structurizr/dsl/CustomViewParser.java @@ -28,7 +28,7 @@ CustomView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/DeploymentViewParser.java b/src/main/java/com/structurizr/dsl/DeploymentViewParser.java index 6c937be..8794c68 100644 --- a/src/main/java/com/structurizr/dsl/DeploymentViewParser.java +++ b/src/main/java/com/structurizr/dsl/DeploymentViewParser.java @@ -1,7 +1,6 @@ package com.structurizr.dsl; import com.structurizr.Workspace; -import com.structurizr.model.DeploymentNode; import com.structurizr.model.Element; import com.structurizr.model.SoftwareSystem; import com.structurizr.view.DeploymentView; @@ -53,7 +52,7 @@ DeploymentView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); @@ -68,7 +67,7 @@ DeploymentView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/DynamicViewParser.java b/src/main/java/com/structurizr/dsl/DynamicViewParser.java index 1e99e44..78b2310 100644 --- a/src/main/java/com/structurizr/dsl/DynamicViewParser.java +++ b/src/main/java/com/structurizr/dsl/DynamicViewParser.java @@ -46,7 +46,7 @@ DynamicView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); @@ -61,7 +61,7 @@ DynamicView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); @@ -71,7 +71,7 @@ DynamicView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/FilteredViewParser.java b/src/main/java/com/structurizr/dsl/FilteredViewParser.java index eb28864..f90dd9d 100644 --- a/src/main/java/com/structurizr/dsl/FilteredViewParser.java +++ b/src/main/java/com/structurizr/dsl/FilteredViewParser.java @@ -78,7 +78,7 @@ FilteredView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/ImageViewParser.java b/src/main/java/com/structurizr/dsl/ImageViewParser.java index 9906aaa..548e823 100644 --- a/src/main/java/com/structurizr/dsl/ImageViewParser.java +++ b/src/main/java/com/structurizr/dsl/ImageViewParser.java @@ -33,7 +33,7 @@ ImageView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/SystemContextViewParser.java b/src/main/java/com/structurizr/dsl/SystemContextViewParser.java index 9a5b5d3..4dc004a 100644 --- a/src/main/java/com/structurizr/dsl/SystemContextViewParser.java +++ b/src/main/java/com/structurizr/dsl/SystemContextViewParser.java @@ -45,7 +45,7 @@ SystemContextView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key); diff --git a/src/main/java/com/structurizr/dsl/SystemLandscapeViewParser.java b/src/main/java/com/structurizr/dsl/SystemLandscapeViewParser.java index 51b7767..e03919f 100644 --- a/src/main/java/com/structurizr/dsl/SystemLandscapeViewParser.java +++ b/src/main/java/com/structurizr/dsl/SystemLandscapeViewParser.java @@ -26,7 +26,7 @@ SystemLandscapeView parse(DslContext context, Tokens tokens) { if (tokens.includes(KEY_INDEX)) { key = tokens.get(KEY_INDEX); } else { - key = generateViewKey(workspace, VIEW_TYPE); + key = workspace.getViews().generateViewKey(VIEW_TYPE); } validateViewKey(key);