Newer
Older
gitbucket_jkp / build.sbt
@Naoki Takezoe Naoki Takezoe on 20 Oct 2017 10 KB Bump to 4.19.0-SNAPSHOT
  1. import com.typesafe.sbt.license.{LicenseInfo, DepModuleInfo}
  2.  
  3. val Organization = "io.github.gitbucket"
  4. val Name = "gitbucket"
  5. val GitBucketVersion = "4.19.0-SNAPSHOT"
  6. val ScalatraVersion = "2.5.0"
  7. val JettyVersion = "9.3.19.v20170502"
  8.  
  9. lazy val root = (project in file(".")).enablePlugins(SbtTwirl, ScalatraPlugin, JRebelPlugin).settings(
  10.  
  11. )
  12.  
  13. sourcesInBase := false
  14. organization := Organization
  15. name := Name
  16. version := GitBucketVersion
  17. scalaVersion := "2.12.4"
  18.  
  19. // dependency settings
  20. resolvers ++= Seq(
  21. Classpaths.typesafeReleases,
  22. Resolver.jcenterRepo,
  23. "amateras" at "http://amateras.sourceforge.jp/mvn/",
  24. "sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/",
  25. "amateras-snapshot" at "http://amateras.sourceforge.jp/mvn-snapshot/"
  26. )
  27. libraryDependencies ++= Seq(
  28. "org.eclipse.jgit" % "org.eclipse.jgit.http.server" % "4.9.0.201710071750-r",
  29. "org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.9.0.201710071750-r",
  30. "org.scalatra" %% "scalatra" % ScalatraVersion,
  31. "org.scalatra" %% "scalatra-json" % ScalatraVersion,
  32. "org.json4s" %% "json4s-jackson" % "3.5.1",
  33. "io.github.gitbucket" %% "scalatra-forms" % "1.1.0",
  34. "commons-io" % "commons-io" % "2.5",
  35. "io.github.gitbucket" % "solidbase" % "1.0.2",
  36. "io.github.gitbucket" % "markedj" % "1.0.15",
  37. "org.apache.commons" % "commons-compress" % "1.13",
  38. "org.apache.commons" % "commons-email" % "1.4",
  39. "org.apache.httpcomponents" % "httpclient" % "4.5.3",
  40. "org.apache.sshd" % "apache-sshd" % "1.4.0" exclude("org.slf4j","slf4j-jdk14"),
  41. "org.apache.tika" % "tika-core" % "1.14",
  42. "com.github.takezoe" %% "blocking-slick-32" % "0.0.10",
  43. "joda-time" % "joda-time" % "2.9.9",
  44. "com.novell.ldap" % "jldap" % "2009-10-07",
  45. "com.h2database" % "h2" % "1.4.195",
  46. "org.mariadb.jdbc" % "mariadb-java-client" % "2.0.3",
  47. "org.postgresql" % "postgresql" % "42.0.0",
  48. "ch.qos.logback" % "logback-classic" % "1.2.3",
  49. "com.zaxxer" % "HikariCP" % "2.6.1",
  50. "com.typesafe" % "config" % "1.3.1",
  51. "com.typesafe.akka" %% "akka-actor" % "2.5.0",
  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.0.CR1",
  55. "com.enragedginger" %% "akka-quartz-scheduler" % "1.6.0-akka-2.4.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.7.22" % "test",
  63. "com.wix" % "wix-embedded-mysql" % "2.1.4" % "test",
  64. "ru.yandex.qatools.embed" % "postgresql-embedded" % "2.0" % "test",
  65. "net.i2p.crypto" % "eddsa" % "0.1.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. // Create executable war file
  103. val ExecutableConfig = config("executable").hide
  104. Keys.ivyConfigurations += ExecutableConfig
  105. libraryDependencies ++= Seq(
  106. "org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
  107. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
  108. "org.eclipse.jetty" % "jetty-continuation" % JettyVersion % "executable",
  109. "org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
  110. "org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
  111. "org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
  112. "org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
  113. "org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
  114. "org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
  115. )
  116.  
  117. val executableKey = TaskKey[File]("executable")
  118. executableKey := {
  119. import java.util.jar.{ Manifest => JarManifest }
  120. import java.util.jar.Attributes.{ Name => AttrName }
  121.  
  122. val workDir = Keys.target.value / "executable"
  123. val warName = Keys.name.value + ".war"
  124.  
  125. val log = streams.value.log
  126. log info s"building executable webapp in ${workDir}"
  127.  
  128. // initialize temp directory
  129. val temp = workDir / "webapp"
  130. IO delete temp
  131.  
  132. // include jetty classes
  133. val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
  134. jettyJars foreach { jar =>
  135. IO unzip (jar, temp, (name:String) =>
  136. (name startsWith "javax/") ||
  137. (name startsWith "org/")
  138. )
  139. }
  140.  
  141. // include original war file
  142. val warFile = (Keys.`package`).value
  143. IO unzip (warFile, temp)
  144.  
  145. // include launcher classes
  146. val classDir = (Keys.classDirectory in Compile).value
  147. val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */)
  148. launchClasses foreach { name =>
  149. IO copyFile (classDir / name, temp / name)
  150. }
  151.  
  152. // include plugins
  153. val pluginsDir = temp / "WEB-INF" / "classes" / "plugins"
  154. IO createDirectory (pluginsDir)
  155. IO copyFile(Keys.baseDirectory.value / "plugins.json", pluginsDir / "plugins.json")
  156.  
  157. val json = IO read(Keys.baseDirectory.value / "plugins.json")
  158. PluginsJson.parse(json).foreach { case (plugin, version) =>
  159. val url = if(plugin == "gitbucket-pages-plugin"){
  160. s"https://github.com/gitbucket/${plugin}/releases/download/v${version}/${plugin}_${scalaBinaryVersion.value}-${version}.jar"
  161. } else {
  162. s"https://github.com/gitbucket/${plugin}/releases/download/${version}/${plugin}_${scalaBinaryVersion.value}-${version}.jar"
  163. }
  164. log info s"Download: ${url}"
  165. IO transfer(new java.net.URL(url).openStream, pluginsDir / s"${plugin}_${scalaBinaryVersion.value}-${version}.jar")
  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. }