Alexey Tsvetkov
2 years ago
committed by
GitHub
58 changed files with 212 additions and 157 deletions
@ -0,0 +1,58 @@
|
||||
/* |
||||
* Copyright 2020-2023 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
package org.jetbrains.compose.internal.utils |
||||
|
||||
import org.gradle.api.Project |
||||
import org.gradle.api.file.Directory |
||||
import org.gradle.api.file.FileSystemLocation |
||||
import org.gradle.api.file.FileSystemOperations |
||||
import org.gradle.api.file.RegularFile |
||||
import org.gradle.api.provider.Provider |
||||
import java.io.File |
||||
|
||||
internal fun Provider<String>.toDir(project: Project): Provider<Directory> = |
||||
project.layout.dir(map { File(it) }) |
||||
|
||||
internal fun Provider<File>.fileToDir(project: Project): Provider<Directory> = |
||||
project.layout.dir(this) |
||||
|
||||
internal fun Provider<Directory>.file(relativePath: String): Provider<RegularFile> = |
||||
map { it.file(relativePath) } |
||||
|
||||
internal fun Provider<Directory>.dir(relativePath: String): Provider<Directory> = |
||||
map { it.dir(relativePath) } |
||||
|
||||
internal val <T : FileSystemLocation> Provider<T>.ioFile: File |
||||
get() = get().asFile |
||||
|
||||
internal val <T : FileSystemLocation> Provider<T>.ioFileOrNull: File? |
||||
get() = orNull?.asFile |
||||
|
||||
internal fun FileSystemOperations.delete(vararg files: Any) { |
||||
delete { it.delete(*files) } |
||||
} |
||||
|
||||
internal fun FileSystemOperations.mkdirs(vararg dirs: File) { |
||||
for (dir in dirs) { |
||||
dir.mkdirs() |
||||
} |
||||
} |
||||
|
||||
internal fun FileSystemOperations.mkdirs(vararg dirs: Provider<out FileSystemLocation>) { |
||||
mkdirs(*dirs.ioFiles()) |
||||
} |
||||
|
||||
internal fun FileSystemOperations.clearDirs(vararg dirs: File) { |
||||
delete(*dirs) |
||||
mkdirs(*dirs) |
||||
} |
||||
|
||||
internal fun FileSystemOperations.clearDirs(vararg dirs: Provider<out FileSystemLocation>) { |
||||
clearDirs(*dirs.ioFiles()) |
||||
} |
||||
|
||||
private fun Array<out Provider<out FileSystemLocation>>.ioFiles(): Array<File> = |
||||
let { providers -> Array(size) { i -> providers[i].ioFile } } |
@ -1,9 +1,9 @@
|
||||
/* |
||||
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. |
||||
* Copyright 2020-2023 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
package org.jetbrains.compose.desktop.application.internal |
||||
package org.jetbrains.compose.internal.utils |
||||
|
||||
import org.gradle.api.provider.Provider |
||||
import org.jetbrains.compose.desktop.application.internal.files.checkExistingFile |
@ -0,0 +1,22 @@
|
||||
/* |
||||
* Copyright 2020-2023 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
package org.jetbrains.compose.internal.utils |
||||
|
||||
import org.gradle.api.Project |
||||
import org.gradle.api.Task |
||||
import org.gradle.api.tasks.TaskProvider |
||||
|
||||
internal fun <T : Task> TaskProvider<T>.dependsOn(vararg dependencies: Any) { |
||||
configure { it.dependsOn(*dependencies) } |
||||
} |
||||
|
||||
internal inline fun <reified T : Task> Project.registerTask( |
||||
name: String, |
||||
crossinline fn: T.() -> Unit |
||||
): TaskProvider<T> = |
||||
tasks.register(name, T::class.java) { task -> |
||||
task.fn() |
||||
} |
Loading…
Reference in new issue