Skip to content

Commit 4248814

Browse files
committed
Update the download url and jar name to the latest release (2024.01.02)
* the tag name is no longer the classic v1.2.3, but it's now year.month.day * the downloaded jar no longer has version in its name * the legacy versioning scheme is still supported, but structurizr has removed most of their past releases (only v1.34.0 and v1.35.0 were kept)
1 parent 0b89fe3 commit 4248814

File tree

8 files changed

+68
-14
lines changed

8 files changed

+68
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The `version` property can be used To force a specific release.
4343

4444
```kotlin
4545
structurizrCli {
46-
version = "1.30.0"
46+
version = "2024.01.02"
4747
}
4848
```
4949

src/functionalTest/kotlin/pl/zalas/gradle/structurizrcli/DownloadFunctionalTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class DownloadFunctionalTest : FunctionalTest {
3030
id 'pl.zalas.structurizr-cli'
3131
}
3232
structurizrCli {
33-
version = "1.30.0"
33+
version = "2024.01.02"
3434
}
3535
""")
3636

3737
execute(projectDir, "structurizrCliDownload")
3838

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())
4040
}
4141

4242
@Test
@@ -46,7 +46,7 @@ class DownloadFunctionalTest : FunctionalTest {
4646
id 'pl.zalas.structurizr-cli'
4747
}
4848
structurizrCli {
49-
version = "1.20.1"
49+
version = "2024.01.02"
5050
download {
5151
directory = "tmp"
5252
}
@@ -55,7 +55,7 @@ class DownloadFunctionalTest : FunctionalTest {
5555

5656
execute(projectDir, "structurizrCliDownload")
5757

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())
5959
}
6060

6161
@Test

src/functionalTest/kotlin/pl/zalas/gradle/structurizrcli/ExportFunctionalTest.kt

+21
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@ class ExportFunctionalTest : FunctionalTest {
4242
assertTrue(File("${projectDir.absolutePath}/structurizr-SystemContext.puml").exists())
4343
}
4444

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+
4566
@Test
4667
fun `it exports the workspace to a specified output dir`(@TempDir projectDir: File) {
4768
givenWorkspace(projectDir, "workspace.dsl")

src/functionalTest/kotlin/pl/zalas/gradle/structurizrcli/ExtractFunctionalTest.kt

+20-4
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,29 @@ class ExtractFunctionalTest : FunctionalTest {
2929
id 'pl.zalas.structurizr-cli'
3030
}
3131
structurizrCli {
32-
version = "1.30.0"
32+
version = "2024.01.02"
3333
}
3434
""")
3535

3636
execute(projectDir, "structurizrCliExtract")
3737

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())
3955
}
4056

4157
@Test
@@ -45,7 +61,7 @@ class ExtractFunctionalTest : FunctionalTest {
4561
id 'pl.zalas.structurizr-cli'
4662
}
4763
structurizrCli {
48-
version = "1.19.0"
64+
version = "2024.01.02"
4965
extract {
5066
directory = "structurizr-cli"
5167
}
@@ -54,6 +70,6 @@ class ExtractFunctionalTest : FunctionalTest {
5470

5571
execute(projectDir, "structurizrCliExtract")
5672

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())
5874
}
5975
}

src/main/kotlin/pl/zalas/gradle/structurizrcli/StructurizrCliPlugin.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class StructurizrCliPlugin : Plugin<Project> {
4242
tasks.register("structurizrCliDownload", Download::class.java) { task ->
4343
task.version.set(version.flatMap { it.version })
4444
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")
4647
}
4748

4849
private fun Project.registerExtractTask(extension: StructurizrCliPluginExtension, version: TaskProvider<Version>, download: TaskProvider<Download>) =

src/main/kotlin/pl/zalas/gradle/structurizrcli/tasks/Download.kt

+13-2
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,28 @@ open class Download : DefaultTask() {
3232
@Input
3333
val version: Property<String> = project.objects.property(String::class.java)
3434

35+
// Example: https://github.com/structurizr/cli/releases/download/2024.01.02/structurizr-cli.zip
3536
@Input
3637
val downloadUrlTemplate: Property<String> = project.objects.property(String::class.java)
3738

39+
// Example: https://github.com/structurizr/cli/releases/download/v1.35.0/structurizr-cli-1.35.0.zip
3840
@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+
}
4050

4151
@OutputDirectory
4252
val downloadDirectory: DirectoryProperty = project.objects.directoryProperty()
4353

4454
@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") }
4657

4758
init {
4859
group = "documentation"

src/main/kotlin/pl/zalas/gradle/structurizrcli/tasks/Extract.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ open class Extract : DefaultTask() {
3535
val structurizrCliDirectory: DirectoryProperty = project.objects.directoryProperty()
3636

3737
@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+
}
3944

4045
init {
4146
group = "documentation"

src/main/kotlin/pl/zalas/gradle/structurizrcli/tasks/Version.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ open class Version : DefaultTask() {
4040

4141
private fun latestVersion(): String = URL("https://api.github.com/repos/structurizr/cli/releases/latest")
4242
.readText()
43-
.replace("(?smi).*?\"tag_name\":\\s*\"v([0-9.]*)\".*".toRegex(), "$1")
43+
.replace("(?smi).*?\"tag_name\":\\s*\"v?([0-9.]*)\".*".toRegex(), "$1")
4444
}

0 commit comments

Comments
 (0)