Skip to content

Commit ee2d078

Browse files
authored
Bump to Scala 2.13.0 (#83)
1 parent fcb1c4b commit ee2d078

File tree

15 files changed

+49
-39
lines changed

15 files changed

+49
-39
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ In addition, this plug-in is made to just experiment continuous integration on G
5656

5757
Plugin version | GitBucket version
5858
:--------------|:--------------------
59+
1.9.x | 4.32.x -
5960
1.8.x | 4.31.x -
6061
1.7.x | 4.30.x -
6162
1.6.x - | 4.24.0 -
@@ -66,14 +67,17 @@ Plugin version | GitBucket version
6667

6768
## Installation
6869

69-
Download jar file from [plugin registry](https://plugins.gitbucket-community.org/releases/gitbucket-ci-plugin) and put into `GITBUCKET_HOME/plugins`.
70+
Download jar file from [the release page](https://github.com/takezoe/gitbucket-ci-plugin/releases) and put into `GITBUCKET_HOME/plugins`.
7071

7172
## Build
7273

73-
Run `sbt assembly` and copy generated `/target/scala-2.12/gitbucket-ci-plugin-assembply-x.x.x.jar` to `~/.gitbucket/plugins/` (If the directory does not exist, create it by hand before copying the jar), or just run `sbt install`.
74+
Run `sbt assembly` and copy generated `/target/scala-2.13/gitbucket-ci-plugin-x.x.x.jar` to `~/.gitbucket/plugins/` (If the directory does not exist, create it by hand before copying the jar), or just run `sbt install`.
7475

7576
## Release Notes
7677

78+
### 1.9.0
79+
- Update for GitBUcket 4.32.0 and Scala 2.13.0
80+
7781
### 1.8.1
7882
- Bug fix
7983

build.sbt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
name := "gitbucket-ci-plugin"
22
organization := "io.github.gitbucket"
3-
version := "1.8.1"
4-
scalaVersion := "2.12.8"
5-
gitbucketVersion := "4.31.0"
3+
version := "1.9.0"
4+
scalaVersion := "2.13.0"
5+
gitbucketVersion := "4.32.0"
6+
scalacOptions += "-deprecation"
67
libraryDependencies ++= Seq(
7-
"org.fusesource.jansi" % "jansi" % "1.16",
8-
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
9-
"com.dimafeng" %% "testcontainers-scala" % "0.27.0" % "test",
10-
"org.testcontainers" % "mysql" % "1.11.3" % "test",
11-
"org.testcontainers" % "postgresql" % "1.11.3" % "test"
8+
"org.fusesource.jansi" % "jansi" % "1.18",
9+
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
10+
"com.dimafeng" %% "testcontainers-scala" % "0.29.0" % "test",
11+
"org.testcontainers" % "mysql" % "1.12.0" % "test",
12+
"org.testcontainers" % "postgresql" % "1.12.0" % "test"
1213
)
1314

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.2.6
1+
sbt.version = 1.2.8

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.3.0")
1+
addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.5.0")

src/main/scala/Plugin.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class Plugin extends gitbucket.core.plugin.Plugin with CIService with AccountSer
6464
new Version("1.7.0"),
6565
new Version("1.8.0",
6666
new LiquibaseMigration("update/gitbucket-ci_1.8.0.xml")),
67-
new Version("1.8.1")
67+
new Version("1.8.1"),
68+
new Version("1.9.0")
6869
)
6970

7071
override val assetsMappings = Seq("/ci" -> "/gitbucket/ci/assets")

src/main/scala/io/github/gitbucket/ci/controller/CIApiController.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import gitbucket.core.util.Implicits._
44
import gitbucket.core.controller.ControllerBase
55
import gitbucket.core.service.{AccountService, RepositoryService}
66
import gitbucket.core.util.Directory.getRepositoryDir
7-
import gitbucket.core.util.SyntaxSugars._
87
import gitbucket.core.util._
98
import io.github.gitbucket.ci.api.{CIApiBuild, CIApiPreviousBuild, CIApiSingleBuild, JsonFormat}
109
import io.github.gitbucket.ci.service.CIService
1110
import org.eclipse.jgit.api.Git
1211
import org.scalatra.{BadRequest, Ok}
12+
import scala.util.Using
1313

1414
class CIApiController extends ControllerBase
1515
with UsersAuthenticator
@@ -84,7 +84,7 @@ class CIApiController extends ControllerBase
8484

8585
post("/api/circleci/v1.1/project/gitbucket/:owner/:repository")(writableUsersOnly { repository =>
8686
loadCIConfig(repository.owner, repository.name).map { config =>
87-
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
87+
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
8888
JGitUtil.getDefaultBranch(git, repository).map { case (objectId, revision) =>
8989
val revCommit = JGitUtil.getRevCommitFromId(git, objectId)
9090
runBuild(
@@ -110,7 +110,7 @@ class CIApiController extends ControllerBase
110110
post("/api/circleci/v1.1/project/gitbucket/:owner/:repository/tree/:branch")(writableUsersOnly { repository =>
111111
val branch = params("branch")
112112
loadCIConfig(repository.owner, repository.name).map { config =>
113-
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
113+
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
114114
val objectId = git.getRepository.resolve(branch)
115115
val revCommit = JGitUtil.getRevCommitFromId(git, objectId)
116116
runBuild(

src/main/scala/io/github/gitbucket/ci/controller/CIController.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import gitbucket.core.controller.ControllerBase
66
import gitbucket.core.service.RepositoryService.RepositoryInfo
77
import gitbucket.core.service.{AccountService, RepositoryService}
88
import gitbucket.core.util.Directory.getRepositoryDir
9-
import gitbucket.core.util.SyntaxSugars.using
109
import gitbucket.core.util._
1110
import gitbucket.core.util.Implicits._
1211
import gitbucket.core.view.helpers.datetimeAgo
@@ -20,6 +19,8 @@ import org.eclipse.jgit.api.Git
2019
import org.json4s.jackson.Serialization
2120
import org.scalatra.{BadRequest, Ok}
2221

22+
import scala.util.Using
23+
2324
object CIController {
2425

2526
case class ApiJobOutput(
@@ -135,7 +136,7 @@ class CIController extends ControllerBase
135136
committer = result.commitUserName,
136137
author = result.buildAuthor,
137138
startTime = datetimeAgo(result.startTime),
138-
duration = ((result.endTime.getTime - result.startTime.getTime) / 1000) + " sec"
139+
duration = s"${((result.endTime.getTime - result.startTime.getTime) / 1000)} sec"
139140
)
140141
}
141142
}.map { status =>
@@ -164,7 +165,7 @@ class CIController extends ControllerBase
164165

165166
ajaxPost("/:owner/:repository/build/run")(writableUsersOnly { repository =>
166167
loadCIConfig(repository.owner, repository.name).map { config =>
167-
using(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
168+
Using.resource(Git.open(getRepositoryDir(repository.owner, repository.name))) { git =>
168169
JGitUtil.getDefaultBranch(git, repository).map { case (objectId, revision) =>
169170
val revCommit = JGitUtil.getRevCommitFromId(git, objectId)
170171
runBuild(
@@ -237,7 +238,7 @@ class CIController extends ControllerBase
237238
if(file.isFile){
238239
contentType = FileUtil.getMimeType(path)
239240
response.setContentLength(file.length.toInt)
240-
using(new FileInputStream(file)){ in =>
241+
Using.resource(new FileInputStream(file)){ in =>
241242
IOUtils.copy(in, response.getOutputStream)
242243
}
243244
} else {
@@ -309,7 +310,7 @@ class CIController extends ControllerBase
309310
committer = result.commitUserName,
310311
author = result.buildUserName,
311312
startTime = datetimeAgo(result.startTime),
312-
duration = ((result.endTime.getTime - result.startTime.getTime) / 1000) + " sec"
313+
duration = s"${((result.endTime.getTime - result.startTime.getTime) / 1000)} sec"
313314
)
314315
}
315316

@@ -344,7 +345,7 @@ class CIController extends ControllerBase
344345
} else {
345346
saveCIConfig(repository.owner, repository.name, None)
346347
}
347-
flash += "info" -> "Build configuration has been updated."
348+
flash.update("info", "Build configuration has been updated.")
348349
redirect(s"/${repository.owner}/${repository.name}/settings/build")
349350
})
350351

src/main/scala/io/github/gitbucket/ci/hook/CICommitHook.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import gitbucket.core.model.Profile._
55
import gitbucket.core.service._
66
import gitbucket.core.util.Directory.getRepositoryDir
77
import gitbucket.core.util.JGitUtil
8-
import gitbucket.core.util.SyntaxSugars.using
98
import io.github.gitbucket.ci.model.CIConfig
109
import io.github.gitbucket.ci.service.CIService
1110
import org.eclipse.jgit.api.Git
1211
import org.eclipse.jgit.transport.{ReceiveCommand, ReceivePack}
1312
import profile.blockingApi._
13+
import scala.util.Using
1414

1515
class CICommitHook extends ReceiveHook
1616
with CIService with RepositoryService with AccountService with CommitStatusService with SystemSettingsService {
@@ -20,7 +20,7 @@ class CICommitHook extends ReceiveHook
2020
val branch = command.getRefName.stripPrefix("refs/heads/")
2121
if(branch != command.getRefName && command.getType != ReceiveCommand.Type.DELETE){
2222
getRepository(owner, repository).foreach { repositoryInfo =>
23-
using(Git.open(getRepositoryDir(owner, repository))) { git =>
23+
Using.resource(Git.open(getRepositoryDir(owner, repository))) { git =>
2424
val sha = command.getNewId.name
2525
val revCommit = JGitUtil.getRevCommitFromId(git, command.getNewId)
2626

src/main/scala/io/github/gitbucket/ci/hook/CIPullRequestHook.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import gitbucket.core.model.Profile._
88
import gitbucket.core.service._
99
import gitbucket.core.util.Directory.getRepositoryDir
1010
import gitbucket.core.util.JGitUtil
11-
import gitbucket.core.util.SyntaxSugars.using
1211
import io.github.gitbucket.ci.service.CIService
1312
import org.eclipse.jgit.api.Git
1413
import profile.api._
14+
import scala.util.Using
1515

1616
class CIPullRequestHook extends PullRequestHook
1717
with PullRequestService with IssuesService with CommitsService with AccountService with WebHookService
@@ -25,7 +25,7 @@ class CIPullRequestHook extends PullRequestHook
2525
buildAuthor <- context.loginAccount
2626
buildConfig <- loadCIConfig(pullreq.userName, pullreq.repositoryName)
2727
} yield {
28-
val revCommit = using(Git.open(getRepositoryDir(pullreq.requestUserName, pullreq.requestRepositoryName))) { git =>
28+
val revCommit = Using.resource(Git.open(getRepositoryDir(pullreq.requestUserName, pullreq.requestRepositoryName))) { git =>
2929
val objectId = git.getRepository.resolve(pullreq.commitIdTo)
3030
JGitUtil.getRevCommitFromId(git, objectId)
3131
}
@@ -56,7 +56,7 @@ class CIPullRequestHook extends PullRequestHook
5656
buildConfig <- loadCIConfig(pullreq.userName, pullreq.repositoryName)
5757
} yield {
5858
if(!buildConfig.runWordsSeq.find(content.contains).isEmpty){
59-
val revCommit = using(Git.open(getRepositoryDir(pullreq.requestUserName, pullreq.requestRepositoryName))) { git =>
59+
val revCommit = Using.resource(Git.open(getRepositoryDir(pullreq.requestUserName, pullreq.requestRepositoryName))) { git =>
6060
val objectId = git.getRepository.resolve(pullreq.commitIdTo)
6161
JGitUtil.getRevCommitFromId(git, objectId)
6262
}

src/main/scala/io/github/gitbucket/ci/manager/BuildJobThread.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import gitbucket.core.service.{AccountService, CommitStatusService, RepositorySe
1111
import gitbucket.core.servlet.Database
1212
import gitbucket.core.util.Directory.getRepositoryDir
1313
import gitbucket.core.util.Mailer
14-
import gitbucket.core.util.SyntaxSugars.using
1514
import io.github.gitbucket.ci.model.CIResult
1615
import io.github.gitbucket.ci.service._
1716
import io.github.gitbucket.ci.util.{CIUtils, JobStatus}
@@ -23,6 +22,7 @@ import org.slf4j.LoggerFactory
2322

2423
import scala.sys.process.{Process, ProcessLogger}
2524
import scala.util.control.ControlThrowable
25+
import scala.util.Using
2626

2727

2828
class BuildJobThread(queue: LinkedBlockingQueue[BuildJob], threads: LinkedBlockingQueue[BuildJobThread]) extends Thread
@@ -97,7 +97,7 @@ class BuildJobThread(queue: LinkedBlockingQueue[BuildJob], threads: LinkedBlocki
9797
sb.append(s"git clone ${job.buildUserName}/${job.buildRepositoryName}\n")
9898

9999
// git clone
100-
using(Git.cloneRepository()
100+
Using.resource(Git.cloneRepository()
101101
.setURI(getRepositoryDir(job.buildUserName, job.buildRepositoryName).toURI.toString)
102102
.setDirectory(dir).call()) { git =>
103103

src/main/scala/io/github/gitbucket/ci/model/CIConfig.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.github.gitbucket.ci.model
22

3+
import scala.language.postfixOps
4+
35
trait CIConfigComponent { self: gitbucket.core.model.Profile =>
46
import profile.api._
57
import self._

src/main/scala/io/github/gitbucket/ci/model/CIResult.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.gitbucket.ci.model
22

33
import io.github.gitbucket.ci.util.JobStatus
4+
import scala.language.postfixOps
45

56
trait CIResultComponent { self: gitbucket.core.model.Profile =>
67
import profile.api._

src/main/scala/io/github/gitbucket/ci/service/CIService.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import gitbucket.core.model.Profile.profile.blockingApi._
88
import gitbucket.core.service.{AccountService, RepositoryService}
99
import io.github.gitbucket.ci.util.CIUtils
1010
import org.apache.commons.io.FileUtils
11-
import scala.collection.JavaConverters._
11+
import scala.jdk.CollectionConverters._
1212

1313
case class BuildJob(
1414
userName: String,
@@ -145,7 +145,6 @@ trait CIService { self: AccountService with RepositoryService =>
145145
}
146146

147147
def getQueuedJobs(userName: String, repositoryName: String): Seq[BuildJob] = {
148-
import scala.collection.JavaConverters._
149148
BuildManager.queue.iterator.asScala.filter { job =>
150149
job.userName == userName && job.repositoryName == repositoryName
151150
}.toSeq

src/main/scala/io/github/gitbucket/ci/util/CIUtils.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package io.github.gitbucket.ci.util
33
import java.io.{ByteArrayOutputStream, File}
44

55
import gitbucket.core.util.Directory
6-
import gitbucket.core.util.SyntaxSugars.using
76
import org.fusesource.jansi.HtmlAnsiOutputStream
87

8+
import scala.util.Using
9+
910
object CIUtils {
1011

1112
val ContextName = "gitbucket-ci"
@@ -16,8 +17,8 @@ object CIUtils {
1617
}
1718

1819
def colorize(text: String) = {
19-
using(new ByteArrayOutputStream()){ os =>
20-
using(new HtmlAnsiOutputStream(os)){ hos =>
20+
Using.resource(new ByteArrayOutputStream()){ os =>
21+
Using.resource(new HtmlAnsiOutputStream(os)){ hos =>
2122
hos.write(text.getBytes("UTF-8"))
2223
}
2324
new String(os.toByteArray, "UTF-8")

src/test/scala/io/github/gitbucket/ci/MigrationSpec.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import io.github.gitbucket.solidbase.model.Module
88
import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
99
import org.junit.runner.Description
1010
import org.scalatest.{FunSuite, Tag}
11-
import scala.collection.JavaConverters._
11+
import scala.jdk.CollectionConverters._
1212

1313
object ExternalDBTest extends Tag("ExternalDBTest")
1414

@@ -36,7 +36,7 @@ class MigrationSpec extends FunSuite {
3636
// TODO https://github.com/testcontainers/testcontainers-java/issues/736
3737
container.withCommand("mysqld --default-authentication-plugin=mysql_native_password")
3838
}
39-
container.starting()
39+
container.start()
4040
try {
4141
new Solidbase().migrate(
4242
DriverManager.getConnection(s"${container.jdbcUrl}?useSSL=false", container.username, container.password),
@@ -45,7 +45,7 @@ class MigrationSpec extends FunSuite {
4545
new Module(plugin.pluginId, plugin.versions.asJava)
4646
)
4747
} finally {
48-
container.finished()
48+
container.stop()
4949
}
5050
}
5151
}
@@ -54,7 +54,7 @@ class MigrationSpec extends FunSuite {
5454
test(s"Migration PostgreSQL $tag", ExternalDBTest) {
5555
val container = PostgreSQLContainer(s"postgres:$tag")
5656

57-
container.starting()
57+
container.start()
5858
try {
5959
new Solidbase().migrate(
6060
DriverManager.getConnection(container.jdbcUrl, container.username, container.password),
@@ -63,7 +63,7 @@ class MigrationSpec extends FunSuite {
6363
new Module(plugin.pluginId, plugin.versions.asJava)
6464
)
6565
} finally {
66-
container.finished()
66+
container.stop()
6767
}
6868
}
6969
}

0 commit comments

Comments
 (0)