in src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/PublishPluginTask.kt [97:132]
fun publishPlugin() {
if (token.orNull.isNullOrEmpty()) {
throw GradleException("'token' property must be specified for plugin publishing")
}
val path = archiveFile.asPath
val plugin = pluginManager.safelyCreatePlugin(path, suppressPluginProblems = false).getOrThrow()
val pluginId = plugin.pluginId
channels.get().forEach { channel ->
log.info("Uploading plugin '$pluginId' from '$path' to '${host.get()}', channel: '$channel'")
try {
val repositoryClient = when (ideServices.get()) {
true -> PluginRepositoryFactory.createWithImplementationClass(
host.get(),
token.get(),
"Automation",
IdeServicesPluginRepositoryService::class.java,
)
false -> PluginRepositoryFactory.create(host.get(), token.get())
}
repositoryClient.uploader.uploadUpdateByXmlIdAndFamily(
id = pluginId as StringPluginId,
family = ProductFamily.INTELLIJ,
file = path.toFile(),
channel = channel.takeIf { it != "default" },
notes = null,
isHidden = hidden.get(),
)
log.info("Uploaded successfully")
} catch (exception: Exception) {
throw GradleException("Failed to upload plugin: ${exception.message}", exception)
}
}
}