@@ -13,6 +13,7 @@ plugins {
1313 alias(libs.plugins.dependency.license.report)
1414 alias(libs.plugins.ksp)
1515 alias(libs.plugins.gradle.wrapper)
16+ alias(libs.plugins.changelog)
1617}
1718
1819buildscript {
@@ -50,6 +51,16 @@ dependencies {
5051 testImplementation(kotlin(" test" ))
5152}
5253
54+ val pluginId = properties(" group" )
55+ val pluginName = properties(" name" )
56+ val pluginVersion = properties(" version" )
57+
58+ changelog {
59+ version.set(pluginVersion)
60+ groups.set(emptyList())
61+ title.set(" Coder Toolbox Plugin Changelog" )
62+ }
63+
5364licenseReport {
5465 renderers = arrayOf(JsonReportRenderer (" dependencies.json" ))
5566 filters = arrayOf(ExcludeTransitiveDependenciesFilter ())
@@ -65,17 +76,19 @@ tasks.test {
6576 useJUnitPlatform()
6677}
6778
68- val pluginId = " com.coder.toolbox"
69- val pluginVersion = " 0.0.1"
70-
7179val assemblePlugin by tasks.registering(Jar ::class ) {
7280 archiveBaseName.set(pluginId)
7381 from(sourceSets.main.get().output)
7482}
7583
7684val copyPlugin by tasks.creating(Sync ::class .java) {
7785 dependsOn(assemblePlugin)
86+ fromCompileDependencies()
87+
88+ into(getPluginInstallDir())
89+ }
7890
91+ fun CopySpec.fromCompileDependencies () {
7992 from(assemblePlugin.get().outputs.files)
8093 from(" src/main/resources" ) {
8194 include(" extension.json" )
@@ -97,8 +110,14 @@ val copyPlugin by tasks.creating(Sync::class.java) {
97110 }
98111 },
99112 )
113+ }
100114
101- into(getPluginInstallDir())
115+ val pluginZip by tasks.creating(Zip ::class ) {
116+ dependsOn(assemblePlugin)
117+
118+ fromCompileDependencies()
119+ into(pluginId)
120+ archiveBaseName.set(pluginName)
102121}
103122
104123tasks.register(" cleanAll" , Delete ::class .java) {
@@ -126,26 +145,14 @@ private fun getPluginInstallDir(): Path {
126145 return pluginsDir / pluginId
127146}
128147
129- val pluginZip by tasks.creating(Zip ::class ) {
130- dependsOn(assemblePlugin)
131-
132- from(assemblePlugin.get().outputs.files)
133- from(" src/main/resources" ) {
134- include(" extension.json" )
135- include(" dependencies.json" )
136- }
137- from(" src/main/resources" ) {
138- include(" icon.svg" )
139- rename(" icon.svg" , " pluginIcon.svg" )
140- }
141- archiveBaseName.set(" $pluginId -$pluginVersion " )
142- }
143-
144- val uploadPlugin by tasks.creating {
148+ val publishPlugin by tasks.creating {
145149 dependsOn(pluginZip)
146150
147151 doLast {
148- val instance = PluginRepositoryFactory .create(" https://plugins.jetbrains.com" , project.property(" pluginMarketplaceToken" ).toString())
152+ val instance = PluginRepositoryFactory .create(
153+ " https://plugins.jetbrains.com" ,
154+ project.property(" PUBLISH_TOKEN" ).toString()
155+ )
149156
150157 // first upload
151158 // instance.uploader.uploadNewPlugin(pluginZip.outputs.files.singleFile, listOf("toolbox", "gateway"), LicenseUrl.APACHE_2_0, ProductFamily.TOOLBOX)
@@ -163,3 +170,5 @@ tasks.register("classpath") {
163170 )
164171 }
165172}
173+
174+ fun properties (key : String ) = project.findProperty(key).toString()
0 commit comments