Newer
Older
gitbucket_jkp / build.sbt
  1. import com.typesafe.sbt.license.{DepModuleInfo, LicenseInfo}
  2. import com.typesafe.sbt.pgp.PgpKeys._
  3.  
  4. val Organization = "io.github.gitbucket"
  5. val Name = "gitbucket"
  6. val GitBucketVersion = "4.22.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.5"
  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.11.0.201803080745-r",
  30. "org.eclipse.jgit" % "org.eclipse.jgit.archive" % "4.11.0.201803080745-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.3",
  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. "com.nimbusds" % "oauth2-oidc-sdk" % "5.45",
  59. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
  60. "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  61. "junit" % "junit" % "4.12" % "test",
  62. "org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
  63. "org.mockito" % "mockito-core" % "2.13.0" % "test",
  64. "com.wix" % "wix-embedded-mysql" % "3.0.0" % "test",
  65. "ru.yandex.qatools.embed" % "postgresql-embedded" % "2.6" % "test",
  66. "net.i2p.crypto" % "eddsa" % "0.2.0",
  67. "is.tagomor.woothee" % "woothee-java" % "1.7.0"
  68. )
  69.  
  70. // Compiler settings
  71. scalacOptions := Seq("-deprecation", "-language:postfixOps", "-opt:l:method")
  72. javacOptions in compile ++= Seq("-target", "8", "-source", "8")
  73. javaOptions in Jetty += "-Dlogback.configurationFile=/logback-dev.xml"
  74.  
  75. // Test settings
  76. //testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
  77. javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test"
  78. testOptions in Test += Tests.Setup( () => new java.io.File("target/gitbucket_home_for_test").mkdir() )
  79. fork in Test := true
  80.  
  81. // Packaging options
  82. packageOptions += Package.MainClass("JettyLauncher")
  83.  
  84. // Assembly settings
  85. test in assembly := {}
  86. assemblyMergeStrategy in assembly := {
  87. case PathList("META-INF", xs @ _*) =>
  88. (xs map {_.toLowerCase}) match {
  89. case ("manifest.mf" :: Nil) => MergeStrategy.discard
  90. case _ => MergeStrategy.discard
  91. }
  92. case x => MergeStrategy.first
  93. }
  94.  
  95. // JRebel
  96. //Seq(jrebelSettings: _*)
  97.  
  98. //jrebel.webLinks += (target in webappPrepare).value
  99. //jrebel.enabled := System.getenv().get("JREBEL") != null
  100. javaOptions in Jetty ++= Option(System.getenv().get("JREBEL")).toSeq.flatMap { path =>
  101. if (path.endsWith(".jar")) {
  102. // Legacy JRebel agent
  103. Seq("-noverify", "-XX:+UseConcMarkSweepGC", "-XX:+CMSClassUnloadingEnabled", s"-javaagent:${path}")
  104. } else {
  105. // New JRebel agent
  106. Seq(s"-agentpath:${path}")
  107. }
  108. }
  109.  
  110. // Exclude a war file from published artifacts
  111. signedArtifacts := {
  112. signedArtifacts.value.filterNot { case (_, file) => file.getName.endsWith(".war") || file.getName.endsWith(".war.asc") }
  113. }
  114.  
  115. // Create executable war file
  116. val ExecutableConfig = config("executable").hide
  117. Keys.ivyConfigurations += ExecutableConfig
  118. libraryDependencies ++= Seq(
  119. "org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
  120. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
  121. "org.eclipse.jetty" % "jetty-continuation" % JettyVersion % "executable",
  122. "org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
  123. "org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
  124. "org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
  125. "org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
  126. "org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
  127. "org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
  128. )
  129.  
  130. val executableKey = TaskKey[File]("executable")
  131. executableKey := {
  132. import java.util.jar.Attributes.{Name => AttrName}
  133. import java.util.jar.{Manifest => JarManifest}
  134.  
  135. val workDir = Keys.target.value / "executable"
  136. val warName = Keys.name.value + ".war"
  137.  
  138. val log = streams.value.log
  139. log info s"building executable webapp in ${workDir}"
  140.  
  141. // initialize temp directory
  142. val temp = workDir / "webapp"
  143. IO delete temp
  144.  
  145. // include jetty classes
  146. val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
  147. jettyJars foreach { jar =>
  148. IO unzip (jar, temp, (name:String) =>
  149. (name startsWith "javax/") ||
  150. (name startsWith "org/")
  151. )
  152. }
  153.  
  154. // include original war file
  155. val warFile = (Keys.`package`).value
  156. IO unzip (warFile, temp)
  157.  
  158. // include launcher classes
  159. val classDir = (Keys.classDirectory in Compile).value
  160. val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */)
  161. launchClasses foreach { name =>
  162. IO copyFile (classDir / name, temp / name)
  163. }
  164.  
  165. // include plugins
  166. val pluginsDir = temp / "WEB-INF" / "classes" / "plugins"
  167. IO createDirectory (pluginsDir)
  168. IO copyFile(Keys.baseDirectory.value / "plugins.json", pluginsDir / "plugins.json")
  169.  
  170. val json = IO read(Keys.baseDirectory.value / "plugins.json")
  171. PluginsJson.getUrls(json).foreach { url =>
  172. log info s"Download: ${url}"
  173. IO transfer(new java.net.URL(url).openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
  174. }
  175.  
  176. // zip it up
  177. IO delete (temp / "META-INF" / "MANIFEST.MF")
  178. val contentMappings = (temp.allPaths --- PathFinder(temp)).get pair { file => IO.relativizeFile(temp, file) }
  179. val manifest = new JarManifest
  180. manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
  181. manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
  182. val outputFile = workDir / warName
  183. IO jar (contentMappings.map { case (file, path) => (file, path.toString) } , outputFile, manifest)
  184.  
  185. // generate checksums
  186. Seq(
  187. "md5" -> "MD5",
  188. "sha1" -> "SHA-1",
  189. "sha256" -> "SHA-256"
  190. )
  191. .foreach { case (extension, algorithm) =>
  192. val checksumFile = workDir / (warName + "." + extension)
  193. Checksums generate (outputFile, checksumFile, algorithm)
  194. }
  195.  
  196. // done
  197. log info s"built executable webapp ${outputFile}"
  198. outputFile
  199. }
  200. publishTo := {
  201. val nexus = "https://oss.sonatype.org/"
  202. if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
  203. else Some("releases" at nexus + "service/local/staging/deploy/maven2")
  204. }
  205. publishMavenStyle := true
  206. pomIncludeRepository := { _ => false }
  207. pomExtra := (
  208. <url>https://github.com/gitbucket/gitbucket</url>
  209. <licenses>
  210. <license>
  211. <name>The Apache Software License, Version 2.0</name>
  212. <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
  213. </license>
  214. </licenses>
  215. <scm>
  216. <url>https://github.com/gitbucket/gitbucket</url>
  217. <connection>scm:git:https://github.com/gitbucket/gitbucket.git</connection>
  218. </scm>
  219. <developers>
  220. <developer>
  221. <id>takezoe</id>
  222. <name>Naoki Takezoe</name>
  223. <url>https://github.com/takezoe</url>
  224. </developer>
  225. <developer>
  226. <id>shimamoto</id>
  227. <name>Takako Shimamoto</name>
  228. <url>https://github.com/shimamoto</url>
  229. </developer>
  230. <developer>
  231. <id>tanacasino</id>
  232. <name>Tomofumi Tanaka</name>
  233. <url>https://github.com/tanacasino</url>
  234. </developer>
  235. <developer>
  236. <id>mrkm4ntr</id>
  237. <name>Shintaro Murakami</name>
  238. <url>https://github.com/mrkm4ntr</url>
  239. </developer>
  240. <developer>
  241. <id>nazoking</id>
  242. <name>nazoking</name>
  243. <url>https://github.com/nazoking</url>
  244. </developer>
  245. <developer>
  246. <id>McFoggy</id>
  247. <name>Matthieu Brouillard</name>
  248. <url>https://github.com/McFoggy</url>
  249. </developer>
  250. </developers>
  251. )
  252.  
  253. licenseOverrides := {
  254. case DepModuleInfo("com.github.bkromhout", "java-diff-utils", _) =>
  255. LicenseInfo(LicenseCategory.Apache, "Apache-2.0", "http://www.apache.org/licenses/LICENSE-2.0")
  256. }