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