aboutsummaryrefslogtreecommitdiffstats
path: root/build-logic/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectBundleTask.kt
blob: b4c2b74bba0dca254d02aa6b7de6d76fd111f5d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright © 2014-2024 The Android Password Store Authors. All Rights Reserved.
 * SPDX-License-Identifier: GPL-3.0-only
 */

package app.passwordstore.gradle.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
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

abstract class CollectBundleTask : DefaultTask() {
  @get:InputFile abstract val bundleFile: RegularFileProperty

  @get:Input abstract val variantName: Property<String>

  @get:Input abstract val versionName: Property<String>

  @get:OutputDirectory abstract val outputDirectory: DirectoryProperty

  @TaskAction
  fun taskAction() {
    val outputDir = outputDirectory.asFile.get()
    outputDir.mkdirs()
    Files.copy(
      bundleFile.get().asFile.toPath(),
      outputDir.resolve("APS-${variantName.get()}-${versionName.get()}.aab").toPath(),
      StandardCopyOption.REPLACE_EXISTING,
    )
  }
}