build-logic: rename copy files to destination rather than move (#1773)
This commit is contained in:
parent
8b36a45c71
commit
2edaf3d14b
2 changed files with 15 additions and 7 deletions
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue