diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2022-03-09 02:09:18 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 20:39:18 +0000 |
commit | 2edaf3d14baaa66e1d0f67197bcecc78e0eb0ba0 (patch) | |
tree | 729e1380a6fa1e33fb8b449a9881676d1ba7c4b9 /build-logic | |
parent | 8b36a45c714192ddb57c8d13ee6c5701a5402dda (diff) |
build-logic: rename copy files to destination rather than move (#1773)
Diffstat (limited to 'build-logic')
-rw-r--r-- | build-logic/android-plugins/src/main/kotlin/artifacts/CollectApksTask.kt | 11 | ||||
-rw-r--r-- | build-logic/android-plugins/src/main/kotlin/artifacts/CollectBundleTask.kt | 11 |
2 files changed, 15 insertions, 7 deletions
diff --git a/build-logic/android-plugins/src/main/kotlin/artifacts/CollectApksTask.kt b/build-logic/android-plugins/src/main/kotlin/artifacts/CollectApksTask.kt index 23f94f22..07f52943 100644 --- a/build-logic/android-plugins/src/main/kotlin/artifacts/CollectApksTask.kt +++ b/build-logic/android-plugins/src/main/kotlin/artifacts/CollectApksTask.kt @@ -1,7 +1,9 @@ package artifacts import com.android.build.api.variant.BuiltArtifactsLoader -import java.io.File +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption import org.gradle.api.DefaultTask import org.gradle.api.file.DirectoryProperty import org.gradle.api.provider.Property @@ -32,8 +34,11 @@ abstract class CollectApksTask : DefaultTask() { val builtArtifacts = builtArtifactsLoader.get().load(apkFolder.get()) ?: throw RuntimeException("Cannot load APKs") builtArtifacts.elements.forEach { artifact -> - File(artifact.outputFile) - .renameTo(outputDir.resolve("APS-${variantName.get()}-${artifact.versionName}.apk")) + Files.copy( + Paths.get(artifact.outputFile), + outputDir.resolve("APS-${variantName.get()}-${artifact.versionName}.apk").toPath(), + StandardCopyOption.REPLACE_EXISTING, + ) } } } diff --git a/build-logic/android-plugins/src/main/kotlin/artifacts/CollectBundleTask.kt b/build-logic/android-plugins/src/main/kotlin/artifacts/CollectBundleTask.kt index a735fb7b..709744f2 100644 --- a/build-logic/android-plugins/src/main/kotlin/artifacts/CollectBundleTask.kt +++ b/build-logic/android-plugins/src/main/kotlin/artifacts/CollectBundleTask.kt @@ -1,5 +1,7 @@ package artifacts +import java.nio.file.Files +import java.nio.file.StandardCopyOption import org.gradle.api.DefaultTask import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFileProperty @@ -22,9 +24,10 @@ abstract class CollectBundleTask : DefaultTask() { fun taskAction() { val outputDir = outputDirectory.asFile.get() outputDir.mkdirs() - bundleFile - .get() - .asFile - .renameTo(outputDir.resolve("APS-${variantName.get()}-${versionName.get()}.aab")) + Files.copy( + bundleFile.get().asFile.toPath(), + outputDir.resolve("APS-${variantName.get()}-${versionName.get()}.aab").toPath(), + StandardCopyOption.REPLACE_EXISTING, + ) } } |