Alexey Tsvetkov
4 years ago
committed by
Alexey Tsvetkov
5 changed files with 102 additions and 32 deletions
@ -0,0 +1,35 @@ |
|||||||
|
package org.jetbrains.compose.desktop.application.internal |
||||||
|
|
||||||
|
import java.io.File |
||||||
|
import java.util.* |
||||||
|
|
||||||
|
internal const val NOTARIZATION_REQUEST_INFO_FILE_NAME = "notarization-request.properties" |
||||||
|
|
||||||
|
internal data class NotarizationRequestInfo( |
||||||
|
var uuid: String = "", |
||||||
|
var uploadTime: String = "" |
||||||
|
) { |
||||||
|
fun loadFrom(file: File) { |
||||||
|
val properties = Properties().apply { |
||||||
|
file.inputStream().buffered().use { input -> |
||||||
|
load(input) |
||||||
|
} |
||||||
|
} |
||||||
|
uuid = properties.getProperty(UUID) ?: uuid |
||||||
|
uploadTime = properties.getProperty(UPLOAD_TIME) ?: uploadTime |
||||||
|
} |
||||||
|
|
||||||
|
fun saveTo(file: File) { |
||||||
|
val properties = Properties() |
||||||
|
properties[UUID] = uuid |
||||||
|
properties[UPLOAD_TIME] = uploadTime |
||||||
|
file.outputStream().buffered().use { output -> |
||||||
|
properties.store(output, null) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
companion object { |
||||||
|
private const val UUID = "uuid" |
||||||
|
private const val UPLOAD_TIME = "upload.time" |
||||||
|
} |
||||||
|
} |
@ -1,27 +1,53 @@ |
|||||||
package org.jetbrains.compose.desktop.application.tasks |
package org.jetbrains.compose.desktop.application.tasks |
||||||
|
|
||||||
import org.gradle.api.file.RegularFileProperty |
import org.gradle.api.file.DirectoryProperty |
||||||
import org.gradle.api.tasks.* |
import org.gradle.api.tasks.* |
||||||
import org.jetbrains.compose.desktop.application.internal.MacUtils |
import org.jetbrains.compose.desktop.application.internal.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.desktop.application.internal.ioFile |
||||||
|
|
||||||
abstract class AbstractCheckNotarizationStatusTask : AbstractNotarizationTask() { |
abstract class AbstractCheckNotarizationStatusTask : AbstractNotarizationTask() { |
||||||
@get:InputFile |
@get:Internal |
||||||
val requestIDFile: RegularFileProperty = objects.fileProperty() |
val requestDir: DirectoryProperty = objects.directoryProperty() |
||||||
|
|
||||||
@TaskAction |
@TaskAction |
||||||
fun run() { |
fun run() { |
||||||
val notarization = validateNotarization() |
val notarization = validateNotarization() |
||||||
|
|
||||||
val requestId = requestIDFile.ioFile.readText() |
val requests = HashSet<NotarizationRequestInfo>() |
||||||
|
for (file in requestDir.ioFile.walk()) { |
||||||
|
if (file.isFile && file.name == NOTARIZATION_REQUEST_INFO_FILE_NAME) { |
||||||
|
try { |
||||||
|
val status = NotarizationRequestInfo() |
||||||
|
status.loadFrom(file) |
||||||
|
requests.add(status) |
||||||
|
} catch (e: Exception) { |
||||||
|
logger.error("Invalid notarization request status file: $file", e) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (requests.isEmpty()) { |
||||||
|
logger.quiet("No existing notarization requests") |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
for (request in requests.sortedBy { it.uploadTime }) { |
||||||
|
try { |
||||||
|
logger.quiet("Checking status of notarization request '${request.uuid}'") |
||||||
execOperations.exec { exec -> |
execOperations.exec { exec -> |
||||||
exec.executable = MacUtils.xcrun.absolutePath |
exec.executable = MacUtils.xcrun.absolutePath |
||||||
exec.args( |
exec.args( |
||||||
"altool", |
"altool", |
||||||
"--notarization-info", requestId, |
"--notarization-info", request.uuid, |
||||||
"--username", notarization.appleID, |
"--username", notarization.appleID, |
||||||
"--password", notarization.password |
"--password", notarization.password |
||||||
) |
) |
||||||
} |
} |
||||||
|
} catch (e: Exception) { |
||||||
|
logger.error("Could not check notarization request '${request.uuid}'", e) |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
Loading…
Reference in new issue