From 4f1bb98711e456f84b081e435e1001e94a35f556 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com> Date: Mon, 9 Jan 2023 12:27:11 +0100 Subject: [PATCH] Remove usages of internal Gradle API FileOperations (#2606) --- .../org/jetbrains/compose/ComposeExtension.kt | 2 +- .../org/jetbrains/compose/ComposePlugin.kt | 2 +- .../dsl/JvmApplicationBuildTypes.kt | 2 +- .../dsl/MacOSNotarizationSettings.kt | 2 +- .../application/dsl/MacOSSigningSettings.kt | 4 +- .../application/dsl/ProguardSettings.kt | 4 +- .../desktop/application/dsl/TargetFormat.kt | 4 +- .../internal/ExternalToolRunner.kt | 1 + .../internal/JvmApplicationContext.kt | 2 +- .../internal/JvmApplicationData.kt | 1 + .../internal/JvmApplicationInternal.kt | 1 + .../desktop/application/internal/JvmTasks.kt | 2 +- .../desktop/application/internal/MacSigner.kt | 1 + .../application/internal/configureDesktop.kt | 2 +- .../internal/configureJvmApplication.kt | 8 +++ .../internal/configureNativeApplication.kt | 4 +- .../application/internal/dirLayoutUtils.kt | 1 + .../application/internal/files/fileUtils.kt | 4 +- .../application/internal/packageVersions.kt | 1 + .../ValidatedMacOSSigningSettings.kt | 4 +- .../validation/validatePackageVersions.kt | 2 +- .../application/internal/wixToolset.kt | 2 + .../AbstractCheckNativeDistributionRuntime.kt | 10 ++-- .../AbstractCheckNotarizationStatusTask.kt | 4 +- .../application/tasks/AbstractJLinkTask.kt | 6 +- .../application/tasks/AbstractJPackageTask.kt | 19 +++--- .../tasks/AbstractJvmToolOperationTask.kt | 6 +- ...ctNativeMacApplicationPackageAppDirTask.kt | 6 +- ...tractNativeMacApplicationPackageDmgTask.kt | 4 +- ...AbstractNativeMacApplicationPackageTask.kt | 5 +- .../tasks/AbstractNotarizationTask.kt | 2 +- .../application/tasks/AbstractProguardTask.kt | 6 +- .../tasks/AbstractRunDistributableTask.kt | 8 +-- .../tasks/AbstractSuggestModulesTask.kt | 6 +- .../AbstractUploadAppForNotarizationTask.kt | 2 + .../preview/internal/configurePreview.kt | 1 + .../AbstractConfigureDesktopPreviewTask.kt | 6 +- .../tasks/AbstractComposeDesktopTask.kt | 14 ++--- ...kDefaultComposeApplicationResourcesTask.kt | 5 +- .../uikit/internal/SimctlUtils.kt | 2 +- .../configureExperimentalUikitApplication.kt | 4 +- .../internal/configureInstallIosDeployTask.kt | 4 +- .../internal/configureInstallXcodeGenTask.kt | 4 +- ...PackComposeUiKitApplicationForXCodeTask.kt | 2 +- .../internal/registerConnectedDeviceTasks.kt | 6 +- .../uikit/internal/registerSimulatorTasks.kt | 6 +- .../uikit/tasks/AbstractComposeIosTask.kt | 6 +- .../configureExperimentalWebApplication.kt | 2 +- .../ExperimentalUnpackSkikoWasmRuntimeTask.kt | 11 +++- .../utils}/diagnosticUtils.kt | 2 +- .../compose/internal/utils/fileUtils.kt | 58 +++++++++++++++++++ .../internal/{ => utils}/gradleUtils.kt | 23 +------- .../internal => internal/utils}/osUtils.kt | 4 +- .../utils/providerUtils.kt} | 33 ++--------- .../internal/{ => utils}/stringUtils.kt | 2 +- .../compose/internal/utils/taskUtils.kt | 22 +++++++ .../integration/DesktopApplicationTest.kt | 8 ++- .../compose/test/tests/unit/FileHashTest.kt | 4 +- 58 files changed, 212 insertions(+), 157 deletions(-) rename gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/{desktop/application/internal => internal/utils}/diagnosticUtils.kt (84%) create mode 100644 gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/fileUtils.kt rename gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/{ => utils}/gradleUtils.kt (55%) rename gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/{desktop/application/internal => internal/utils}/osUtils.kt (95%) rename gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/{desktop/application/internal/gradleUtils.kt => internal/utils/providerUtils.kt} (54%) rename gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/{ => utils}/stringUtils.kt (96%) create mode 100644 gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/taskUtils.kt diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt index 7cbf7a7c77..e16b8e7677 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt @@ -10,7 +10,7 @@ import org.gradle.api.model.ObjectFactory import org.gradle.api.plugins.ExtensionAware import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property -import org.jetbrains.compose.desktop.application.internal.nullableProperty +import org.jetbrains.compose.internal.utils.nullableProperty import javax.inject.Inject abstract class ComposeExtension @Inject constructor( diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt index 3b8b3e5d79..5e4a3a8079 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt @@ -20,11 +20,11 @@ import org.gradle.api.plugins.ExtensionAware import org.jetbrains.compose.android.AndroidExtension import org.jetbrains.compose.desktop.DesktopExtension import org.jetbrains.compose.desktop.application.internal.configureDesktop -import org.jetbrains.compose.desktop.application.internal.currentTarget import org.jetbrains.compose.desktop.preview.internal.initializePreview import org.jetbrains.compose.experimental.dsl.ExperimentalExtension import org.jetbrains.compose.experimental.internal.checkExperimentalTargetsWithSkikoIsEnabled import org.jetbrains.compose.experimental.internal.configureExperimental +import org.jetbrains.compose.internal.utils.currentTarget import org.jetbrains.compose.web.WebExtension import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/JvmApplicationBuildTypes.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/JvmApplicationBuildTypes.kt index 92aafbabf1..d542b3fae5 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/JvmApplicationBuildTypes.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/JvmApplicationBuildTypes.kt @@ -7,7 +7,7 @@ package org.jetbrains.compose.desktop.application.dsl import org.gradle.api.Action import org.gradle.api.model.ObjectFactory -import org.jetbrains.compose.desktop.application.internal.new +import org.jetbrains.compose.internal.utils.new import javax.inject.Inject abstract class JvmApplicationBuildTypes @Inject constructor( diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSNotarizationSettings.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSNotarizationSettings.kt index 6bc649e87c..8e98968e81 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSNotarizationSettings.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSNotarizationSettings.kt @@ -11,7 +11,7 @@ import org.gradle.api.provider.ProviderFactory import org.gradle.api.tasks.Input import org.gradle.api.tasks.Optional import org.jetbrains.compose.desktop.application.internal.ComposeProperties -import org.jetbrains.compose.desktop.application.internal.nullableProperty +import org.jetbrains.compose.internal.utils.nullableProperty import javax.inject.Inject abstract class MacOSNotarizationSettings { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSSigningSettings.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSSigningSettings.kt index d5b2bce4f2..0a009ef6f3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSSigningSettings.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/MacOSSigningSettings.kt @@ -11,8 +11,8 @@ import org.gradle.api.provider.ProviderFactory import org.gradle.api.tasks.Input import org.gradle.api.tasks.Optional import org.jetbrains.compose.desktop.application.internal.ComposeProperties -import org.jetbrains.compose.desktop.application.internal.notNullProperty -import org.jetbrains.compose.desktop.application.internal.nullableProperty +import org.jetbrains.compose.internal.utils.notNullProperty +import org.jetbrains.compose.internal.utils.nullableProperty import javax.inject.Inject abstract class MacOSSigningSettings { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt index cb1b2153c2..14a3e27b8f 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt @@ -8,8 +8,8 @@ package org.jetbrains.compose.desktop.application.dsl import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property -import org.jetbrains.compose.desktop.application.internal.notNullProperty -import org.jetbrains.compose.desktop.application.internal.nullableProperty +import org.jetbrains.compose.internal.utils.notNullProperty +import org.jetbrains.compose.internal.utils.nullableProperty import javax.inject.Inject private const val DEFAULT_PROGUARD_VERSION = "7.2.2" diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/TargetFormat.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/TargetFormat.kt index defdcd6f5c..5f6859b39d 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/TargetFormat.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/TargetFormat.kt @@ -5,8 +5,8 @@ package org.jetbrains.compose.desktop.application.dsl -import org.jetbrains.compose.desktop.application.internal.OS -import org.jetbrains.compose.desktop.application.internal.currentOS +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS enum class TargetFormat( internal val id: String, diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ExternalToolRunner.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ExternalToolRunner.kt index 4138f487fc..c8775f9b26 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ExternalToolRunner.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ExternalToolRunner.kt @@ -10,6 +10,7 @@ import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.process.ExecOperations import org.gradle.process.ExecResult +import org.jetbrains.compose.internal.utils.ioFile import java.io.File import java.time.LocalDateTime import java.time.format.DateTimeFormatter diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationContext.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationContext.kt index 2f51ceb46b..4ddb3593d0 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationContext.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationContext.kt @@ -13,7 +13,7 @@ import org.jetbrains.compose.desktop.application.dsl.JvmApplicationBuildType import org.jetbrains.compose.internal.KOTLIN_JVM_PLUGIN_ID import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID import org.jetbrains.compose.internal.javaSourceSets -import org.jetbrains.compose.internal.joinDashLowercaseNonEmpty +import org.jetbrains.compose.internal.utils.joinDashLowercaseNonEmpty import org.jetbrains.compose.internal.mppExt import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationData.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationData.kt index b444fcf21a..ebebf9fa9d 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationData.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationData.kt @@ -12,6 +12,7 @@ import org.gradle.api.provider.Provider import org.gradle.api.provider.ProviderFactory import org.jetbrains.compose.desktop.application.dsl.JvmApplicationDistributions import org.jetbrains.compose.desktop.application.dsl.JvmApplicationBuildTypes +import org.jetbrains.compose.internal.utils.new import javax.inject.Inject internal open class JvmApplicationData @Inject constructor( diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationInternal.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationInternal.kt index 46cc2dbecc..3736ca897c 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationInternal.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmApplicationInternal.kt @@ -13,6 +13,7 @@ import org.gradle.api.tasks.SourceSet import org.jetbrains.compose.desktop.application.dsl.JvmApplication import org.jetbrains.compose.desktop.application.dsl.JvmApplicationDistributions import org.jetbrains.compose.desktop.application.dsl.JvmApplicationBuildTypes +import org.jetbrains.compose.internal.utils.new import org.jetbrains.kotlin.gradle.plugin.KotlinTarget import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget import javax.inject.Inject diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmTasks.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmTasks.kt index cc24c16cb9..429f9c40c3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmTasks.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/JvmTasks.kt @@ -9,7 +9,7 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.tasks.TaskProvider import org.jetbrains.compose.desktop.application.dsl.JvmApplicationBuildType -import org.jetbrains.compose.internal.uppercaseFirstChar +import org.jetbrains.compose.internal.utils.uppercaseFirstChar internal class JvmTasks( private val project: Project, diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/MacSigner.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/MacSigner.kt index 61112ec94b..a38cab986d 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/MacSigner.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/MacSigner.kt @@ -6,6 +6,7 @@ package org.jetbrains.compose.desktop.application.internal import org.jetbrains.compose.desktop.application.internal.validation.ValidatedMacOSSigningSettings +import org.jetbrains.compose.internal.utils.MacUtils import java.io.File import java.nio.file.Files import java.util.regex.Pattern diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureDesktop.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureDesktop.kt index 869b053228..81955650c3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureDesktop.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureDesktop.kt @@ -8,7 +8,7 @@ package org.jetbrains.compose.desktop.application.internal import org.gradle.api.Project import org.jetbrains.compose.desktop.DesktopExtension import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask -import org.jetbrains.compose.internal.registerTask +import org.jetbrains.compose.internal.utils.registerTask internal fun configureDesktop(project: Project, desktopExtension: DesktopExtension) { if (desktopExtension._isJvmApplicationInitialized) { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt index 01fae60244..1a32d92c9a 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt @@ -17,6 +17,14 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.compose.desktop.application.internal.validation.validatePackageVersions import org.jetbrains.compose.desktop.application.tasks.* import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS +import org.jetbrains.compose.internal.utils.currentTarget +import org.jetbrains.compose.internal.utils.dir +import org.jetbrains.compose.internal.utils.ioFile +import org.jetbrains.compose.internal.utils.ioFileOrNull +import org.jetbrains.compose.internal.utils.javaExecutable +import org.jetbrains.compose.internal.utils.provider import java.io.File private val defaultJvmArgs = listOf("-D$CONFIGURE_SWING_GLOBALS=true") diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureNativeApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureNativeApplication.kt index 8d85aaecad..2cf2c7961c 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureNativeApplication.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureNativeApplication.kt @@ -15,7 +15,9 @@ import org.jetbrains.compose.desktop.application.tasks.AbstractNativeMacApplicat import org.jetbrains.compose.desktop.application.tasks.AbstractNativeMacApplicationPackageDmgTask import org.jetbrains.compose.desktop.application.tasks.AbstractNativeMacApplicationPackageTask import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask -import org.jetbrains.compose.internal.joinLowerCamelCase +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS +import org.jetbrains.compose.internal.utils.joinLowerCamelCase import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBinary import org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/dirLayoutUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/dirLayoutUtils.kt index 9cbb841412..108a62d9e5 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/dirLayoutUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/dirLayoutUtils.kt @@ -10,6 +10,7 @@ import org.gradle.api.Task import org.gradle.api.file.Directory import org.gradle.api.file.ProjectLayout import org.gradle.api.provider.Provider +import org.jetbrains.compose.internal.utils.dir internal val Project.jvmDirs: JvmDirectoriesProvider get() = JvmDirectoriesProvider(project.layout) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt index ae9d5fa51f..04bf09def5 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/files/fileUtils.kt @@ -7,8 +7,8 @@ package org.jetbrains.compose.desktop.application.internal.files import org.gradle.api.tasks.Internal import org.jetbrains.compose.desktop.application.dsl.TargetFormat -import org.jetbrains.compose.desktop.application.internal.OS -import org.jetbrains.compose.desktop.application.internal.currentOS +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS import java.io.* import java.security.DigestInputStream import java.security.MessageDigest diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/packageVersions.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/packageVersions.kt index f8a599f466..7362fbccb0 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/packageVersions.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/packageVersions.kt @@ -8,6 +8,7 @@ package org.jetbrains.compose.desktop.application.internal import org.gradle.api.provider.Provider import org.jetbrains.compose.desktop.application.dsl.JvmApplicationDistributions import org.jetbrains.compose.desktop.application.dsl.TargetFormat +import org.jetbrains.compose.internal.utils.OS internal fun JvmApplicationContext.packageVersionFor( targetFormat: TargetFormat diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/ValidatedMacOSSigningSettings.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/ValidatedMacOSSigningSettings.kt index 273baecc4a..e9e7854da0 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/ValidatedMacOSSigningSettings.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/ValidatedMacOSSigningSettings.kt @@ -9,8 +9,8 @@ import org.gradle.api.Project import org.gradle.api.provider.Provider import org.jetbrains.compose.desktop.application.dsl.MacOSSigningSettings import org.jetbrains.compose.desktop.application.internal.ComposeProperties -import org.jetbrains.compose.desktop.application.internal.OS -import org.jetbrains.compose.desktop.application.internal.currentOS +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS import java.io.File internal data class ValidatedMacOSSigningSettings( diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/validatePackageVersions.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/validatePackageVersions.kt index 020e333767..cb2b429b85 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/validatePackageVersions.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/validatePackageVersions.kt @@ -8,7 +8,7 @@ package org.jetbrains.compose.desktop.application.internal.validation import org.gradle.api.GradleException import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.compose.desktop.application.internal.JvmApplicationContext -import org.jetbrains.compose.desktop.application.internal.OS +import org.jetbrains.compose.internal.utils.OS import org.jetbrains.compose.desktop.application.internal.packageBuildVersionFor import org.jetbrains.compose.desktop.application.internal.packageVersionFor diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt index bde366f2ec..f952ec5b1b 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt @@ -9,6 +9,8 @@ import de.undercouch.gradle.tasks.download.Download import org.gradle.api.Project import org.gradle.api.tasks.Copy import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS import java.io.File internal const val DOWNLOAD_WIX_TOOLSET_TASK_NAME = "downloadWix" diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNativeDistributionRuntime.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNativeDistributionRuntime.kt index b729dc0cdf..7cf11e5015 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNativeDistributionRuntime.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNativeDistributionRuntime.kt @@ -7,16 +7,16 @@ package org.jetbrains.compose.desktop.application.tasks import org.gradle.api.file.Directory import org.gradle.api.file.RegularFile -import org.gradle.api.file.RegularFileProperty import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.* import org.jetbrains.compose.desktop.application.internal.JvmRuntimeProperties -import org.jetbrains.compose.desktop.application.internal.executableName -import org.jetbrains.compose.desktop.application.internal.ioFile -import org.jetbrains.compose.desktop.application.internal.notNullProperty +import org.jetbrains.compose.internal.utils.executableName +import org.jetbrains.compose.internal.utils.ioFile +import org.jetbrains.compose.internal.utils.notNullProperty import org.jetbrains.compose.desktop.application.internal.ExternalToolRunner import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask +import org.jetbrains.compose.internal.utils.clearDirs import java.io.File // __COMPOSE_NATIVE_DISTRIBUTIONS_MIN_JAVA_VERSION__ @@ -88,7 +88,7 @@ abstract class AbstractCheckNativeDistributionRuntime : AbstractComposeDesktopTa } private fun getJavaRuntimeVersionUnsafe(): String? { - cleanDirs(workingDir) + fileOperations.clearDirs(workingDir) val workingDir = workingDir.ioFile val printJavaRuntimeClassName = "PrintJavaRuntimeVersion" diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNotarizationStatusTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNotarizationStatusTask.kt index 307e38a661..1e19b9a1be 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNotarizationStatusTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNotarizationStatusTask.kt @@ -8,10 +8,10 @@ package org.jetbrains.compose.desktop.application.tasks import org.gradle.api.file.DirectoryProperty import org.gradle.api.tasks.* import org.jetbrains.compose.desktop.application.internal.ExternalToolRunner -import org.jetbrains.compose.desktop.application.internal.MacUtils +import org.jetbrains.compose.internal.utils.MacUtils import org.jetbrains.compose.desktop.application.internal.NOTARIZATION_REQUEST_INFO_FILE_NAME import org.jetbrains.compose.desktop.application.internal.NotarizationRequestInfo -import org.jetbrains.compose.desktop.application.internal.ioFile +import org.jetbrains.compose.internal.utils.ioFile abstract class AbstractCheckNotarizationStatusTask : AbstractNotarizationTask() { @get:Internal diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJLinkTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJLinkTask.kt index 05a7488d13..b44237ef7b 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJLinkTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJLinkTask.kt @@ -14,9 +14,9 @@ import org.gradle.api.tasks.Optional import org.jetbrains.compose.desktop.application.internal.RuntimeCompressionLevel import org.jetbrains.compose.desktop.application.internal.JvmRuntimeProperties import org.jetbrains.compose.desktop.application.internal.cliArg -import org.jetbrains.compose.desktop.application.internal.ioFile -import org.jetbrains.compose.desktop.application.internal.notNullProperty -import org.jetbrains.compose.desktop.application.internal.nullableProperty +import org.jetbrains.compose.internal.utils.ioFile +import org.jetbrains.compose.internal.utils.notNullProperty +import org.jetbrains.compose.internal.utils.nullableProperty import java.io.File // todo: public DSL diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt index c8ad3331ea..fca6a964a4 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt @@ -6,7 +6,6 @@ package org.jetbrains.compose.desktop.application.tasks import org.gradle.api.file.* -import org.gradle.api.internal.file.FileOperations import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import org.gradle.api.provider.Provider @@ -22,6 +21,7 @@ import org.jetbrains.compose.desktop.application.internal.files.* import org.jetbrains.compose.desktop.application.internal.files.MacJarSignFileCopyingProcessor import org.jetbrains.compose.desktop.application.internal.JvmRuntimeProperties import org.jetbrains.compose.desktop.application.internal.validation.validate +import org.jetbrains.compose.internal.utils.* import java.io.* import java.util.* import javax.inject.Inject @@ -408,8 +408,7 @@ abstract class AbstractJPackageTask @Inject constructor( outdatedLibs.addAll(files.files) logger.debug("Clearing all files in working dir: $libsDirFile") - fileOperations.delete(libsDirFile) - libsDirFile.mkdirs() + fileOperations.clearDirs(libsDirFile) } if (inputChanges.isIncremental) { @@ -440,8 +439,7 @@ abstract class AbstractJPackageTask @Inject constructor( val fileProcessor = macSigner?.let { signer -> val tmpDirForSign = signDir.ioFile - fileOperations.delete(tmpDirForSign) - tmpDirForSign.mkdirs() + fileOperations.clearDirs(tmpDirForSign) MacJarSignFileCopyingProcessor( signer, @@ -473,7 +471,7 @@ abstract class AbstractJPackageTask @Inject constructor( } // todo: incremental copy - cleanDirs(packagedResourcesDir) + fileOperations.clearDirs(packagedResourcesDir) val destResourcesDir = packagedResourcesDir.ioFile val appResourcesDir = appResourcesDir.ioFileOrNull if (appResourcesDir != null) { @@ -481,14 +479,14 @@ abstract class AbstractJPackageTask @Inject constructor( val relPath = file.relativeTo(appResourcesDir).path val destFile = destResourcesDir.resolve(relPath) if (file.isDirectory) { - fileOperations.mkdir(destFile) + fileOperations.mkdirs(destFile) } else { file.copyTo(destFile) } } } - cleanDirs(jpackageResources) + fileOperations.clearDirs(jpackageResources) if (currentOS == OS.MacOS) { InfoPlistBuilder(macExtraPlistKeysRawXml.orNull) .also { setInfoPlistValues(it) } @@ -642,7 +640,7 @@ private fun isSkikoForCurrentOS(lib: File): Boolean = lib.name.startsWith("skiko-awt-runtime-${currentOS.id}-${currentArch.id}") && lib.name.endsWith(".jar") -private fun unpackSkikoForCurrentOS(sourceJar: File, skikoDir: File, fileOperations: FileOperations): List { +private fun unpackSkikoForCurrentOS(sourceJar: File, skikoDir: File, fileOperations: FileSystemOperations): List { val entriesToUnpack = when (currentOS) { OS.MacOS -> setOf("libskiko-macos-${currentArch.id}.dylib") OS.Windows -> setOf("skiko-windows-${currentArch.id}.dll", "icudtl.dat") @@ -654,8 +652,7 @@ private fun unpackSkikoForCurrentOS(sourceJar: File, skikoDir: File, fileOperati val targetJar = skikoDir.resolve(sourceJar.name) outputFiles.add(targetJar) - fileOperations.delete(skikoDir) - fileOperations.mkdir(skikoDir) + fileOperations.clearDirs(skikoDir) transformJar(sourceJar, targetJar) { entry, zin, zout -> // check both entry or entry.sha256 if (entry.name.removeSuffix(".sha256") in entriesToUnpack) { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJvmToolOperationTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJvmToolOperationTask.kt index 675347b86c..d68aaf71b0 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJvmToolOperationTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJvmToolOperationTask.kt @@ -14,10 +14,8 @@ import org.gradle.api.tasks.* import org.gradle.process.ExecResult import org.gradle.work.InputChanges import org.jetbrains.compose.desktop.application.internal.ComposeProperties -import org.jetbrains.compose.desktop.application.internal.ioFile -import org.jetbrains.compose.desktop.application.internal.jvmToolFile -import org.jetbrains.compose.desktop.application.internal.notNullProperty import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask +import org.jetbrains.compose.internal.utils.* import java.io.File abstract class AbstractJvmToolOperationTask(private val toolName: String) : AbstractComposeDesktopTask() { @@ -37,7 +35,7 @@ abstract class AbstractJvmToolOperationTask(private val toolName: String) : Abst } protected open fun prepareWorkingDir(inputChanges: InputChanges) { - cleanDirs(workingDir) + fileOperations.clearDirs(workingDir) } protected open fun makeArgs(tmpDir: File): MutableList = arrayListOf().apply { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageAppDirTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageAppDirTask.kt index c3419aec0c..583c0e52e6 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageAppDirTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageAppDirTask.kt @@ -11,9 +11,9 @@ import org.gradle.api.tasks.* import org.gradle.api.tasks.Optional import org.jetbrains.compose.desktop.application.internal.InfoPlistBuilder import org.jetbrains.compose.desktop.application.internal.PlistKeys -import org.jetbrains.compose.desktop.application.internal.ioFile -import org.jetbrains.compose.desktop.application.internal.notNullProperty -import org.jetbrains.compose.desktop.application.internal.nullableProperty +import org.jetbrains.compose.internal.utils.ioFile +import org.jetbrains.compose.internal.utils.notNullProperty +import org.jetbrains.compose.internal.utils.nullableProperty import java.io.File private const val KOTLIN_NATIVE_MIN_SUPPORTED_MAC_OS = "10.13" diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageDmgTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageDmgTask.kt index fd50099664..e8622804e2 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageDmgTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageDmgTask.kt @@ -9,8 +9,8 @@ import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFileProperty import org.gradle.api.provider.Property import org.gradle.api.tasks.* -import org.jetbrains.compose.desktop.application.internal.ioFile -import org.jetbrains.compose.desktop.application.internal.notNullProperty +import org.jetbrains.compose.internal.utils.ioFile +import org.jetbrains.compose.internal.utils.notNullProperty import java.io.File abstract class AbstractNativeMacApplicationPackageDmgTask : AbstractNativeMacApplicationPackageTask() { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageTask.kt index 77e541e991..c9d0c8ce90 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNativeMacApplicationPackageTask.kt @@ -10,9 +10,8 @@ import org.gradle.api.file.DirectoryProperty import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.* -import org.jetbrains.compose.desktop.application.internal.ioFile -import org.jetbrains.compose.desktop.application.internal.notNullProperty import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask +import org.jetbrains.compose.internal.utils.* import java.io.File abstract class AbstractNativeMacApplicationPackageTask : AbstractComposeDesktopTask() { @@ -34,7 +33,7 @@ abstract class AbstractNativeMacApplicationPackageTask : AbstractComposeDesktopT @TaskAction fun run() { - cleanDirs(destinationDir, workingDir) + fileOperations.clearDirs(destinationDir, workingDir) createPackage( destinationDir = destinationDir.ioFile, diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNotarizationTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNotarizationTask.kt index d6b3c67362..4efbadacdd 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNotarizationTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractNotarizationTask.kt @@ -10,7 +10,7 @@ import org.gradle.api.tasks.Input import org.gradle.api.tasks.Nested import org.gradle.api.tasks.Optional import org.jetbrains.compose.desktop.application.dsl.MacOSNotarizationSettings -import org.jetbrains.compose.desktop.application.internal.nullableProperty +import org.jetbrains.compose.internal.utils.nullableProperty import org.jetbrains.compose.desktop.application.internal.validation.validate import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt index 86482eaaef..0fd0f4b984 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt @@ -15,12 +15,10 @@ import org.gradle.api.provider.Provider import org.gradle.api.tasks.* import org.gradle.api.tasks.Optional import org.jetbrains.compose.desktop.application.internal.* -import org.jetbrains.compose.desktop.application.internal.ioFile import org.jetbrains.compose.desktop.application.internal.files.mangledName import org.jetbrains.compose.desktop.application.internal.files.normalizedPath -import org.jetbrains.compose.desktop.application.internal.notNullProperty -import org.jetbrains.compose.desktop.application.internal.nullableProperty import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask +import org.jetbrains.compose.internal.utils.* import java.io.File import java.io.Writer import kotlin.collections.LinkedHashMap @@ -80,7 +78,7 @@ abstract class AbstractProguardTask : AbstractComposeDesktopTask() { project.dependencies.create("com.guardsquare:proguard-gradle:${proguardVersion.get()}") ).files - cleanDirs(destinationDir, workingDir) + fileOperations.clearDirs(destinationDir, workingDir) val destinationDir = destinationDir.ioFile.absoluteFile // todo: can be cached for a jdk diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractRunDistributableTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractRunDistributableTask.kt index ab581e2bbd..8d33b55c08 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractRunDistributableTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractRunDistributableTask.kt @@ -11,10 +11,10 @@ import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputDirectory import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.TaskProvider -import org.jetbrains.compose.desktop.application.internal.OS -import org.jetbrains.compose.desktop.application.internal.currentOS -import org.jetbrains.compose.desktop.application.internal.executableName -import org.jetbrains.compose.desktop.application.internal.ioFile +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS +import org.jetbrains.compose.internal.utils.executableName +import org.jetbrains.compose.internal.utils.ioFile import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask import javax.inject.Inject diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractSuggestModulesTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractSuggestModulesTask.kt index 2a5e55d82f..fb98b58c42 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractSuggestModulesTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractSuggestModulesTask.kt @@ -14,12 +14,10 @@ import org.gradle.api.provider.Provider import org.gradle.api.tasks.* import org.jetbrains.compose.desktop.application.dsl.DEFAULT_RUNTIME_MODULES import org.jetbrains.compose.desktop.application.internal.ComposeProperties -import org.jetbrains.compose.desktop.application.internal.ioFile import org.jetbrains.compose.desktop.application.internal.ExternalToolRunner -import org.jetbrains.compose.desktop.application.internal.jvmToolFile import org.jetbrains.compose.desktop.application.internal.files.normalizedPath -import org.jetbrains.compose.desktop.application.internal.notNullProperty import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask +import org.jetbrains.compose.internal.utils.* abstract class AbstractSuggestModulesTask : AbstractComposeDesktopTask() { @get:Input @@ -47,7 +45,7 @@ abstract class AbstractSuggestModulesTask : AbstractComposeDesktopTask() { fun run() { val jtool = jvmToolFile("jdeps", javaHome = javaHome) - cleanDirs(workingDir) + fileOperations.clearDirs(workingDir) val args = arrayListOf().apply { add("--print-module-deps") add("--ignore-missing-deps") diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractUploadAppForNotarizationTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractUploadAppForNotarizationTask.kt index 1385c7bc9d..ebc5e22a4f 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractUploadAppForNotarizationTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractUploadAppForNotarizationTask.kt @@ -11,6 +11,8 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.compose.desktop.application.internal.* import org.jetbrains.compose.desktop.application.internal.files.checkExistingFile import org.jetbrains.compose.desktop.application.internal.files.findOutputFileOrDir +import org.jetbrains.compose.internal.utils.MacUtils +import org.jetbrains.compose.internal.utils.ioFile import java.io.File import java.time.LocalDateTime import java.time.format.DateTimeFormatter diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/internal/configurePreview.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/internal/configurePreview.kt index 4b7de910b8..5ac6bad23f 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/internal/configurePreview.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/internal/configurePreview.kt @@ -5,6 +5,7 @@ import org.jetbrains.compose.desktop.DesktopExtension import org.jetbrains.compose.desktop.application.internal.JvmApplicationRuntimeFilesProvider import org.jetbrains.compose.desktop.preview.tasks.AbstractConfigureDesktopPreviewTask import org.jetbrains.compose.internal.* +import org.jetbrains.compose.internal.utils.uppercaseFirstChar import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt index fe84b26b32..013d101e58 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt @@ -7,9 +7,9 @@ import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.* import org.jetbrains.compose.ComposeBuildConfig -import org.jetbrains.compose.desktop.application.internal.currentTarget -import org.jetbrains.compose.desktop.application.internal.javaExecutable -import org.jetbrains.compose.desktop.application.internal.notNullProperty +import org.jetbrains.compose.internal.utils.currentTarget +import org.jetbrains.compose.internal.utils.javaExecutable +import org.jetbrains.compose.internal.utils.notNullProperty import org.jetbrains.compose.desktop.tasks.AbstractComposeDesktopTask import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.* import java.io.File diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractComposeDesktopTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractComposeDesktopTask.kt index 6115a0eb59..857f2325a8 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractComposeDesktopTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractComposeDesktopTask.kt @@ -8,7 +8,7 @@ package org.jetbrains.compose.desktop.tasks import org.gradle.api.DefaultTask import org.gradle.api.file.Directory import org.gradle.api.file.FileSystemLocation -import org.gradle.api.internal.file.FileOperations +import org.gradle.api.file.FileSystemOperations import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property import org.gradle.api.provider.Provider @@ -18,7 +18,8 @@ import org.gradle.api.tasks.LocalState import org.gradle.process.ExecOperations import org.jetbrains.compose.desktop.application.internal.ComposeProperties import org.jetbrains.compose.desktop.application.internal.ExternalToolRunner -import org.jetbrains.compose.desktop.application.internal.notNullProperty +import org.jetbrains.compose.internal.utils.clearDirs +import org.jetbrains.compose.internal.utils.notNullProperty import javax.inject.Inject abstract class AbstractComposeDesktopTask : DefaultTask() { @@ -32,7 +33,7 @@ abstract class AbstractComposeDesktopTask : DefaultTask() { protected abstract val execOperations: ExecOperations @get:Inject - protected abstract val fileOperations: FileOperations + protected abstract val fileOperations: FileSystemOperations @get:LocalState protected val logsDir: Provider = project.layout.buildDirectory.dir("compose/logs/$name") @@ -47,11 +48,4 @@ abstract class AbstractComposeDesktopTask : DefaultTask() { @get:Internal internal val runExternalTool: ExternalToolRunner get() = ExternalToolRunner(verbose, logsDir, execOperations) - - protected fun cleanDirs(vararg dirs: Provider) { - for (dir in dirs) { - fileOperations.delete(dir) - fileOperations.mkdir(dir) - } - } } \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractUnpackDefaultComposeApplicationResourcesTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractUnpackDefaultComposeApplicationResourcesTask.kt index a62312bcc2..18677f378a 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractUnpackDefaultComposeApplicationResourcesTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/tasks/AbstractUnpackDefaultComposeApplicationResourcesTask.kt @@ -13,7 +13,8 @@ import org.gradle.api.tasks.Internal import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.TaskAction import org.jetbrains.compose.ComposeBuildConfig -import org.jetbrains.compose.desktop.application.internal.ioFile +import org.jetbrains.compose.internal.utils.clearDirs +import org.jetbrains.compose.internal.utils.ioFile private const val DEFAULT_COMPOSE_PROGUARD_RULES_FILE_NAME = "default-compose-desktop-rules.pro" @@ -35,7 +36,7 @@ abstract class AbstractUnpackDefaultComposeApplicationResourcesTask : AbstractCo @TaskAction fun run() { - cleanDirs(destinationDir) + fileOperations.clearDirs(destinationDir) unpack(iconSourcePath("mac", "icns"), resources.macIcon) unpack(iconSourcePath("windows", "ico"), resources.windowsIcon) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlUtils.kt index 558239faf3..0aade06f79 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlUtils.kt @@ -6,7 +6,7 @@ package org.jetbrains.compose.experimental.uikit.internal import kotlinx.serialization.json.Json -import org.jetbrains.compose.desktop.application.internal.MacUtils +import org.jetbrains.compose.internal.utils.MacUtils import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask val json = Json { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureExperimentalUikitApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureExperimentalUikitApplication.kt index 0d67a1dc4c..17e090cb41 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureExperimentalUikitApplication.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureExperimentalUikitApplication.kt @@ -6,8 +6,8 @@ package org.jetbrains.compose.experimental.uikit.internal import org.gradle.api.Project -import org.jetbrains.compose.desktop.application.internal.OS -import org.jetbrains.compose.desktop.application.internal.currentOS +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS import org.jetbrains.compose.experimental.dsl.ExperimentalUiKitApplication import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallIosDeployTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallIosDeployTask.kt index 6b236937f0..f76f31be31 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallIosDeployTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallIosDeployTask.kt @@ -6,8 +6,8 @@ package org.jetbrains.compose.experimental.uikit.internal import org.gradle.api.Project -import org.jetbrains.compose.desktop.application.internal.MacUtils -import org.jetbrains.compose.desktop.application.internal.UnixUtils +import org.jetbrains.compose.internal.utils.MacUtils +import org.jetbrains.compose.internal.utils.UnixUtils import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask internal val Project.iosDeployExecutable get() = iosDeploySrc.resolve("build/Release/ios-deploy") diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallXcodeGenTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallXcodeGenTask.kt index 537d19f3e8..4d9c666bfd 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallXcodeGenTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallXcodeGenTask.kt @@ -6,8 +6,8 @@ package org.jetbrains.compose.experimental.uikit.internal import org.gradle.api.Project -import org.jetbrains.compose.desktop.application.internal.MacUtils -import org.jetbrains.compose.desktop.application.internal.UnixUtils +import org.jetbrains.compose.internal.utils.MacUtils +import org.jetbrains.compose.internal.utils.UnixUtils import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask internal val Project.xcodeGenExecutable get() = xcodeGenSrc.resolve(".build/apple/Products/Release/xcodegen") diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configurePackComposeUiKitApplicationForXCodeTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configurePackComposeUiKitApplicationForXCodeTask.kt index abd106cf84..ced8d72e00 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configurePackComposeUiKitApplicationForXCodeTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configurePackComposeUiKitApplicationForXCodeTask.kt @@ -7,7 +7,7 @@ package org.jetbrains.compose.experimental.uikit.internal import org.gradle.api.Project import org.jetbrains.compose.experimental.uikit.tasks.ExperimentalPackComposeApplicationForXCodeTask -import org.jetbrains.compose.internal.fileToDir +import org.jetbrains.compose.internal.utils.fileToDir import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerConnectedDeviceTasks.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerConnectedDeviceTasks.kt index 08a4d9979e..1a55d7b6d3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerConnectedDeviceTasks.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerConnectedDeviceTasks.kt @@ -7,13 +7,13 @@ package org.jetbrains.compose.experimental.uikit.internal import org.gradle.api.Project import org.gradle.api.tasks.TaskProvider -import org.jetbrains.compose.desktop.application.internal.MacUtils +import org.jetbrains.compose.internal.utils.MacUtils import org.jetbrains.compose.experimental.dsl.DeployTarget import org.jetbrains.compose.experimental.dsl.UiKitConfiguration import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask import org.jetbrains.compose.experimental.uikit.tasks.ExperimentalPackComposeApplicationForXCodeTask -import org.jetbrains.compose.internal.getLocalProperty -import org.jetbrains.compose.internal.localPropertiesFile +import org.jetbrains.compose.internal.utils.getLocalProperty +import org.jetbrains.compose.internal.utils.localPropertiesFile import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension fun Project.registerConnectedDeviceTasks( diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt index bbc9e867ed..4175d32174 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt @@ -7,9 +7,9 @@ package org.jetbrains.compose.experimental.uikit.internal import org.gradle.api.Project import org.gradle.api.tasks.TaskProvider -import org.jetbrains.compose.desktop.application.internal.Arch -import org.jetbrains.compose.desktop.application.internal.MacUtils -import org.jetbrains.compose.desktop.application.internal.currentArch +import org.jetbrains.compose.internal.utils.Arch +import org.jetbrains.compose.internal.utils.MacUtils +import org.jetbrains.compose.internal.utils.currentArch import org.jetbrains.compose.experimental.dsl.DeployTarget import org.jetbrains.compose.experimental.dsl.UiKitConfiguration import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/AbstractComposeIosTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/AbstractComposeIosTask.kt index 921b053930..94ac162184 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/AbstractComposeIosTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/AbstractComposeIosTask.kt @@ -7,7 +7,7 @@ package org.jetbrains.compose.experimental.uikit.tasks import org.gradle.api.DefaultTask import org.gradle.api.file.Directory -import org.gradle.api.internal.file.FileOperations +import org.gradle.api.file.FileSystemOperations import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property import org.gradle.api.provider.Provider @@ -17,7 +17,7 @@ import org.gradle.api.tasks.LocalState import org.gradle.process.ExecOperations import org.jetbrains.compose.desktop.application.internal.ComposeProperties import org.jetbrains.compose.desktop.application.internal.ExternalToolRunner -import org.jetbrains.compose.desktop.application.internal.notNullProperty +import org.jetbrains.compose.internal.utils.notNullProperty import javax.inject.Inject abstract class AbstractComposeIosTask : DefaultTask() { @@ -31,7 +31,7 @@ abstract class AbstractComposeIosTask : DefaultTask() { protected abstract val execOperations: ExecOperations @get:Inject - protected abstract val fileOperations: FileOperations + protected abstract val fileOperations: FileSystemOperations @get:LocalState protected val logsDir: Provider = project.layout.buildDirectory.dir("compose/logs/$name") diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/internal/configureExperimentalWebApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/internal/configureExperimentalWebApplication.kt index bd15b231c0..30028ffc23 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/internal/configureExperimentalWebApplication.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/internal/configureExperimentalWebApplication.kt @@ -6,7 +6,7 @@ package org.jetbrains.compose.experimental.web.internal import org.jetbrains.compose.experimental.dsl.ExperimentalWebApplication -import org.jetbrains.compose.internal.registerTask +import org.jetbrains.compose.internal.utils.registerTask import org.jetbrains.compose.experimental.web.tasks.ExperimentalUnpackSkikoWasmRuntimeTask import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/tasks/ExperimentalUnpackSkikoWasmRuntimeTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/tasks/ExperimentalUnpackSkikoWasmRuntimeTask.kt index e467af05e5..6bb67c0e86 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/tasks/ExperimentalUnpackSkikoWasmRuntimeTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/web/tasks/ExperimentalUnpackSkikoWasmRuntimeTask.kt @@ -9,10 +9,13 @@ import org.gradle.api.DefaultTask import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.component.ModuleComponentIdentifier import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.FileSystemOperations import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.TaskAction -import org.jetbrains.compose.internal.debug +import org.jetbrains.compose.internal.utils.clearDirs +import org.jetbrains.compose.internal.utils.debug +import javax.inject.Inject abstract class ExperimentalUnpackSkikoWasmRuntimeTask : DefaultTask() { @get:InputFiles @@ -21,10 +24,12 @@ abstract class ExperimentalUnpackSkikoWasmRuntimeTask : DefaultTask() { @get:OutputDirectory abstract val outputDir: DirectoryProperty + @get:Inject + internal abstract val fileOperations: FileSystemOperations + @TaskAction fun run() { - project.delete(outputDir) - project.mkdir(outputDir) + fileOperations.clearDirs(outputDir) val runtimeArtifacts = runtimeClasspath.resolvedConfiguration.resolvedArtifacts for (artifact in runtimeArtifacts) { logger.debug { "Checking artifact: id=${artifact.id}, file=${artifact.file}" } diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/diagnosticUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/diagnosticUtils.kt similarity index 84% rename from gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/diagnosticUtils.kt rename to gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/diagnosticUtils.kt index ecb09d127f..9ea704dee6 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/diagnosticUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/diagnosticUtils.kt @@ -3,7 +3,7 @@ * 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 java.io.PrintWriter import java.io.StringWriter diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/fileUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/fileUtils.kt new file mode 100644 index 0000000000..ed4dcec5ed --- /dev/null +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/fileUtils.kt @@ -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.toDir(project: Project): Provider = + project.layout.dir(map { File(it) }) + +internal fun Provider.fileToDir(project: Project): Provider = + project.layout.dir(this) + +internal fun Provider.file(relativePath: String): Provider = + map { it.file(relativePath) } + +internal fun Provider.dir(relativePath: String): Provider = + map { it.dir(relativePath) } + +internal val Provider.ioFile: File + get() = get().asFile + +internal val Provider.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) { + mkdirs(*dirs.ioFiles()) +} + +internal fun FileSystemOperations.clearDirs(vararg dirs: File) { + delete(*dirs) + mkdirs(*dirs) +} + +internal fun FileSystemOperations.clearDirs(vararg dirs: Provider) { + clearDirs(*dirs.ioFiles()) +} + +private fun Array>.ioFiles(): Array = + let { providers -> Array(size) { i -> providers[i].ioFile } } \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/gradleUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/gradleUtils.kt similarity index 55% rename from gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/gradleUtils.kt rename to gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/gradleUtils.kt index 7b17850738..966c05a9e0 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/gradleUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/gradleUtils.kt @@ -1,17 +1,12 @@ /* - * Copyright 2020-2021 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.internal +package org.jetbrains.compose.internal.utils import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.file.Directory import org.gradle.api.logging.Logger -import org.gradle.api.provider.Provider -import org.gradle.api.tasks.TaskProvider -import java.io.File import java.util.* internal inline fun Logger.info(fn: () -> String) { @@ -26,20 +21,6 @@ internal inline fun Logger.debug(fn: () -> String) { } } -internal inline fun Project.registerTask( - name: String, - crossinline fn: T.() -> Unit -): TaskProvider = - tasks.register(name, T::class.java) { task -> - task.fn() - } - -internal fun Provider.toDir(project: Project): Provider = - project.layout.dir(map { File(it) }) - -internal fun Provider.fileToDir(project: Project): Provider = - project.layout.dir(this) - val Project.localPropertiesFile get() = project.rootProject.file("local.properties") fun Project.getLocalProperty(key: String): String? { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/osUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/osUtils.kt similarity index 95% rename from gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/osUtils.kt rename to gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/osUtils.kt index cd6e77b3fc..4537489e8f 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/osUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/osUtils.kt @@ -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 diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/gradleUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/providerUtils.kt similarity index 54% rename from gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/gradleUtils.kt rename to gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/providerUtils.kt index 163ef12fb6..3ce83c064d 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/gradleUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/providerUtils.kt @@ -1,19 +1,17 @@ /* - * 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.Task -import org.gradle.api.file.Directory -import org.gradle.api.file.FileSystemLocation -import org.gradle.api.file.RegularFile import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property import org.gradle.api.provider.Provider -import org.gradle.api.tasks.TaskProvider -import java.io.File + +internal inline fun ObjectFactory.new(vararg params: Any): T = + newInstance(T::class.java, *params) @SuppressWarnings("UNCHECKED_CAST") internal inline fun ObjectFactory.nullableProperty(): Property = @@ -29,23 +27,4 @@ internal inline fun Provider.toProperty(objects: ObjectFactory): objects.property(T::class.java).value(this) internal inline fun Task.provider(noinline fn: () -> T): Provider = - project.provider(fn) - -internal fun Provider.file(relativePath: String): Provider = - map { it.file(relativePath) } - -internal fun Provider.dir(relativePath: String): Provider = - map { it.dir(relativePath) } - -internal inline fun ObjectFactory.new(vararg params: Any): T = - newInstance(T::class.java, *params) - -internal fun TaskProvider.dependsOn(vararg dependencies: Any) { - configure { it.dependsOn(*dependencies) } -} - -internal val Provider.ioFile: File - get() = get().asFile - -internal val Provider.ioFileOrNull: File? - get() = orNull?.asFile + project.provider(fn) \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/stringUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/stringUtils.kt similarity index 96% rename from gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/stringUtils.kt rename to gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/stringUtils.kt index 202b5494c7..5b9730aa48 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/stringUtils.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/stringUtils.kt @@ -3,7 +3,7 @@ * 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 +package org.jetbrains.compose.internal.utils internal fun String.uppercaseFirstChar(): String = transformFirstCharIfNeeded( diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/taskUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/taskUtils.kt new file mode 100644 index 0000000000..a9a02977e0 --- /dev/null +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/utils/taskUtils.kt @@ -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 TaskProvider.dependsOn(vararg dependencies: Any) { + configure { it.dependsOn(*dependencies) } +} + +internal inline fun Project.registerTask( + name: String, + crossinline fn: T.() -> Unit +): TaskProvider = + tasks.register(name, T::class.java) { task -> + task.fn() + } diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt index b1948346ea..417633b54a 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt @@ -7,8 +7,12 @@ package org.jetbrains.compose.test.tests.integration import org.gradle.internal.impldep.org.testng.Assert import org.gradle.testkit.runner.TaskOutcome -import org.jetbrains.compose.desktop.application.internal.* -import org.jetbrains.compose.internal.uppercaseFirstChar +import org.jetbrains.compose.internal.utils.MacUtils +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentArch +import org.jetbrains.compose.internal.utils.currentOS +import org.jetbrains.compose.internal.utils.currentTarget +import org.jetbrains.compose.internal.utils.uppercaseFirstChar import org.jetbrains.compose.test.utils.* import java.io.File diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt index a49a7aa6ef..4b20b6fa52 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt @@ -5,8 +5,8 @@ package org.jetbrains.compose.test.tests.unit -import org.jetbrains.compose.desktop.application.internal.OS -import org.jetbrains.compose.desktop.application.internal.currentOS +import org.jetbrains.compose.internal.utils.OS +import org.jetbrains.compose.internal.utils.currentOS import org.jetbrains.compose.desktop.application.internal.files.contentHash import org.junit.jupiter.api.Assertions.*