File tree 8 files changed +68
-14
lines changed
functionalTest/kotlin/pl/zalas/gradle/structurizrcli
main/kotlin/pl/zalas/gradle/structurizrcli
8 files changed +68
-14
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ The `version` property can be used To force a specific release.
43
43
44
44
``` kotlin
45
45
structurizrCli {
46
- version = " 1.30.0 "
46
+ version = " 2024.01.02 "
47
47
}
48
48
```
49
49
Original file line number Diff line number Diff line change @@ -30,13 +30,13 @@ class DownloadFunctionalTest : FunctionalTest {
30
30
id 'pl.zalas.structurizr-cli'
31
31
}
32
32
structurizrCli {
33
- version = "1.30.0 "
33
+ version = "2024.01.02 "
34
34
}
35
35
""" )
36
36
37
37
execute(projectDir, " structurizrCliDownload" )
38
38
39
- assertTrue(File (" ${projectDir.absolutePath} /build/downloads/structurizr-cli-1.30.0 .zip" ).exists())
39
+ assertTrue(File (" ${projectDir.absolutePath} /build/downloads/structurizr-cli-2024.01.02 .zip" ).exists())
40
40
}
41
41
42
42
@Test
@@ -46,7 +46,7 @@ class DownloadFunctionalTest : FunctionalTest {
46
46
id 'pl.zalas.structurizr-cli'
47
47
}
48
48
structurizrCli {
49
- version = "1.20.1 "
49
+ version = "2024.01.02 "
50
50
download {
51
51
directory = "tmp"
52
52
}
@@ -55,7 +55,7 @@ class DownloadFunctionalTest : FunctionalTest {
55
55
56
56
execute(projectDir, " structurizrCliDownload" )
57
57
58
- assertTrue(File (" ${projectDir.absolutePath} /tmp/structurizr-cli-1.20.1 .zip" ).exists())
58
+ assertTrue(File (" ${projectDir.absolutePath} /tmp/structurizr-cli-2024.01.02 .zip" ).exists())
59
59
}
60
60
61
61
@Test
Original file line number Diff line number Diff line change @@ -42,6 +42,27 @@ class ExportFunctionalTest : FunctionalTest {
42
42
assertTrue(File (" ${projectDir.absolutePath} /structurizr-SystemContext.puml" ).exists())
43
43
}
44
44
45
+ @Test
46
+ fun `it exports the workspace with a legacy structurizr cli` (@TempDir projectDir : File ) {
47
+ givenWorkspace(projectDir, " workspace.dsl" )
48
+ givenConfiguration(projectDir, """
49
+ plugins {
50
+ id 'pl.zalas.structurizr-cli'
51
+ }
52
+ structurizrCli {
53
+ version = "1.35.0"
54
+ export {
55
+ format = "plantuml"
56
+ workspace = "${projectDir.absolutePath} /workspace.dsl"
57
+ }
58
+ }
59
+ """ )
60
+
61
+ execute(projectDir, " structurizrCliExport" )
62
+
63
+ assertTrue(File (" ${projectDir.absolutePath} /structurizr-SystemContext.puml" ).exists())
64
+ }
65
+
45
66
@Test
46
67
fun `it exports the workspace to a specified output dir` (@TempDir projectDir : File ) {
47
68
givenWorkspace(projectDir, " workspace.dsl" )
Original file line number Diff line number Diff line change @@ -29,13 +29,29 @@ class ExtractFunctionalTest : FunctionalTest {
29
29
id 'pl.zalas.structurizr-cli'
30
30
}
31
31
structurizrCli {
32
- version = "1.30.0 "
32
+ version = "2024.01.02 "
33
33
}
34
34
""" )
35
35
36
36
execute(projectDir, " structurizrCliExtract" )
37
37
38
- assertTrue(File (" ${projectDir.absolutePath} /build/structurizr-cli/lib/structurizr-cli-1.30.0.jar" ).exists())
38
+ assertTrue(File (" ${projectDir.absolutePath} /build/structurizr-cli/lib/structurizr-cli.jar" ).exists())
39
+ }
40
+
41
+ @Test
42
+ fun `it extracts the downloaded legacy structurizr cli` (@TempDir projectDir : File ) {
43
+ givenConfiguration(projectDir, """
44
+ plugins {
45
+ id 'pl.zalas.structurizr-cli'
46
+ }
47
+ structurizrCli {
48
+ version = "1.35.0"
49
+ }
50
+ """ )
51
+
52
+ execute(projectDir, " structurizrCliExtract" )
53
+
54
+ assertTrue(File (" ${projectDir.absolutePath} /build/structurizr-cli/lib/structurizr-cli-1.35.0.jar" ).exists())
39
55
}
40
56
41
57
@Test
@@ -45,7 +61,7 @@ class ExtractFunctionalTest : FunctionalTest {
45
61
id 'pl.zalas.structurizr-cli'
46
62
}
47
63
structurizrCli {
48
- version = "1.19.0 "
64
+ version = "2024.01.02 "
49
65
extract {
50
66
directory = "structurizr-cli"
51
67
}
@@ -54,6 +70,6 @@ class ExtractFunctionalTest : FunctionalTest {
54
70
55
71
execute(projectDir, " structurizrCliExtract" )
56
72
57
- assertTrue(File (" ${projectDir.absolutePath} /structurizr-cli/lib/structurizr-cli-1.19.0 .jar" ).exists())
73
+ assertTrue(File (" ${projectDir.absolutePath} /structurizr-cli/lib/structurizr-cli.jar" ).exists())
58
74
}
59
75
}
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ class StructurizrCliPlugin : Plugin<Project> {
42
42
tasks.register(" structurizrCliDownload" , Download ::class .java) { task ->
43
43
task.version.set(version.flatMap { it.version })
44
44
task.downloadDirectory.set(downloadsDirectory(extension))
45
- task.downloadUrlTemplate.set(" https://github.com/structurizr/cli/releases/download/v{VERSION}/structurizr-cli-{VERSION}.zip" )
45
+ task.downloadUrlTemplate.set(" https://github.com/structurizr/cli/releases/download/{VERSION}/structurizr-cli.zip" )
46
+ task.legacyDownloadUrlTemplate.set(" https://github.com/structurizr/cli/releases/download/v{VERSION}/structurizr-cli-{VERSION}.zip" )
46
47
}
47
48
48
49
private fun Project.registerExtractTask (extension : StructurizrCliPluginExtension , version : TaskProvider <Version >, download : TaskProvider <Download >) =
Original file line number Diff line number Diff line change @@ -32,17 +32,28 @@ open class Download : DefaultTask() {
32
32
@Input
33
33
val version: Property <String > = project.objects.property(String ::class .java)
34
34
35
+ // Example: https://github.com/structurizr/cli/releases/download/2024.01.02/structurizr-cli.zip
35
36
@Input
36
37
val downloadUrlTemplate: Property <String > = project.objects.property(String ::class .java)
37
38
39
+ // Example: https://github.com/structurizr/cli/releases/download/v1.35.0/structurizr-cli-1.35.0.zip
38
40
@Input
39
- val downloadUrl: Provider <String > = downloadUrlTemplate.flatMap { t -> version.map { v -> t.replace(" {VERSION}" , v) } }
41
+ val legacyDownloadUrlTemplate: Property <String > = project.objects.property(String ::class .java)
42
+
43
+ @Input
44
+ val downloadUrl: Provider <String > = version.flatMap { v ->
45
+ when {
46
+ v.matches(" ^[0-9]{4}\\ ..*" .toRegex()) -> downloadUrlTemplate.map { t -> t.replace(" {VERSION}" , v) }
47
+ else -> legacyDownloadUrlTemplate.map { t -> t.replace(" {VERSION}" , v) }
48
+ }
49
+ }
40
50
41
51
@OutputDirectory
42
52
val downloadDirectory: DirectoryProperty = project.objects.directoryProperty()
43
53
44
54
@OutputFile
45
- val downloadDestination: Provider <RegularFile > = version.flatMap { v -> downloadDirectory.file(" structurizr-cli-$v .zip" ) }
55
+ val downloadDestination: Provider <RegularFile > =
56
+ version.flatMap { v -> downloadDirectory.file(" structurizr-cli-$v .zip" ) }
46
57
47
58
init {
48
59
group = " documentation"
Original file line number Diff line number Diff line change @@ -35,7 +35,12 @@ open class Extract : DefaultTask() {
35
35
val structurizrCliDirectory: DirectoryProperty = project.objects.directoryProperty()
36
36
37
37
@OutputFile
38
- val structurizrCliJar: Provider <RegularFile > = version.flatMap { v -> structurizrCliDirectory.file(" lib/structurizr-cli-$v .jar" ) }
38
+ val structurizrCliJar: Provider <RegularFile > = version.flatMap { v ->
39
+ when {
40
+ v.matches(" ^[0-9]{4}\\ ..*" .toRegex()) -> structurizrCliDirectory.file(" lib/structurizr-cli.jar" )
41
+ else -> structurizrCliDirectory.file(" lib/structurizr-cli-$v .jar" )
42
+ }
43
+ }
39
44
40
45
init {
41
46
group = " documentation"
Original file line number Diff line number Diff line change @@ -40,5 +40,5 @@ open class Version : DefaultTask() {
40
40
41
41
private fun latestVersion (): String = URL (" https://api.github.com/repos/structurizr/cli/releases/latest" )
42
42
.readText()
43
- .replace(" (?smi).*?\" tag_name\" :\\ s*\" v([0-9.]*)\" .*" .toRegex(), " $1" )
43
+ .replace(" (?smi).*?\" tag_name\" :\\ s*\" v? ([0-9.]*)\" .*" .toRegex(), " $1" )
44
44
}
You can’t perform that action at this time.
0 commit comments