diff --git a/build.sbt b/build.sbt index 34b5f62..6b2f922 100644 --- a/build.sbt +++ b/build.sbt @@ -160,10 +160,9 @@ IO copyFile(Keys.baseDirectory.value / "plugins.json", pluginsDir / "plugins.json") val json = IO read(Keys.baseDirectory.value / "plugins.json") - PluginsJson.parse(json).foreach { case (plugin, version, file) => - val url = s"https://github.com/gitbucket/${plugin}/releases/download/${version}/${file}" + PluginsJson.getUrls(json).foreach { url => log info s"Download: ${url}" - IO transfer(new java.net.URL(url).openStream, pluginsDir / file) + IO transfer(new java.net.URL(url).openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1)) } // zip it up diff --git a/plugins.json b/plugins.json index 8c83e7a..0b890eb 100644 --- a/plugins.json +++ b/plugins.json @@ -7,7 +7,7 @@ { "version": "1.4.0", "range": ">=4.19.0", - "file": "gitbucket-notifications-plugin_2.12-1.4.0.jar" + "url": "https://github.com/gitbucket/gitbucket-notifications-plugin/releases/download/1.4.0/gitbucket-notifications-plugin_2.12-1.4.0.jar" } ], "default": true @@ -20,7 +20,7 @@ { "version": "4.5.0", "range": ">=4.18.0", - "file": "gitbucket-emoji-plugin_2.12-4.5.0.jar" + "url": "https://github.com/gitbucket/gitbucket-emoji-plugin/releases/download/4.5.0/gitbucket-emoji-plugin_2.12-4.5.0.jar" } ], "default": false @@ -33,7 +33,7 @@ { "version": "4.11.0", "range": ">=4.19.0", - "file": "gitbucket-gist-plugin-assembly-4.11.0.jar" + "url": "https://github.com/gitbucket/gitbucket-gist-plugin/releases/download/4.11.0/gitbucket-gist-plugin-assembly-4.11.0.jar" } ], "default": false @@ -44,9 +44,9 @@ "description": "Project pages for gitbucket", "versions": [ { - "version": "v1.6.0", + "version": "1.6.0", "range": ">=4.19.0", - "file": "gitbucket-pages-plugin_2.12-1.6.0.jar" + "url": "https://github.com/gitbucket/gitbucket-pages-plugin/releases/download/v1.6.0/gitbucket-pages-plugin_2.12-1.6.0.jar" } ], "default": false diff --git a/project/PluginsJson.scala b/project/PluginsJson.scala index e47c528..dbf6ab1 100644 --- a/project/PluginsJson.scala +++ b/project/PluginsJson.scala @@ -3,17 +3,12 @@ object PluginsJson { - def parse(json: String): Seq[(String, String, String)] = { + def getUrls(json: String): Seq[String] = { val value = Json.parse(json) value.asArray.values.asScala.map { plugin => val pluginObject = plugin.asObject - val pluginName = "gitbucket-" + pluginObject.get("id").asString + "-plugin" - val latestVersionObject = pluginObject.get("versions").asArray.asScala.head.asObject - val file = latestVersionObject.get("file").asString - val version = latestVersionObject.get("version").asString - - (pluginName, version, file) + latestVersionObject.get("url").asString } } diff --git a/src/main/scala/gitbucket/core/plugin/PluginRepository.scala b/src/main/scala/gitbucket/core/plugin/PluginRepository.scala index b509323..c4cd051 100644 --- a/src/main/scala/gitbucket/core/plugin/PluginRepository.scala +++ b/src/main/scala/gitbucket/core/plugin/PluginRepository.scala @@ -35,7 +35,9 @@ case class VersionDef( version: String, - file: String, + url: String, range: String -) +){ + lazy val file = url.substring(url.lastIndexOf("/") + 1) +}