46 lines
1.3 KiB
Kotlin
46 lines
1.3 KiB
Kotlin
/*
|
|
* Copyright 2024, 2025 New Vector Ltd.
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
* Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
package extension
|
|
|
|
import java.io.File
|
|
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.CacheableTask
|
|
import org.gradle.api.tasks.Input
|
|
import org.gradle.api.tasks.InputFile
|
|
import org.gradle.api.tasks.OutputDirectory
|
|
import org.gradle.api.tasks.PathSensitive
|
|
import org.gradle.api.tasks.PathSensitivity
|
|
import org.gradle.api.tasks.TaskAction
|
|
|
|
@CacheableTask
|
|
abstract class AssetCopyTask : DefaultTask() {
|
|
@get:OutputDirectory
|
|
abstract val outputDirectory: DirectoryProperty
|
|
|
|
@get:PathSensitive(PathSensitivity.RELATIVE)
|
|
@get:InputFile
|
|
abstract val inputFile: RegularFileProperty
|
|
|
|
@get:Input
|
|
abstract val targetFileName: Property<String>
|
|
|
|
@TaskAction
|
|
fun action() {
|
|
println("Copying ${inputFile.get()} to ${outputDirectory.get().asFile}/${targetFileName.get()}")
|
|
inputFile.get().asFile.copyTo(
|
|
target = File(
|
|
outputDirectory.get().asFile,
|
|
targetFileName.get(),
|
|
),
|
|
overwrite = true,
|
|
)
|
|
}
|
|
}
|