@@ -5,6 +5,8 @@ import com.github.jk1.license.render.JsonReportRenderer
5
5
import com.jetbrains.plugin.structure.toolbox.ToolboxMeta
6
6
import com.jetbrains.plugin.structure.toolbox.ToolboxPluginDescriptor
7
7
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
8
+ import org.jetbrains.intellij.pluginRepository.model.LicenseUrl
9
+ import org.jetbrains.intellij.pluginRepository.model.ProductFamily
8
10
import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfoRt
9
11
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
10
12
import java.nio.file.Path
@@ -153,7 +155,10 @@ fun CopySpec.fromCompileDependencies() {
153
155
)
154
156
}
155
157
156
- val pluginZip by tasks.creating(Zip ::class ) {
158
+ /* *
159
+ * Useful when doing manual local install.
160
+ */
161
+ val pluginPrettyZip by tasks.creating(Zip ::class ) {
157
162
archiveBaseName.set(properties(" name" ))
158
163
dependsOn(tasks.jar)
159
164
dependsOn(tasks.getByName(" generateLicenseReport" ))
@@ -162,6 +167,14 @@ val pluginZip by tasks.creating(Zip::class) {
162
167
into(extension.id) // folder like com.coder.toolbox
163
168
}
164
169
170
+ val pluginZip by tasks.creating(Zip ::class ) {
171
+ dependsOn(tasks.jar)
172
+ dependsOn(tasks.getByName(" generateLicenseReport" ))
173
+
174
+ fromCompileDependencies()
175
+ archiveBaseName.set(extension.id)
176
+ }
177
+
165
178
tasks.register(" cleanAll" , Delete ::class .java) {
166
179
dependsOn(tasks.clean)
167
180
delete(getPluginInstallDir())
@@ -187,20 +200,43 @@ private fun getPluginInstallDir(): Path {
187
200
return pluginsDir / extension.id
188
201
}
189
202
190
- val publishPlugin by tasks.creating {
203
+ val publishPlugin by tasks.registering {
191
204
dependsOn(pluginZip)
192
205
193
206
doLast {
207
+ val pluginMarketplaceToken: String = if (System .getenv(" JETBRAINS_MARKETPLACE_PUBLISH_TOKEN" ).isNullOrBlank()) {
208
+ error(" Env. variable `JETBRAINS_MARKETPLACE_PUBLISH_TOKEN` does not exist. Please set the env. variable to a token obtained from the marketplace." )
209
+ } else {
210
+ System .getenv(" JETBRAINS_MARKETPLACE_PUBLISH_TOKEN" )
211
+ }
212
+
213
+ println (" Plugin Marketplace Token: ${pluginMarketplaceToken.take(5 )} *****" )
214
+
194
215
val instance = PluginRepositoryFactory .create(
195
216
" https://plugins.jetbrains.com" ,
196
- project.property( " PUBLISH_TOKEN " ).toString()
217
+ pluginMarketplaceToken
197
218
)
198
219
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)
220
+ if (extension.version == " 0.1.0" ) {
221
+ instance.uploader.uploadNewPlugin(
222
+ pluginZip.outputs.files.singleFile,
223
+ listOf (" toolbox" , " gateway" ), // do not change
224
+ LicenseUrl .MIT , // choose wisely
225
+ ProductFamily .TOOLBOX , // do not change
226
+ extension.meta.vendor, // do not change
227
+ isHidden = true
228
+ )
229
+ } else {
230
+ // !!! subsequent updates !!!
231
+ instance.uploader.uploadUpdateByXmlIdAndFamily(
232
+ extension.id, // do not change
233
+ ProductFamily .TOOLBOX , // do not change
234
+ pluginZip.outputs.files.singleFile, // do not change
235
+ null , // do not change. Channels will be available later
236
+ " Bug fixes and improvements" ,
237
+ true
238
+ )
239
+ }
204
240
}
205
241
}
206
242
0 commit comments