@@ -5,6 +5,8 @@ import com.github.jk1.license.render.JsonReportRenderer
55import com.jetbrains.plugin.structure.toolbox.ToolboxMeta
66import com.jetbrains.plugin.structure.toolbox.ToolboxPluginDescriptor
77import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
8+ import org.jetbrains.intellij.pluginRepository.model.LicenseUrl
9+ import org.jetbrains.intellij.pluginRepository.model.ProductFamily
810import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfoRt
911import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1012import java.nio.file.Path
@@ -187,20 +189,43 @@ private fun getPluginInstallDir(): Path {
187189 return pluginsDir / extension.id
188190}
189191
190- val publishPlugin by tasks.creating {
192+ val publishPlugin by tasks.registering {
191193 dependsOn(pluginZip)
192194
193195 doLast {
196+ val pluginMarketplaceToken: String = if (System .getenv(" JETBRAINS_MARKETPLACE_PUBLISH_TOKEN" ).isNullOrBlank()) {
197+ error(" Env. variable `JETBRAINS_MARKETPLACE_PUBLISH_TOKEN` does not exist. Please set the env. variable to a token obtained from the marketplace." )
198+ } else {
199+ System .getenv(" JETBRAINS_MARKETPLACE_PUBLISH_TOKEN" )
200+ }
201+
202+ println (" Plugin Marketplace Token: ${pluginMarketplaceToken.take(5 )} *****" )
203+
194204 val instance = PluginRepositoryFactory .create(
195205 " https://plugins.jetbrains.com" ,
196- project.property( " PUBLISH_TOKEN " ).toString()
206+ pluginMarketplaceToken
197207 )
198208
199- // first upload
200- // instance.uploader.uploadNewPlugin(pluginZip.outputs.files.singleFile, listOf("toolbox", "gateway"), LicenseUrl.APACHE_2_0, ProductFamily.TOOLBOX)
201-
202- // subsequent updates
203- instance.uploader.upload(extension.id, pluginZip.outputs.files.singleFile)
209+ if (extension.version == " 0.1.0" ) {
210+ instance.uploader.uploadNewPlugin(
211+ pluginZip.outputs.files.singleFile,
212+ listOf (" toolbox" , " gateway" ), // do not change
213+ LicenseUrl .MIT , // choose wisely
214+ ProductFamily .TOOLBOX , // do not change
215+ extension.meta.vendor, // do not change
216+ isHidden = true
217+ )
218+ } else {
219+ // !!! subsequent updates !!!
220+ instance.uploader.uploadUpdateByXmlIdAndFamily(
221+ extension.id, // do not change
222+ ProductFamily .TOOLBOX , // do not change
223+ pluginZip.outputs.files.singleFile, // do not change
224+ null , // do not change. Channels will be available later
225+ " Bug fixes and improvements" ,
226+ true
227+ )
228+ }
204229 }
205230}
206231
0 commit comments