Newer
Older
gitbucket_jkp / build.sbt
@Steve K Steve K on 27 Dec 2017 10 KB Update dependencies
  1. import com.typesafe.sbt.license.{LicenseInfo, DepModuleInfo}
  2. import com.typesafe.sbt.pgp.PgpKeys._
  3.  
  4. val Organization = "io.github.gitbucket"
  5. val Name = "gitbucket"
  6. val GitBucketVersion = "4.20.0"
  7. val ScalatraVersion = "2.6.1"
  8. val JettyVersion = "9.4.7.v20170914"
  9.  
  10. lazy val root = (project in file(".")).enablePlugins(SbtTwirl, ScalatraPlugin, JRebelPlugin).settings(
  11.  
  12. )
  13.  
  14. sourcesInBase := false
  15. organization := Organization
  16. name := Name
  17. version := GitBucketVersion
  18. scalaVersion := "2.12.4"
  19.  
  20. // dependency settings
  21. resolvers ++= Seq(
  22. Classpaths.typesafeReleases,
  23. Resolver.jcenterRepo,
  24. "amateras" at "http://amateras.sourceforge.jp/mvn/",
  25. "sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/",
  26. "amateras-snapshot" at "http://amateras.sourceforge.jp/mvn-snapshot/"
  27. )
  28. libraryDependencies ++= Seq(
  29. "org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "4.9.2.201712150930-r",
  30. "org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.9.2.201712150930-r",
  31. "org.scalatra" %% "scalatra" % ScalatraVersion,
  32. "org.scalatra" %% "scalatra-json" % ScalatraVersion,
  33. "org.scalatra" %% "scalatra-forms" % ScalatraVersion,
  34. "org.json4s" %% "json4s-jackson" % "3.5.3",
  35. "commons-io" % "commons-io" % "2.6",
  36. "io.github.gitbucket" % "solidbase" % "1.0.2",
  37. "io.github.gitbucket" % "markedj" % "1.0.15",
  38. "org.apache.commons" % "commons-compress" % "1.15",
  39. "org.apache.commons" % "commons-email" % "1.5",
  40. "org.apache.httpcomponents" % "httpclient" % "4.5.4",
  41. "org.apache.sshd" % "apache-sshd" % "1.6.0" exclude("org.slf4j","slf4j-jdk14"),
  42. "org.apache.tika" % "tika-core" % "1.17",
  43. "com.github.takezoe" %% "blocking-slick-32" % "0.0.10",
  44. "com.novell.ldap" % "jldap" % "2009-10-07",
  45. "com.h2database" % "h2" % "1.4.196",
  46. "org.mariadb.jdbc" % "mariadb-java-client" % "2.2.1",
  47. "org.postgresql" % "postgresql" % "42.1.4",
  48. "ch.qos.logback" % "logback-classic" % "1.2.3",
  49. "com.zaxxer" % "HikariCP" % "2.7.4",
  50. "com.typesafe" % "config" % "1.3.2",
  51. "com.typesafe.akka" %% "akka-actor" % "2.5.8",
  52. "fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
  53. "com.github.bkromhout" % "java-diff-utils" % "2.1.1",
  54. "org.cache2k" % "cache2k-all" % "1.0.1.Final",
  55. "com.enragedginger" %% "akka-quartz-scheduler" % "1.6.1-akka-2.5.x" exclude("c3p0","c3p0"),
  56. "net.coobird" % "thumbnailator" % "0.4.8",
  57. "com.github.zafarkhaja" % "java-semver" % "0.9.0",
  58. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
  59. "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  60. "junit" % "junit" % "4.12" % "test",
  61. "org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
  62. "org.mockito" % "mockito-core" % "2.13.0" % "test",
  63. "com.wix" % "wix-embedded-mysql" % "3.0.0" % "test",
  64. "ru.yandex.qatools.embed" % "postgresql-embedded" % "2.6" % "test",
  65. "net.i2p.crypto" % "eddsa" % "0.2.0"
  66. )
  67.  
  68. // Compiler settings
  69. scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method")
  70. javacOptions in compile ++= Seq("-target", "8", "-source", "8")
  71. javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"
  72.  
  73. // Test settings
  74. //testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
  75. javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test"
  76. testOptions in Test += Tests.Setup( () => new java.io.File("target/gitbucket_home_for_test").mkdir() )
  77. fork in Test := true
  78.  
  79. // Packaging options
  80. packageOptions += Package.MainClass("JettyLauncher")
  81.  
  82. // Assembly settings
  83. test in assembly := {}
  84. assemblyMergeStrategy in assembly := {
  85. case PathList("META-INF", xs @ _*) =>
  86. (xs map {_.toLowerCase}) match {
  87. case ("manifest.mf" :: Nil) => MergeStrategy.discard
  88. case _ => MergeStrategy.discard
  89. }
  90. case x => MergeStrategy.first
  91. }
  92.  
  93. // JRebel
  94. //Seq(jrebelSettings: _*)
  95.  
  96. //jrebel.webLinks += (target in webappPrepare).value
  97. //jrebel.enabled := System.getenv().get("JREBEL") != null
  98. javaOptions in Jetty ++= Option(System.getenv().get("JREBEL")).toSeq.flatMap { path =>
  99. Seq("-noverify", "-XX:+UseConcMarkSweepGC", "-XX:+CMSClassUnloadingEnabled", s"-javaagent:${path}")
  100. }
  101.  
  102. // Exclude a war file from published artifacts
  103. signedArtifacts := {
  104. signedArtifacts.value.filterNot { case (_, file) => file.getName.endsWith(".war") || file.getName.endsWith(".war.asc") }
  105. }
  106.  
  107. // Create executable war file
  108. val ExecutableConfig = config("executable").hide
  109. Keys.ivyConfigurations += ExecutableConfig
  110. libraryDependencies ++= Seq(
  111. "org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
  112. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
  113. "org.eclipse.jetty" % "jetty-continuation" % JettyVersion % "executable",
  114. "org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
  115. "org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
  116. "org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
  117. "org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
  118. "org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
  119. "org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
  120. )
  121.  
  122. val executableKey = TaskKey[File]("executable")
  123. executableKey := {
  124. import java.util.jar.{ Manifest => JarManifest }
  125. import java.util.jar.Attributes.{ Name => AttrName }
  126.  
  127. val workDir = Keys.target.value / "executable"
  128. val warName = Keys.name.value + ".war"
  129.  
  130. val log = streams.value.log
  131. log info s"building executable webapp in ${workDir}"
  132.  
  133. // initialize temp directory
  134. val temp = workDir / "webapp"
  135. IO delete temp
  136.  
  137. // include jetty classes
  138. val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
  139. jettyJars foreach { jar =>
  140. IO unzip (jar, temp, (name:String) =>
  141. (name startsWith "javax/") ||
  142. (name startsWith "org/")
  143. )
  144. }
  145.  
  146. // include original war file
  147. val warFile = (Keys.`package`).value
  148. IO unzip (warFile, temp)
  149.  
  150. // include launcher classes
  151. val classDir = (Keys.classDirectory in Compile).value
  152. val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */)
  153. launchClasses foreach { name =>
  154. IO copyFile (classDir / name, temp / name)
  155. }
  156.  
  157. // include plugins
  158. val pluginsDir = temp / "WEB-INF" / "classes" / "plugins"
  159. IO createDirectory (pluginsDir)
  160. IO copyFile(Keys.baseDirectory.value / "plugins.json", pluginsDir / "plugins.json")
  161.  
  162. val json = IO read(Keys.baseDirectory.value / "plugins.json")
  163. PluginsJson.getUrls(json).foreach { url =>
  164. log info s"Download: ${url}"
  165. IO transfer(new java.net.URL(url).openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
  166. }
  167.  
  168. // zip it up
  169. IO delete (temp / "META-INF" / "MANIFEST.MF")
  170. val contentMappings = (temp.allPaths --- PathFinder(temp)).get pair { file => IO.relativizeFile(temp, file) }
  171. val manifest = new JarManifest
  172. manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
  173. manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
  174. val outputFile = workDir / warName
  175. IO jar (contentMappings.map { case (file, path) => (file, path.toString) } , outputFile, manifest)
  176.  
  177. // generate checksums
  178. Seq(
  179. "md5" -> "MD5",
  180. "sha1" -> "SHA-1",
  181. "sha256" -> "SHA-256"
  182. )
  183. .foreach { case (extension, algorithm) =>
  184. val checksumFile = workDir / (warName + "." + extension)
  185. Checksums generate (outputFile, checksumFile, algorithm)
  186. }
  187.  
  188. // done
  189. log info s"built executable webapp ${outputFile}"
  190. outputFile
  191. }
  192. publishTo := {
  193. val nexus = "https://oss.sonatype.org/"
  194. if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
  195. else Some("releases" at nexus + "service/local/staging/deploy/maven2")
  196. }
  197. publishMavenStyle := true
  198. pomIncludeRepository := { _ => false }
  199. pomExtra := (
  200. <url>https://github.com/gitbucket/gitbucket</url>
  201. <licenses>
  202. <license>
  203. <name>The Apache Software License, Version 2.0</name>
  204. <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
  205. </license>
  206. </licenses>
  207. <scm>
  208. <url>https://github.com/gitbucket/gitbucket</url>
  209. <connection>scm:git:https://github.com/gitbucket/gitbucket.git</connection>
  210. </scm>
  211. <developers>
  212. <developer>
  213. <id>takezoe</id>
  214. <name>Naoki Takezoe</name>
  215. <url>https://github.com/takezoe</url>
  216. </developer>
  217. <developer>
  218. <id>shimamoto</id>
  219. <name>Takako Shimamoto</name>
  220. <url>https://github.com/shimamoto</url>
  221. </developer>
  222. <developer>
  223. <id>tanacasino</id>
  224. <name>Tomofumi Tanaka</name>
  225. <url>https://github.com/tanacasino</url>
  226. </developer>
  227. <developer>
  228. <id>mrkm4ntr</id>
  229. <name>Shintaro Murakami</name>
  230. <url>https://github.com/mrkm4ntr</url>
  231. </developer>
  232. <developer>
  233. <id>nazoking</id>
  234. <name>nazoking</name>
  235. <url>https://github.com/nazoking</url>
  236. </developer>
  237. <developer>
  238. <id>McFoggy</id>
  239. <name>Matthieu Brouillard</name>
  240. <url>https://github.com/McFoggy</url>
  241. </developer>
  242. </developers>
  243. )
  244.  
  245. licenseOverrides := {
  246. case DepModuleInfo("com.github.bkromhout", "java-diff-utils", _) =>
  247. LicenseInfo(LicenseCategory.Apache, "Apache-2.0", "http://www.apache.org/licenses/LICENSE-2.0")
  248. }