Skip to content

Commit

Permalink
Merge pull request #145 from jakzal/remove-deprecated-calls
Browse files Browse the repository at this point in the history
Replace deprecated calls
  • Loading branch information
jakzal authored Jan 2, 2025
2 parents ccc5389 + 915ce30 commit 1d42803
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
12 changes: 5 additions & 7 deletions src/main/kotlin/pl/zalas/gradle/structurizrcli/tasks/Export.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.*
import org.gradle.process.ExecOperations
import javax.inject.Inject

open class Export : DefaultTask() {
open class Export @Inject constructor(@Internal val execOperations: ExecOperations) : DefaultTask() {

@InputFile
val workspace: RegularFileProperty = project.objects.fileProperty()
Expand All @@ -50,7 +48,7 @@ open class Export : DefaultTask() {

@TaskAction
fun export() {
project.javaexec { spec ->
execOperations.javaexec { spec ->
spec.workingDir(project.layout.projectDirectory)
spec.classpath(structurizrCliDirectory.dir("lib/*"))
spec.mainClass.set("com.structurizr.cli.StructurizrCliApplication")
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/pl/zalas/gradle/structurizrcli/tasks/Pull.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.options.Option
import org.gradle.process.ExecOperations
import javax.inject.Inject

open class Pull : DefaultTask() {
open class Pull @Inject constructor(@Internal val execOperations: ExecOperations) : DefaultTask() {

@InputFile
val structurizrCliJar: RegularFileProperty = project.objects.fileProperty()
Expand Down Expand Up @@ -50,7 +52,7 @@ open class Pull : DefaultTask() {

@TaskAction
fun pull() {
project.javaexec { spec ->
execOperations.javaexec { spec ->
spec.workingDir(project.layout.projectDirectory)
spec.classpath(structurizrCliJar.get(), structurizrCliDirectory.dir("lib/*"))
spec.mainClass.set("com.structurizr.cli.StructurizrCliApplication")
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/pl/zalas/gradle/structurizrcli/tasks/Push.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.options.Option
import org.gradle.process.ExecOperations
import javax.inject.Inject

open class Push : DefaultTask() {
open class Push @Inject constructor(@Internal val execOperations: ExecOperations) : DefaultTask() {

@InputFile
val structurizrCliJar: RegularFileProperty = project.objects.fileProperty()
Expand Down Expand Up @@ -86,7 +88,7 @@ open class Push : DefaultTask() {

@TaskAction
fun push() {
project.javaexec { spec ->
execOperations.javaexec { spec ->
spec.workingDir(project.layout.projectDirectory)
spec.classpath(structurizrCliJar.get(), structurizrCliDirectory.dir("lib/*"))
spec.mainClass.set("com.structurizr.cli.StructurizrCliApplication")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import java.net.URL
import java.net.URI

open class Version : DefaultTask() {

Expand All @@ -38,7 +38,8 @@ open class Version : DefaultTask() {

private fun latestVersionProvider(): Provider<String> = project.provider(this::latestVersion)

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

0 comments on commit 1d42803

Please sign in to comment.