diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf63ce9..00e09ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: branches: - - master + - main tags: - '*' pull_request: @@ -12,21 +12,31 @@ jobs: strategy: fail-fast: false matrix: - java: [adopt@1.8] + java: [ '8' ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: olafurpg/setup-scala@v13 + - name: Set up JVM + uses: actions/setup-java@v3 with: + distribution: 'temurin' java-version: ${{ matrix.java }} + cache: 'sbt' + - run: git fetch --tags -f - run: # for git tests git config --global user.email "scalafmt@scalameta.org" && git config --global user.name "scalafmt" - run: sbt plugin/scripted + formatting: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: olafurpg/setup-scala@v13 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + cache: 'sbt' + - run: ./bin/scalafmt --test diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 17fdb96..896edaf 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -3,7 +3,7 @@ name: Release Drafter on: push: branches: - - master + - main jobs: update_release_draft: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f9f1c9..f44f776 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,18 +1,22 @@ name: Release on: push: - branches: [master] + branches: + - main tags: ["*"] jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: olafurpg/setup-scala@v13 - - uses: olafurpg/setup-gpg@v3 - - run: git fetch --tags --unshallow -f || true - - name: Publish ${{ github.ref }} - run: sbt ci-release + with: + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' + cache: 'sbt' + - run: sbt ci-release env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} diff --git a/.scala-steward.conf b/.scala-steward.conf deleted file mode 100644 index d3c9518..0000000 --- a/.scala-steward.conf +++ /dev/null @@ -1 +0,0 @@ -updates.ignore = [ { groupId = "org.scala-sbt" } ] diff --git a/.scalafmt.conf b/.scalafmt.conf index 0a2b01a..d846fa9 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.5.8 +version = 3.7.13 runner.dialect = scala213 project.git = true project.excludeFilters = [ diff --git a/build.sbt b/build.sbt index 40c1929..d47cee1 100644 --- a/build.sbt +++ b/build.sbt @@ -35,15 +35,15 @@ inThisBuild( url("https://github.com/tanishiking/") ) ), - resolvers += Resolver.sonatypeRepo("public"), - scalaVersion := "2.12.17", - publishArtifact in packageDoc := sys.env.contains("CI"), - publishArtifact in packageSrc := sys.env.contains("CI") + resolvers ++= Resolver.sonatypeOssRepos("public"), + scalaVersion := "2.12.18", + packageDoc / publishArtifact := sys.env.contains("CI"), + packageSrc / publishArtifact := sys.env.contains("CI") ) ) -skip in publish := true +publish / skip := true -val scalafmtVersion = "3.5.9" +val scalafmtVersion = "3.7.13" onLoadMessage := s"Welcome to sbt-scalafmt ${version.value} (scalafmt ${scalafmtVersion})" lazy val plugin = project @@ -56,7 +56,10 @@ lazy val plugin = project "org.scalameta" %% "scalafmt-dynamic" % scalafmtVersion ), scriptedBufferLog := false, - scriptedLaunchOpts += s"-Dplugin.version=${version.value}" + scriptedLaunchOpts += s"-Dplugin.version=${version.value}", + // For compat reasons we have this in here to ensure we are testing against 1.2.8 + // We honestly probably don't need to, so if this ever causes issues, rip it out. + pluginCrossBuild / sbtVersion := "1.2.8" ) // For some reason, it doesn't work if this is defined in globalSettings in PublishPlugin. diff --git a/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala b/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala index 3b8c66d..2e4f8fd 100644 --- a/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala +++ b/plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala @@ -15,6 +15,7 @@ import scala.util.Failure import scala.util.Success import scala.util.Try +import org.scalafmt.interfaces.RepositoryCredential import org.scalafmt.interfaces.Scalafmt import org.scalafmt.sysops.AbsoluteFile import org.scalafmt.sysops.FileOps @@ -141,6 +142,7 @@ object ScalafmtPlugin extends AutoPlugin { taskStreams: TaskStreams, cacheStoreFactory: CacheStoreFactory, resolvers: Seq[Resolver], + credentials: Seq[Credentials], currentProject: ResolvedProject, filterMode: String, errorHandling: ErrorHandling @@ -156,13 +158,25 @@ object ScalafmtPlugin extends AutoPlugin { val repositories = resolvers.collect { case r: MavenRepository => r.root } + val repoCredentials = credentials.flatMap { c => + Try(Credentials.toDirect(c)).toOption.map { dc => + new RepositoryCredential(dc.host, dc.userName, dc.passwd) + } + } + log.debug( - s"Adding repositories ${repositories.mkString("[", ",", "]")}" + repositories.mkString("Adding repositories [", ",", "]") ) + log.debug { + val info = repoCredentials.map(x => s"${x.username}@${x.host}") + info.mkString("Adding credentials [", ",", "]") + } + val scalafmtSession = globalInstance .withReporter(reporter) .withMavenRepositories(repositories: _*) + .withRepositoryCredentials(repoCredentials: _*) .createSession(config.toAbsolutePath) if (scalafmtSession == null) throw messageException( @@ -465,6 +479,7 @@ object ScalafmtPlugin extends AutoPlugin { streams.value, (scalafmt / streams).value.cacheStoreFactory, fullResolvers.value, + credentials.value, thisProject.value, scalafmtFilter.value, new ErrorHandling( @@ -511,6 +526,7 @@ object ScalafmtPlugin extends AutoPlugin { streams.value, (scalafmt / streams).value.cacheStoreFactory, fullResolvers.value, + credentials.value, thisProject.value, "", new ErrorHandling( diff --git a/project/build.properties b/project/build.properties index c0bab04..3040987 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.9.4 diff --git a/project/plugins.sbt b/project/plugins.sbt index 4eadbc8..f94bcc2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,3 @@ -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.6") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value addSbtPlugin("com.scalawilliam.esbeetee" % "sbt-vspp" % "0.4.13") diff --git a/readme.md b/readme.md index 8c82c76..f5e748e 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,4 @@ # sbt-scalafmt -[![Build Status](https://travis-ci.org/scalameta/sbt-scalafmt.svg?branch=master)](https://travis-ci.org/scalameta/sbt-scalafmt) [![Join the chat at https://gitter.im/scalameta/scalafmt](https://badges.gitter.im/scalameta/scalafmt.svg)](https://gitter.im/scalameta/scalafmt?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the discord chat](https://img.shields.io/discord/632642981228314653?label=discord)](https://discordapp.com/channels/632642981228314653/632665341864181780) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scalameta/sbt-scalafmt/badge.svg?kill_cache=1)](https://search.maven.org/artifact/org.scalameta/sbt-scalafmt/)