From c93aa9be2ceac35073bbcc422ba63ecc22a50cb3 Mon Sep 17 00:00:00 2001 From: airsquared <36649395+airsquared@users.noreply.github.com> Date: Sat, 23 Sep 2023 21:28:54 -0700 Subject: [PATCH] Replace deprecated API usages --- src/main/groovy/org/beryx/jlink/JPackageImageTask.groovy | 2 +- src/main/groovy/org/beryx/jlink/JPackageTask.groovy | 2 +- src/main/groovy/org/beryx/jlink/JlinkTask.groovy | 2 +- src/main/groovy/org/beryx/jlink/JlinkZipTask.groovy | 8 ++++++-- src/main/groovy/org/beryx/jlink/data/JPackageData.groovy | 4 ++-- .../org/beryx/jlink/data/JlinkPluginExtension.groovy | 2 +- .../org/beryx/jlink/impl/PrepareModulesDirTaskImpl.groovy | 7 ++----- src/main/groovy/org/beryx/jlink/util/JdkUtil.groovy | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/groovy/org/beryx/jlink/JPackageImageTask.groovy b/src/main/groovy/org/beryx/jlink/JPackageImageTask.groovy index 26a0d63c..304078df 100644 --- a/src/main/groovy/org/beryx/jlink/JPackageImageTask.groovy +++ b/src/main/groovy/org/beryx/jlink/JPackageImageTask.groovy @@ -89,6 +89,6 @@ class JPackageImageTask extends BaseTask { @Internal File getImageDirFromName() { - project.file("$project.buildDir/${imageName}") + project.file("${project.layout.buildDirectory.get()}/${imageName}") } } diff --git a/src/main/groovy/org/beryx/jlink/JPackageTask.groovy b/src/main/groovy/org/beryx/jlink/JPackageTask.groovy index c78cdba4..430ac581 100644 --- a/src/main/groovy/org/beryx/jlink/JPackageTask.groovy +++ b/src/main/groovy/org/beryx/jlink/JPackageTask.groovy @@ -82,6 +82,6 @@ class JPackageTask extends BaseTask { @Internal File getImageDirFromName() { - project.file("$project.buildDir/${imageName}") + project.file("${project.layout.buildDirectory.get()}/${imageName}") } } diff --git a/src/main/groovy/org/beryx/jlink/JlinkTask.groovy b/src/main/groovy/org/beryx/jlink/JlinkTask.groovy index 27686ab3..1b8b3069 100644 --- a/src/main/groovy/org/beryx/jlink/JlinkTask.groovy +++ b/src/main/groovy/org/beryx/jlink/JlinkTask.groovy @@ -138,6 +138,6 @@ class JlinkTask extends BaseTask { @Internal File getImageDirFromName() { - project.file("$project.buildDir/$imageName") + project.file("${project.layout.buildDirectory.get()}/$imageName") } } diff --git a/src/main/groovy/org/beryx/jlink/JlinkZipTask.groovy b/src/main/groovy/org/beryx/jlink/JlinkZipTask.groovy index eb4671f9..688da2eb 100644 --- a/src/main/groovy/org/beryx/jlink/JlinkZipTask.groovy +++ b/src/main/groovy/org/beryx/jlink/JlinkZipTask.groovy @@ -80,11 +80,15 @@ class JlinkZipTask extends BaseTask { @Internal File getImageDirFromName() { - project.file("$project.buildDir/$imageName") + project.file("$buildDir/$imageName") } @Internal File getImageZipFromName() { - project.file("$project.buildDir/${imageName}.zip") + project.file("$buildDir/${imageName}.zip") + } + + private File getBuildDir() { + return project.layout.buildDirectory.asFile.get() } } diff --git a/src/main/groovy/org/beryx/jlink/data/JPackageData.groovy b/src/main/groovy/org/beryx/jlink/data/JPackageData.groovy index e19fae46..3ce201b5 100644 --- a/src/main/groovy/org/beryx/jlink/data/JPackageData.groovy +++ b/src/main/groovy/org/beryx/jlink/data/JPackageData.groovy @@ -124,12 +124,12 @@ class JPackageData { @OutputDirectory File getImageOutputDir() { - this.@imageOutputDir ?: project.file("$project.buildDir/$outputDir") + this.@imageOutputDir ?: project.layout.buildDirectory.dir(outputDir).get().asFile } @OutputDirectory File getInstallerOutputDir() { - this.@installerOutputDir ?: project.file("$project.buildDir/$outputDir") + this.@installerOutputDir ?: project.layout.buildDirectory.dir(outputDir).get().asFile } @Internal diff --git a/src/main/groovy/org/beryx/jlink/data/JlinkPluginExtension.groovy b/src/main/groovy/org/beryx/jlink/data/JlinkPluginExtension.groovy index 41837b63..c2b597d0 100644 --- a/src/main/groovy/org/beryx/jlink/data/JlinkPluginExtension.groovy +++ b/src/main/groovy/org/beryx/jlink/data/JlinkPluginExtension.groovy @@ -62,7 +62,7 @@ class JlinkPluginExtension { JlinkPluginExtension(Project project) { this.project = project jlinkBasePath = project.objects.property(String) - jlinkBasePath.set(project.provider{"$project.buildDir/jlinkbase" as String}) + jlinkBasePath.set(project.layout.buildDirectory.dir('jlinkbase').map { it -> it as String}) imageName = project.objects.property(String) imageName.set('') diff --git a/src/main/groovy/org/beryx/jlink/impl/PrepareModulesDirTaskImpl.groovy b/src/main/groovy/org/beryx/jlink/impl/PrepareModulesDirTaskImpl.groovy index b9269dcb..32300420 100644 --- a/src/main/groovy/org/beryx/jlink/impl/PrepareModulesDirTaskImpl.groovy +++ b/src/main/groovy/org/beryx/jlink/impl/PrepareModulesDirTaskImpl.groovy @@ -50,21 +50,18 @@ class PrepareModulesDirTaskImpl extends BaseTaskImpl } project.copy { + from project.jar.archiveFile into td.jlinkJarsDir - from (project.jar.archivePath) } adjustModuleDescriptors(depMgr) - - def mainModuleJar = new File(td.jlinkJarsDir, project.jar.archivePath.name) - def targetPath = "$td.jlinkJarsDir/${td.moduleName}.jar" } @CompileDynamic private void adjustModuleDescriptors(DependencyManager depMgr) { def nonModularModules = depMgr.nonModularJars.collect { Util.getModuleName(it) } def adjuster = new ModuleInfoAdjuster(td.mergedModuleName, nonModularModules) - def jarMap = (depMgr.modularJars + project.jar.archivePath).collectEntries { [it.name, it] } + def jarMap = (depMgr.modularJars + Util.getArchiveFile(project)).collectEntries { [it.name, it] } td.jlinkJarsDir.listFiles().each { File jar -> if(jarMap.keySet().contains(jar.name)) { def adjustedDescriptors = adjuster.getAdjustedDescriptors(jarMap[jar.name]) diff --git a/src/main/groovy/org/beryx/jlink/util/JdkUtil.groovy b/src/main/groovy/org/beryx/jlink/util/JdkUtil.groovy index f45dc4ee..03616e95 100644 --- a/src/main/groovy/org/beryx/jlink/util/JdkUtil.groovy +++ b/src/main/groovy/org/beryx/jlink/util/JdkUtil.groovy @@ -36,7 +36,7 @@ class JdkUtil { JdkDownloadOptions(Project project, String targetPlatform, String downloadUrl) { this.project = project - this.downloadDir = "$project.buildDir/jdks/$targetPlatform" + this.downloadDir = "${project.layout.buildDirectory.get()}/jdks/$targetPlatform" this.archiveName = "jdk" def urlPath = new URL(downloadUrl).path if(urlPath.endsWith(".tar.gz")) archiveExtension = "tar.gz"