Build: Rewrite upload_plugins.gradle in Kotlin

This commit is contained in:
Vyacheslav Gerasimov
2019-08-15 18:27:04 +03:00
parent af2cd36c3d
commit 32153c26a8
+27 -33
View File
@@ -1,48 +1,42 @@
import org.jetbrains.intellij.pluginRepository.PluginRepositoryInstance
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
maven { maven("https://dl.bintray.com/jetbrains/intellij-plugin-service")
url('https://dl.bintray.com/jetbrains/intellij-plugin-service')
}
} }
dependencies { dependencies {
classpath 'org.jetbrains.intellij:plugin-repository-rest-client:0.4.32' classpath("org.jetbrains.intellij:plugin-repository-rest-client:0.4.32")
} }
} }
task uploadPlugins { task("uploadPlugins") {
doLast { doLast {
def env = System.getenv() val kotlinPluginId = 6954
def channel = env['PLUGIN_REPOSITORY_CHANNEL'] val channel = (project.findProperty("plugins.repository.channel") as String?)
if (channel == "_default_") { ?.let { if (it == "_default_") null else it }
channel = null val path = project.findProperty("plugins.path") as String? ?: "."
} val token = project.property("plugins.repository.token") as String
def path = env['PLUGIN_UPLOAD_PATH']
if (path == null) {
path = "."
}
def token = project.property("plugins.repository.token") val repo = PluginRepositoryInstance("https://plugins.jetbrains.com/", token)
def repo = new org.jetbrains.intellij.pluginRepository.PluginRepositoryInstance("https://plugins.jetbrains.com/", token) val pluginFiles = File(path)
.listFiles { _, fileName ->
File[] files = new File(path).listFiles({ _, String filename -> fileName.toLowerCase().let {
if (!filename.startsWith("kotlin-plugin") || !filename.endsWith(".zip")) false it.startsWith("kotlin-plugin") &&
else { it.endsWith(".zip") &&
// don't publish CIDR plugins to IDEA channel // don't publish CIDR plugins to IDEA channel
def filenameLowerCase = filename.toLowerCase() !it.contains("clion") &&
if (filenameLowerCase.contains("clion") || filenameLowerCase.contains("appcode")) false !it.contains("appcode")
else true }
} }
} as FilenameFilter)
files = files.sort { f1, f2 -> pluginFiles
f1.name.contains("1.1.2-5") ? 1 : (f2.name.contains("1.1.2-5") ? -1 : (f1.name <=> f2.name)) ?.sorted()
} ?.forEach { pluginFile ->
println("Uploading ${pluginFile.name}")
files.each { file -> repo.uploadPlugin(kotlinPluginId, pluginFile, channel)
println("Uploading ${file.name}") }
repo.uploadPlugin(6954, file, channel)
}
} }
} }