Browse Source

Allow using relative path, when specifying signing keychain (#988)

pull/994/head
Alexey Tsvetkov 3 years ago committed by GitHub
parent
commit
6d0f74346f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/ValidatedMacOSSigningSettings.kt
  2. 3
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt
  3. 2
      gradle-plugins/compose/src/test/test-projects/application/macSign/build.gradle

15
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/validation/ValidatedMacOSSigningSettings.kt

@ -5,6 +5,7 @@
package org.jetbrains.compose.desktop.application.internal.validation
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
@ -31,7 +32,8 @@ internal data class ValidatedMacOSSigningSettings(
}
internal fun MacOSSigningSettings.validate(
bundleIDProvider: Provider<String?>
bundleIDProvider: Provider<String?>,
project: Project
): ValidatedMacOSSigningSettings {
check(currentOS == OS.MacOS) { ERR_WRONG_OS }
@ -41,10 +43,13 @@ internal fun MacOSSigningSettings.validate(
?: error(ERR_UNKNOWN_PREFIX)
val signIdentity = this.identity.orNull
?: error(ERR_UNKNOWN_SIGN_ID)
val keychainFile = this.keychain.orNull?.let { File(it) }
if (keychainFile != null) {
check(keychainFile.exists()) {
"$ERR_PREFIX keychain is not an existing file: ${keychainFile.absolutePath}"
val keychainPath = this.keychain.orNull
val keychainFile =
listOf(project.file(keychainPath), project.rootProject.file(keychainPath))
.firstOrNull { it.exists() }
if (keychainPath != null) {
check(keychainFile != null && keychainFile.exists()) {
"$ERR_PREFIX could not find the specified keychain: $keychainPath"
}
}

3
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt

@ -178,7 +178,8 @@ abstract class AbstractJPackageTask @Inject constructor(
private val macSigner: MacSigner? by lazy {
val nonValidatedSettings = nonValidatedMacSigningSettings
if (currentOS == OS.MacOS && nonValidatedSettings?.sign?.get() == true) {
val validatedSettings = nonValidatedSettings.validate(nonValidatedMacBundleID)
val validatedSettings =
nonValidatedSettings.validate(nonValidatedMacBundleID, project)
MacSigner(validatedSettings, runExternalTool)
} else null
}

2
gradle-plugins/compose/src/test/test-projects/application/macSign/build.gradle

@ -29,7 +29,7 @@ compose.desktop {
signing {
sign.set(true)
identity.set("Compose Test")
keychain.set(project.file("compose.test.keychain").absolutePath)
keychain.set("compose.test.keychain")
}
}
}

Loading…
Cancel
Save