[geedeecee] add fileChecksum util
This commit is contained in:
parent
ce0d4b7378
commit
e370cb5ef9
3 changed files with 82 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
package dev.adamko.geedeecee.internal
|
||||
|
||||
import org.gradle.api.file.Directory
|
||||
import org.jetbrains.kotlin.incremental.md5
|
||||
|
||||
// should be moved to common plugins lib
|
||||
|
||||
internal fun Directory.filesChecksum(): Long = asFileTree
|
||||
.files
|
||||
.map { it.readBytes() + it.absolutePath.toByteArray() }
|
||||
.fold(byteArrayOf()) { acc, bytes -> acc + bytes }
|
||||
.md5()
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package dev.adamko.geedeecee.internal
|
||||
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.file.FileCopyDetails
|
||||
import org.gradle.api.file.RelativePath
|
||||
|
||||
// move to common-lib
|
||||
|
||||
internal inline fun <reified T : Task> T.enabledIf(crossinline spec: (T) -> Boolean) {
|
||||
onlyIf {
|
||||
require(it is T)
|
||||
spec(it)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package dev.adamko.geedeecee.tasks
|
||||
|
||||
import dev.adamko.geedeecee.GDCPlugin
|
||||
import javax.inject.Inject
|
||||
import org.gradle.api.tasks.Sync
|
||||
|
||||
|
||||
// look into using 'build context' for up-to-date check
|
||||
// https://stackoverflow.com/questions/38946683/how-to-test-dockerignore-file
|
||||
// https://github.com/pwaller/docker-show-context
|
||||
// https://snippets.khromov.se/see-which-files-are-included-in-your-docker-build-context/
|
||||
|
||||
|
||||
//@CacheableTask
|
||||
//@Suppress("UnstableApiUsage")
|
||||
abstract class DockerContextFilesPreparation @Inject constructor(
|
||||
// private val files: FileSystemOperations,
|
||||
) : Sync() {
|
||||
|
||||
// @get:InputFiles
|
||||
//// @get:SkipWhenEmpty
|
||||
// @get:PathSensitive(PathSensitivity.RELATIVE)
|
||||
// @get:NormalizeLineEndings
|
||||
// abstract val dockerContextFiles: ConfigurableFileCollection
|
||||
|
||||
// @get:Input
|
||||
// abstract val copySpec: Property<CopySpec>
|
||||
//
|
||||
// @get:OutputDirectory
|
||||
// abstract val dockerContextDir: DirectoryProperty
|
||||
|
||||
init {
|
||||
group = GDCPlugin.GCD_TASK_GROUP
|
||||
}
|
||||
|
||||
// @TaskAction
|
||||
// fun exec() {
|
||||
// files.sync {
|
||||
// from(dockerContextFiles, copySpec)
|
||||
// into(dockerContextDir)
|
||||
//// with(copySpec)
|
||||
// }
|
||||
// }
|
||||
|
||||
// /** @see [CopySpec.from] */
|
||||
// override fun from(vararg sourcePaths: Any?): CopySpec =
|
||||
// copySpec.from(sourcePaths)
|
||||
//
|
||||
// /** @see [CopySpec.from] */
|
||||
// override fun from(sourcePath: Any, configureClosure: Closure<*>): CopySpec =
|
||||
// copySpec.from(sourcePath, configureClosure)
|
||||
//
|
||||
// /** @see [CopySpec.from] */
|
||||
// override fun from(sourcePath: Any, configureAction: Action<in CopySpec>): CopySpec =
|
||||
// copySpec.from(sourcePath, configureAction)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue