Newer
Older
gitbucket_jkp / build.sbt
@Scala Steward Scala Steward on 4 Feb 2023 11 KB Update tika-core to 2.7.0
  1. import com.typesafe.sbt.license.{DepModuleInfo, LicenseInfo}
  2. import com.jsuereth.sbtpgp.PgpKeys._
  3.  
  4. val Organization = "io.github.gitbucket"
  5. val Name = "gitbucket"
  6. val GitBucketVersion = "4.38.4"
  7. val ScalatraVersion = "2.8.4"
  8. val JettyVersion = "9.4.50.v20221201"
  9. val JgitVersion = "5.13.1.202206130422-r"
  10.  
  11. lazy val root = (project in file("."))
  12. .enablePlugins(SbtTwirl, ScalatraPlugin)
  13.  
  14. sourcesInBase := false
  15. organization := Organization
  16. name := Name
  17. version := GitBucketVersion
  18. scalaVersion := "2.13.10"
  19.  
  20. // scalafmtOnCompile := true
  21.  
  22. coverageExcludedPackages := ".*\\.html\\..*"
  23.  
  24. // dependency settings
  25. resolvers ++= Seq(
  26. Classpaths.typesafeReleases,
  27. "sonatype-snapshot" at "https://oss.sonatype.org/content/repositories/snapshots/"
  28. )
  29.  
  30. libraryDependencies ++= Seq(
  31. "org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
  32. "org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
  33. "org.scalatra" %% "scalatra" % ScalatraVersion cross CrossVersion.for3Use2_13,
  34. "org.scalatra" %% "scalatra-json" % ScalatraVersion cross CrossVersion.for3Use2_13,
  35. "org.scalatra" %% "scalatra-forms" % ScalatraVersion cross CrossVersion.for3Use2_13,
  36. "org.json4s" %% "json4s-jackson" % "4.0.6" cross CrossVersion.for3Use2_13,
  37. "commons-io" % "commons-io" % "2.11.0",
  38. "io.github.gitbucket" % "solidbase" % "1.0.5",
  39. "io.github.gitbucket" % "markedj" % "1.0.17",
  40. "org.apache.commons" % "commons-compress" % "1.22",
  41. "org.apache.commons" % "commons-email" % "1.5",
  42. "commons-net" % "commons-net" % "3.9.0",
  43. "org.apache.httpcomponents" % "httpclient" % "4.5.14",
  44. "org.apache.sshd" % "apache-sshd" % "2.9.2" exclude ("org.slf4j", "slf4j-jdk14") exclude ("org.apache.sshd", "sshd-mina") exclude ("org.apache.sshd", "sshd-netty"),
  45. "org.apache.tika" % "tika-core" % "2.7.0",
  46. "com.github.takezoe" %% "blocking-slick-32" % "0.0.12" cross CrossVersion.for3Use2_13,
  47. "com.novell.ldap" % "jldap" % "2009-10-07",
  48. "com.h2database" % "h2" % "1.4.199",
  49. "org.mariadb.jdbc" % "mariadb-java-client" % "2.7.6",
  50. "org.postgresql" % "postgresql" % "42.5.3",
  51. "ch.qos.logback" % "logback-classic" % "1.3.5",
  52. "com.zaxxer" % "HikariCP" % "4.0.3" exclude ("org.slf4j", "slf4j-api"),
  53. "com.typesafe" % "config" % "1.4.2",
  54. "fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0",
  55. "io.github.java-diff-utils" % "java-diff-utils" % "4.12",
  56. "org.cache2k" % "cache2k-all" % "1.6.0.Final",
  57. "net.coobird" % "thumbnailator" % "0.4.19",
  58. "com.github.zafarkhaja" % "java-semver" % "0.9.0",
  59. "com.nimbusds" % "oauth2-oidc-sdk" % "10.5.1",
  60. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
  61. "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  62. "junit" % "junit" % "4.13.2" % "test",
  63. "org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test" cross CrossVersion.for3Use2_13,
  64. "org.mockito" % "mockito-core" % "4.11.0" % "test",
  65. "com.dimafeng" %% "testcontainers-scala" % "0.40.12" % "test",
  66. "org.testcontainers" % "mysql" % "1.17.6" % "test",
  67. "org.testcontainers" % "postgresql" % "1.17.6" % "test",
  68. "net.i2p.crypto" % "eddsa" % "0.3.0",
  69. "is.tagomor.woothee" % "woothee-java" % "1.11.0",
  70. "org.ec4j.core" % "ec4j-core" % "0.3.0",
  71. "org.kohsuke" % "github-api" % "1.313" % "test"
  72. )
  73.  
  74. libraryDependencies ~= {
  75. _.map {
  76. case x if x.name == "twirl-api" =>
  77. x cross CrossVersion.for3Use2_13
  78. case x =>
  79. x
  80. }
  81. }
  82.  
  83. // Compiler settings
  84. scalacOptions := Seq(
  85. "-deprecation",
  86. "-language:postfixOps",
  87. "-opt:l:method",
  88. "-feature",
  89. "-Wunused:imports",
  90. "-Wconf:cat=unused&src=twirl/.*:s,cat=unused&src=scala/gitbucket/core/model/[^/]+\\.scala:s"
  91. )
  92. compile / javacOptions ++= Seq("-target", "8", "-source", "8")
  93.  
  94. // Test settings
  95. //testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
  96. Test / javaOptions += "-Dgitbucket.home=target/gitbucket_home_for_test"
  97. Test / testOptions += Tests.Setup(() => new java.io.File("target/gitbucket_home_for_test").mkdir())
  98. Test / fork := true
  99.  
  100. // Packaging options
  101. packageOptions += Package.MainClass("JettyLauncher")
  102.  
  103. // Assembly settings
  104. assembly / test := {}
  105. assembly / assemblyMergeStrategy := {
  106. case PathList("META-INF", xs @ _*) =>
  107. (xs map { _.toLowerCase }) match {
  108. case ("manifest.mf" :: Nil) => MergeStrategy.discard
  109. case _ => MergeStrategy.discard
  110. }
  111. case x => MergeStrategy.first
  112. }
  113.  
  114. // Exclude a war file from published artifacts
  115. signedArtifacts := {
  116. signedArtifacts.value.filterNot {
  117. case (_, file) => file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
  118. }
  119. }
  120.  
  121. // Create executable war file
  122. val ExecutableConfig = config("executable").hide
  123. Keys.ivyConfigurations += ExecutableConfig
  124. libraryDependencies ++= Seq(
  125. "org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
  126. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
  127. "org.eclipse.jetty" % "jetty-continuation" % JettyVersion % "executable",
  128. "org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
  129. "org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
  130. "org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
  131. "org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
  132. "org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
  133. "org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
  134. )
  135.  
  136. // Run package task before test to generate target/webapp for integration test
  137. Test / test := {
  138. _root_.sbt.Keys.`package`.value
  139. (Test / test).value
  140. }
  141.  
  142. val executableKey = TaskKey[File]("executable")
  143. executableKey := {
  144. import java.util.jar.Attributes.{Name => AttrName}
  145. import java.util.jar.{Manifest => JarManifest}
  146.  
  147. val workDir = Keys.target.value / "executable"
  148. val warName = Keys.name.value + ".war"
  149.  
  150. val log = streams.value.log
  151. log info s"building executable webapp in ${workDir}"
  152.  
  153. // initialize temp directory
  154. val temp = workDir / "webapp"
  155. IO delete temp
  156.  
  157. // include jetty classes
  158. val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
  159. jettyJars foreach { jar =>
  160. IO unzip (jar, temp, (name: String) =>
  161. (name startsWith "javax/") ||
  162. (name startsWith "org/"))
  163. }
  164.  
  165. // include original war file
  166. val warFile = (Keys.`package`).value
  167. IO unzip (warFile, temp)
  168.  
  169. // include launcher classes
  170. val classDir = (Compile / Keys.classDirectory).value
  171. val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */ )
  172. launchClasses foreach { name =>
  173. IO copyFile (classDir / name, temp / name)
  174. }
  175.  
  176. // include plugins
  177. val pluginsDir = temp / "WEB-INF" / "classes" / "plugins"
  178. IO createDirectory (pluginsDir)
  179.  
  180. val plugins = IO readLines (Keys.baseDirectory.value / "src" / "main" / "resources" / "bundle-plugins.txt")
  181. plugins.foreach { plugin =>
  182. plugin.trim.split(":") match {
  183. case Array(pluginId, pluginVersion) =>
  184. val url = "https://github.com/" +
  185. s"gitbucket/gitbucket-${pluginId}-plugin/releases/download/${pluginVersion}/gitbucket-${pluginId}-plugin-${pluginVersion}.jar"
  186. log info s"Download: ${url}"
  187. IO transfer (new java.net.URL(url).openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
  188. case _ => ()
  189. }
  190. }
  191.  
  192. // zip it up
  193. IO delete (temp / "META-INF" / "MANIFEST.MF")
  194. val contentMappings = (temp.allPaths --- PathFinder(temp)).get pair { file =>
  195. IO.relativizeFile(temp, file)
  196. }
  197. val manifest = new JarManifest
  198. manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
  199. manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
  200. val outputFile = workDir / warName
  201. IO jar (contentMappings.map { case (file, path) => (file, path.toString) }, outputFile, manifest, None)
  202.  
  203. // generate checksums
  204. Seq(
  205. "md5" -> "MD5",
  206. "sha1" -> "SHA-1",
  207. "sha256" -> "SHA-256"
  208. ).foreach {
  209. case (extension, algorithm) =>
  210. val checksumFile = workDir / (warName + "." + extension)
  211. Checksums generate (outputFile, checksumFile, algorithm)
  212. }
  213.  
  214. // done
  215. log info s"built executable webapp ${outputFile}"
  216. outputFile
  217. }
  218. publishTo := {
  219. val nexus = "https://oss.sonatype.org/"
  220. if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
  221. else Some("releases" at nexus + "service/local/staging/deploy/maven2")
  222. }
  223. publishMavenStyle := true
  224. pomIncludeRepository := { _ =>
  225. false
  226. }
  227. pomExtra := (
  228. <url>https://github.com/gitbucket/gitbucket</url>
  229. <licenses>
  230. <license>
  231. <name>The Apache Software License, Version 2.0</name>
  232. <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
  233. </license>
  234. </licenses>
  235. <scm>
  236. <url>https://github.com/gitbucket/gitbucket</url>
  237. <connection>scm:git:https://github.com/gitbucket/gitbucket.git</connection>
  238. </scm>
  239. <developers>
  240. <developer>
  241. <id>takezoe</id>
  242. <name>Naoki Takezoe</name>
  243. <url>https://github.com/takezoe</url>
  244. </developer>
  245. <developer>
  246. <id>shimamoto</id>
  247. <name>Takako Shimamoto</name>
  248. <url>https://github.com/shimamoto</url>
  249. </developer>
  250. <developer>
  251. <id>tanacasino</id>
  252. <name>Tomofumi Tanaka</name>
  253. <url>https://github.com/tanacasino</url>
  254. </developer>
  255. <developer>
  256. <id>mrkm4ntr</id>
  257. <name>Shintaro Murakami</name>
  258. <url>https://github.com/mrkm4ntr</url>
  259. </developer>
  260. <developer>
  261. <id>nazoking</id>
  262. <name>nazoking</name>
  263. <url>https://github.com/nazoking</url>
  264. </developer>
  265. <developer>
  266. <id>McFoggy</id>
  267. <name>Matthieu Brouillard</name>
  268. <url>https://github.com/McFoggy</url>
  269. </developer>
  270. </developers>
  271. )
  272.  
  273. Test / testOptions ++= {
  274. if (scala.util.Properties.isWin) {
  275. Seq(
  276. Tests.Exclude(
  277. Set(
  278. "gitbucket.core.GitBucketCoreModuleSpec"
  279. )
  280. )
  281. )
  282. } else {
  283. Nil
  284. }
  285. }
  286.  
  287. Jetty / javaOptions ++= Seq(
  288. "-Dlogback.configurationFile=/logback-dev.xml",
  289. "-Xdebug",
  290. "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000",
  291. "-Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF",
  292. //"-Ddev-features=keep-session"
  293. )