Newer
Older
gitbucket_jkp / build.sbt
@Scala Steward Scala Steward on 21 Jun 10 KB Update github-api to 1.322
  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.0.0"
  8. val JettyVersion = "10.0.21"
  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.4.2"
  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.apache.commons" % "commons-compress" % "1.26.2",
  37. "org.apache.commons" % "commons-email" % "1.6.0",
  38. "commons-net" % "commons-net" % "3.11.1",
  39. "org.apache.httpcomponents" % "httpclient" % "4.5.14",
  40. "org.apache.sshd" % "apache-sshd" % "2.13.0" exclude ("org.slf4j", "slf4j-jdk14") exclude (
  41. "org.apache.sshd",
  42. "sshd-mina"
  43. ) exclude ("org.apache.sshd", "sshd-netty"),
  44. "org.apache.tika" % "tika-core" % "2.9.2",
  45. "com.github.takezoe" %% "blocking-slick" % "0.0.14",
  46. "com.novell.ldap" % "jldap" % "2009-10-07",
  47. "com.h2database" % "h2" % "1.4.199",
  48. "org.mariadb.jdbc" % "mariadb-java-client" % "2.7.12",
  49. "org.postgresql" % "postgresql" % "42.7.3",
  50. "ch.qos.logback" % "logback-classic" % "1.5.6",
  51. "com.zaxxer" % "HikariCP" % "5.1.0" exclude ("org.slf4j", "slf4j-api"),
  52. "com.typesafe" % "config" % "1.4.3",
  53. "fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.1.0",
  54. "io.github.java-diff-utils" % "java-diff-utils" % "4.12",
  55. "org.cache2k" % "cache2k-all" % "1.6.0.Final",
  56. "net.coobird" % "thumbnailator" % "0.4.20",
  57. "com.github.zafarkhaja" % "java-semver" % "0.10.2",
  58. "com.nimbusds" % "oauth2-oidc-sdk" % "11.12",
  59. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "provided",
  60. "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  61. "junit" % "junit" % "4.13.2" % "test",
  62. "org.scalatra" %% "scalatra-scalatest-javax" % ScalatraVersion % "test",
  63. "org.mockito" % "mockito-core" % "5.12.0" % "test",
  64. "com.dimafeng" %% "testcontainers-scala" % "0.41.4" % "test",
  65. "org.testcontainers" % "mysql" % "1.19.8" % "test",
  66. "org.testcontainers" % "postgresql" % "1.19.8" % "test",
  67. "net.i2p.crypto" % "eddsa" % "0.3.0",
  68. "is.tagomor.woothee" % "woothee-java" % "1.11.0",
  69. "org.ec4j.core" % "ec4j-core" % "0.3.0",
  70. "org.kohsuke" % "github-api" % "1.322" % "test"
  71. )
  72.  
  73. // Compiler settings
  74. scalacOptions := Seq(
  75. "-deprecation",
  76. "-language:postfixOps",
  77. "-opt:l:method",
  78. "-feature",
  79. "-Wunused:imports",
  80. "-Wconf:cat=unused&src=twirl/.*:s,cat=unused&src=scala/gitbucket/core/model/[^/]+\\.scala:s"
  81. )
  82. scalacOptions ++= {
  83. scalaBinaryVersion.value match {
  84. case "2.13" =>
  85. Seq("-Xsource:3-cross")
  86. case _ =>
  87. Nil
  88. }
  89. }
  90. compile / javacOptions ++= Seq("-target", "11", "-source", "11")
  91. Jetty / javaOptions += "-Dlogback.configurationFile=/logback-dev.xml"
  92.  
  93. // Test settings
  94. //testOptions in Test += Tests.Argument("-l", "ExternalDBTest")
  95. Test / javaOptions += "-Dgitbucket.home=target/gitbucket_home_for_test"
  96. Test / testOptions += Tests.Setup(() => new java.io.File("target/gitbucket_home_for_test").mkdir())
  97. Test / fork := true
  98.  
  99. // Packaging options
  100. packageOptions += Package.MainClass("JettyLauncher")
  101.  
  102. // Assembly settings
  103. assembly / test := {}
  104. assembly / assemblyMergeStrategy := {
  105. case PathList("META-INF", xs @ _*) =>
  106. (xs map { _.toLowerCase }) match {
  107. case ("manifest.mf" :: Nil) => MergeStrategy.discard
  108. case _ => MergeStrategy.discard
  109. }
  110. case x => MergeStrategy.first
  111. }
  112.  
  113. // Exclude a war file from published artifacts
  114. signedArtifacts := {
  115. signedArtifacts.value.filterNot { case (_, file) =>
  116. file.getName.endsWith(".war") || file.getName.endsWith(".war.asc")
  117. }
  118. }
  119.  
  120. // Create executable war file
  121. val ExecutableConfig = config("executable").hide
  122. Keys.ivyConfigurations += ExecutableConfig
  123. libraryDependencies ++= Seq(
  124. "org.eclipse.jetty" % "jetty-security" % JettyVersion % "executable",
  125. "org.eclipse.jetty" % "jetty-webapp" % JettyVersion % "executable",
  126. "org.eclipse.jetty" % "jetty-server" % JettyVersion % "executable",
  127. "org.eclipse.jetty" % "jetty-xml" % JettyVersion % "executable",
  128. "org.eclipse.jetty" % "jetty-http" % JettyVersion % "executable",
  129. "org.eclipse.jetty" % "jetty-servlet" % JettyVersion % "executable",
  130. "org.eclipse.jetty" % "jetty-io" % JettyVersion % "executable",
  131. "org.eclipse.jetty" % "jetty-util" % JettyVersion % "executable"
  132. )
  133.  
  134. // Run package task before test to generate target/webapp for integration test
  135. Test / test := {
  136. _root_.sbt.Keys.`package`.value
  137. (Test / test).value
  138. }
  139.  
  140. val executableKey = TaskKey[File]("executable")
  141. executableKey := {
  142. import java.util.jar.Attributes.{Name => AttrName}
  143. import java.util.jar.{Manifest => JarManifest}
  144.  
  145. val workDir = Keys.target.value / "executable"
  146. val warName = Keys.name.value + ".war"
  147.  
  148. val log = streams.value.log
  149. log info s"building executable webapp in ${workDir}"
  150.  
  151. // initialize temp directory
  152. val temp = workDir / "webapp"
  153. IO delete temp
  154.  
  155. // include jetty classes
  156. val jettyJars = Keys.update.value select configurationFilter(name = ExecutableConfig.name)
  157. jettyJars foreach { jar =>
  158. IO unzip (
  159. jar,
  160. temp,
  161. (name: String) => (name startsWith "javax/") || (name startsWith "org/") || (name startsWith "META-INF/services/")
  162. )
  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.URI(url).toURL.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 { case (extension, algorithm) =>
  209. val checksumFile = workDir / (warName + "." + extension)
  210. Checksums generate (outputFile, checksumFile, algorithm)
  211. }
  212.  
  213. // done
  214. log info s"built executable webapp ${outputFile}"
  215. outputFile
  216. }
  217. publishTo := {
  218. val nexus = "https://oss.sonatype.org/"
  219. if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
  220. else Some("releases" at nexus + "service/local/staging/deploy/maven2")
  221. }
  222. publishMavenStyle := true
  223. pomIncludeRepository := { _ =>
  224. false
  225. }
  226. pomExtra := (
  227. <url>https://github.com/gitbucket/gitbucket</url>
  228. <licenses>
  229. <license>
  230. <name>The Apache Software License, Version 2.0</name>
  231. <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
  232. </license>
  233. </licenses>
  234. <scm>
  235. <url>https://github.com/gitbucket/gitbucket</url>
  236. <connection>scm:git:https://github.com/gitbucket/gitbucket.git</connection>
  237. </scm>
  238. <developers>
  239. <developer>
  240. <id>takezoe</id>
  241. <name>Naoki Takezoe</name>
  242. <url>https://github.com/takezoe</url>
  243. </developer>
  244. <developer>
  245. <id>shimamoto</id>
  246. <name>Takako Shimamoto</name>
  247. <url>https://github.com/shimamoto</url>
  248. </developer>
  249. <developer>
  250. <id>tanacasino</id>
  251. <name>Tomofumi Tanaka</name>
  252. <url>https://github.com/tanacasino</url>
  253. </developer>
  254. <developer>
  255. <id>mrkm4ntr</id>
  256. <name>Shintaro Murakami</name>
  257. <url>https://github.com/mrkm4ntr</url>
  258. </developer>
  259. <developer>
  260. <id>nazoking</id>
  261. <name>nazoking</name>
  262. <url>https://github.com/nazoking</url>
  263. </developer>
  264. <developer>
  265. <id>McFoggy</id>
  266. <name>Matthieu Brouillard</name>
  267. <url>https://github.com/McFoggy</url>
  268. </developer>
  269. </developers>
  270. )
  271.  
  272. Test / testOptions ++= {
  273. if (scala.util.Properties.isWin) {
  274. Seq(
  275. Tests.Exclude(
  276. Set(
  277. "gitbucket.core.GitBucketCoreModuleSpec"
  278. )
  279. )
  280. )
  281. } else {
  282. Nil
  283. }
  284. }
  285.  
  286. Jetty / javaOptions ++= Seq(
  287. "-Dlogback.configurationFile=/logback-dev.xml",
  288. "-Xdebug",
  289. "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000",
  290. "-Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF",
  291. // "-Ddev-features=keep-session"
  292. )