Newer
Older
gitbucket_jkp / build.sbt
@Scala Steward Scala Steward on 18 Aug 10 KB Update oauth2-oidc-sdk to 11.17
  1. import sbtlicensereport.license.{DepModuleInfo, LicenseInfo}
  2. import com.jsuereth.sbtpgp.PgpKeys._
  3.  
  4. val Organization = "io.github.gitbucket"
  5. val Name = "gitbucket"
  6. val GitBucketVersion = "4.41.0"
  7. val ScalatraVersion = "3.1.0"
  8. val JettyVersion = "10.0.22"
  9. val JgitVersion = "6.10.0.202406032230-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.14"
  19.  
  20. crossScalaVersions += "3.5.0"
  21.  
  22. // scalafmtOnCompile := true
  23.  
  24. coverageExcludedPackages := ".*\\.html\\..*"
  25.  
  26. libraryDependencies ++= Seq(
  27. "org.eclipse.jgit" % "org.eclipse.jgit.http.server" % JgitVersion,
  28. "org.eclipse.jgit" % "org.eclipse.jgit.archive" % JgitVersion,
  29. "org.scalatra" %% "scalatra-javax" % ScalatraVersion,
  30. "org.scalatra" %% "scalatra-json-javax" % ScalatraVersion,
  31. "org.scalatra" %% "scalatra-forms-javax" % ScalatraVersion,
  32. "org.json4s" %% "json4s-jackson" % "4.1.0-M6",
  33. "commons-io" % "commons-io" % "2.16.1",
  34. "io.github.gitbucket" % "solidbase" % "1.1.0",
  35. "io.github.gitbucket" % "markedj" % "1.0.20",
  36. "org.tukaani" % "xz" % "1.10",
  37. "org.apache.commons" % "commons-compress" % "1.27.0",
  38. "org.apache.commons" % "commons-email" % "1.6.0",
  39. "commons-net" % "commons-net" % "3.11.1",
  40. "org.apache.httpcomponents" % "httpclient" % "4.5.14",
  41. "org.apache.sshd" % "apache-sshd" % "2.13.2" exclude ("org.slf4j", "slf4j-jdk14") exclude (
  42. "org.apache.sshd",
  43. "sshd-mina"
  44. ) exclude ("org.apache.sshd", "sshd-netty"),
  45. "org.apache.tika" % "tika-core" % "2.9.2",
  46. "com.github.takezoe" %% "blocking-slick" % "0.0.14",
  47. "com.novell.ldap" % "jldap" % "2009-10-07",
  48. "com.h2database" % "h2" % "1.4.199",
  49. "org.mariadb.jdbc" % "mariadb-java-client" % "2.7.12",
  50. "org.postgresql" % "postgresql" % "42.7.3",
  51. "ch.qos.logback" % "logback-classic" % "1.5.7",
  52. "com.zaxxer" % "HikariCP" % "5.1.0" exclude ("org.slf4j", "slf4j-api"),
  53. "com.typesafe" % "config" % "1.4.3",
  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.20",
  58. "com.github.zafarkhaja" % "java-semver" % "0.10.2",
  59. "com.nimbusds" % "oauth2-oidc-sdk" % "11.17",
  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-javax" % ScalatraVersion % "test",
  64. "org.mockito" % "mockito-core" % "5.12.0" % "test",
  65. "com.dimafeng" %% "testcontainers-scala" % "0.41.4" % "test",
  66. "org.testcontainers" % "mysql" % "1.20.1" % "test",
  67. "org.testcontainers" % "postgresql" % "1.20.1" % "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.323" % "test"
  72. )
  73.  
  74. // Compiler settings
  75. scalacOptions := Seq(
  76. "-deprecation",
  77. "-language:postfixOps",
  78. "-opt:l:method",
  79. "-feature",
  80. "-Wunused:imports",
  81. "-Wconf:cat=unused&src=twirl/.*:s,cat=unused&src=scala/gitbucket/core/model/[^/]+\\.scala:s"
  82. )
  83. scalacOptions ++= {
  84. scalaBinaryVersion.value match {
  85. case "2.13" =>
  86. Seq("-Xsource:3-cross")
  87. case _ =>
  88. Nil
  89. }
  90. }
  91. compile / javacOptions ++= Seq("-target", "11", "-source", "11")
  92. Jetty / javaOptions += "-Dlogback.configurationFile=/logback-dev.xml"
  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 { case (_, file) =>
  117. 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-server" % JettyVersion % "executable",
  128. "org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
  129. "org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
  130. "org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
  131. "org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
  132. "org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
  133. )
  134.  
  135. // Run package task before test to generate target/webapp for integration test
  136. Test / test := {
  137. _root_.sbt.Keys.`package`.value
  138. (Test / test).value
  139. }
  140.  
  141. val executableKey = TaskKey[File]("executable")
  142. executableKey := {
  143. import java.util.jar.Attributes.{Name => AttrName}
  144. import java.util.jar.{Manifest => JarManifest}
  145.  
  146. val workDir = Keys.target.value / "executable"
  147. val warName = Keys.name.value + ".war"
  148.  
  149. val log = streams.value.log
  150. log info s"building executable webapp in ${workDir}"
  151.  
  152. // initialize temp directory
  153. val temp = workDir / "webapp"
  154. IO delete temp
  155.  
  156. // include jetty classes
  157. val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
  158. jettyJars foreach { jar =>
  159. IO unzip (
  160. jar,
  161. temp,
  162. (name: String) => (name startsWith "javax/") || (name startsWith "org/") || (name startsWith "META-INF/services/")
  163. )
  164. }
  165.  
  166. // include original war file
  167. val warFile = (Keys.`package`).value
  168. IO unzip (warFile, temp)
  169.  
  170. // include launcher classes
  171. val classDir = (Compile / Keys.classDirectory).value
  172. val launchClasses = Seq("JettyLauncher.class" /*, "HttpsSupportConnector.class" */ )
  173. launchClasses foreach { name =>
  174. IO copyFile (classDir / name, temp / name)
  175. }
  176.  
  177. // include plugins
  178. val pluginsDir = temp / "WEB-INF" / "classes" / "plugins"
  179. IO createDirectory (pluginsDir)
  180.  
  181. val plugins = IO readLines (Keys.baseDirectory.value / "src" / "main" / "resources" / "bundle-plugins.txt")
  182. plugins.foreach { plugin =>
  183. plugin.trim.split(":") match {
  184. case Array(pluginId, pluginVersion) =>
  185. val url = "https://github.com/" +
  186. s"gitbucket/gitbucket-${pluginId}-plugin/releases/download/${pluginVersion}/gitbucket-${pluginId}-plugin-${pluginVersion}.jar"
  187. log info s"Download: ${url}"
  188. IO transfer (new java.net.URI(url).toURL.openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
  189. case _ => ()
  190. }
  191. }
  192.  
  193. // zip it up
  194. IO delete (temp / "META-INF" / "MANIFEST.MF")
  195. val contentMappings = (temp.allPaths --- PathFinder(temp)).get pair { file =>
  196. IO.relativizeFile(temp, file)
  197. }
  198. val manifest = new JarManifest
  199. manifest.getMainAttributes put (AttrName.MANIFEST_VERSION, "1.0")
  200. manifest.getMainAttributes put (AttrName.MAIN_CLASS, "JettyLauncher")
  201. val outputFile = workDir / warName
  202. IO jar (contentMappings.map { case (file, path) => (file, path.toString) }, outputFile, manifest, None)
  203.  
  204. // generate checksums
  205. Seq(
  206. "md5" -> "MD5",
  207. "sha1" -> "SHA-1",
  208. "sha256" -> "SHA-256"
  209. ).foreach { 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. )