mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
Adopt latest version if different versions of same plugin are found
This commit is contained in:
@@ -50,6 +50,7 @@ libraryDependencies ++= Seq(
|
||||
"org.cache2k" % "cache2k-all" % "1.0.0.CR1",
|
||||
"com.enragedginger" %% "akka-quartz-scheduler" % "1.6.0-akka-2.4.x" exclude("c3p0","c3p0"),
|
||||
"net.coobird" % "thumbnailator" % "0.4.8",
|
||||
"com.github.zafarkhaja" % "java-semver" % "0.9.0",
|
||||
"org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
|
||||
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
|
||||
"junit" % "junit" % "4.12" % "test",
|
||||
|
||||
@@ -21,6 +21,7 @@ import play.twirl.api.Html
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.collection.mutable.ListBuffer
|
||||
import com.github.zafarkhaja.semver.Version
|
||||
|
||||
class PluginRegistry {
|
||||
|
||||
@@ -197,7 +198,16 @@ object PluginRegistry {
|
||||
if(pluginDir.exists && pluginDir.isDirectory){
|
||||
pluginDir.listFiles(new FilenameFilter {
|
||||
override def accept(dir: File, name: String): Boolean = name.endsWith(".jar")
|
||||
}).sortBy(_.getName).foreach { pluginJar =>
|
||||
}).map { file =>
|
||||
val Array(name, version) = file.getName.split("_2.12-")
|
||||
(name, Version.valueOf(version.replaceFirst("\\.jar$", "")), file)
|
||||
}.groupBy { case (name, _, _) =>
|
||||
name
|
||||
}.map { case (name, versions) =>
|
||||
// Adopt the latest version
|
||||
versions.sortBy { case (name, version, file) => version }.reverse.head._3
|
||||
}.toSeq.sortBy(_.getName).foreach { pluginJar =>
|
||||
logger.info(s"Initialize ${pluginJar.getName}")
|
||||
val classLoader = new URLClassLoader(Array(pluginJar.toURI.toURL), Thread.currentThread.getContextClassLoader)
|
||||
try {
|
||||
val plugin = classLoader.loadClass("Plugin").getDeclaredConstructor().newInstance().asInstanceOf[Plugin]
|
||||
@@ -222,7 +232,6 @@ object PluginRegistry {
|
||||
description = plugin.description,
|
||||
pluginClass = plugin
|
||||
))
|
||||
|
||||
} catch {
|
||||
case e: Throwable => {
|
||||
logger.error(s"Error during plugin initialization: ${pluginJar.getAbsolutePath}", e)
|
||||
|
||||
Reference in New Issue
Block a user