Skip to content

Commit

Permalink
make it possible to and do build against a scalafix SNAPSHOT
Browse files Browse the repository at this point in the history
- clients that do not override scalafixResolvers will continue working
  as sonatype snapshots is added by default
- remove unnecessary scalafixResolvers overrides in scripted
- failing tests were fixed by sticking to the plugin default
  • Loading branch information
github-brice-jaglin committed May 12, 2021
1 parent fdba46f commit 8cdca64
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import sbt._

object Dependencies {
val x = List(1) // scalafix:ok
// when bumping remove dep on SNAPSHOT in sbt-1.5 scripted tests
def scalafixVersion: String = "0.9.27"
def scalafixVersion: String = "0.9.27+52-6c9eeec9-SNAPSHOT"

val all = List(
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.11.0.202103091610-r",
"ch.epfl.scala" % "scalafix-interfaces" % scalafixVersion,
Expand Down
3 changes: 2 additions & 1 deletion src/sbt-test/sbt-1.3/testkit/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ inThisBuild(
List(
scalaVersion := Versions.scala212,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
semanticdbVersion := scalafixSemanticdb.revision,
resolvers += Resolver.sonatypeRepo("snapshots")
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package fix

import scalafix.testkit._
import scala.util.control.NonFatal
import org.scalatest.FunSuiteLike
import org.scalatest.exceptions.TestFailedException

object IntputOutputSuite {
def main(args: Array[String]): Unit = {
if (Array("--save-expect").sameElements(args)) {
val suite = new SemanticRuleSuite(
TestkitProperties.loadFromResources(),
isSaveExpect = true
) {
val suite = new AbstractSemanticRuleSuite with FunSuiteLike {
override val props = TestkitProperties.loadFromResources()
override val isSaveExpect = true

testsToRun.foreach { t =>
try evaluateTestBody(t)
catch {
Expand All @@ -29,6 +30,6 @@ object IntputOutputSuite {
}
}

class IntputOutputSuite extends SemanticRuleSuite {
class IntputOutputSuite extends AbstractSemanticRuleSuite with FunSuiteLike {
runAllTests()
}
4 changes: 0 additions & 4 deletions src/sbt-test/sbt-1.5/scala-3/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
resolvers += Resolver.sonatypeRepo("public")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))

//FIXME: remove when scalafixVersion is bumped to 0.9.28
resolvers += Resolver.sonatypeRepo("snapshots")
dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "0.9.27+52-6c9eeec9-SNAPSHOT"
4 changes: 0 additions & 4 deletions src/sbt-test/sbt-1.5/scalafixEnable/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
resolvers += Resolver.sonatypeRepo("public")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))

//FIXME: remove when scalafixVersion is bumped to 0.9.28
resolvers += Resolver.sonatypeRepo("snapshots")
dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "0.9.27+52-6c9eeec9-SNAPSHOT"
3 changes: 1 addition & 2 deletions src/sbt-test/sbt-scalafix/basic/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ inThisBuild(
scalafixDependencies := List(
// Custom rule published to Maven Central https://github.com/scalacenter/example-scalafix-rule
"ch.epfl.scala" %% "example-scalafix-rule" % "1.4.0"
),
scalafixResolvers := List(Repository.MavenCentral)
)
)
)

Expand Down
1 change: 1 addition & 0 deletions src/sbt-test/sbt-scalafix/concurrency/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ val V = _root_.scalafix.sbt.BuildInfo

scalaVersion := V.scala212
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % V.scalafixVersion % ScalafixConfig
resolvers += Resolver.sonatypeRepo("snapshots")

// make it possible to run scalafix in parallel with other tasks via the `all` command
// (work around "Cannot mix input tasks with plain tasks/settings")
Expand Down
5 changes: 0 additions & 5 deletions src/sbt-test/sbt-scalafix/local-rules/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ inThisBuild(
// Custom rule cross-published to Maven Central https://github.com/scalacenter/example-scalafix-rule
"ch.epfl.scala" %% "example-scalafix-rule" % "1.4.0"
),
// `Repository.central()` can only be used sbt 1.x / scala 2.12
// error: Static methods in interface require -target:jvm-1.8
scalafixResolvers := List(
coursierapi.MavenRepository.of("https://repo1.maven.org/maven2")
),
scalaVersion := "2.13.0", // out of sync with scalafix.sbt.BuildInfo.scala213 on purpose
scalafixScalaBinaryVersion :=
// this should be the default in sbt-scalafix 1.0
Expand Down
3 changes: 2 additions & 1 deletion src/sbt-test/sbt-scalafix/testkit/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ inThisBuild(
List(
scalaVersion := Versions.scala212,
addCompilerPlugin(scalafixSemanticdb),
scalacOptions += "-Yrangepos"
scalacOptions += "-Yrangepos",
resolvers += Resolver.sonatypeRepo("snapshots")
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package fix

import scalafix.testkit._
import scala.util.control.NonFatal
import org.scalatest.FunSuiteLike
import org.scalatest.exceptions.TestFailedException

object IntputOutputSuite {
def main(args: Array[String]): Unit = {
if (Array("--save-expect").sameElements(args)) {
val suite = new SemanticRuleSuite(
TestkitProperties.loadFromResources(),
isSaveExpect = true
) {
val suite = new AbstractSemanticRuleSuite with FunSuiteLike {
override val props = TestkitProperties.loadFromResources()
override val isSaveExpect = true

testsToRun.foreach { t =>
try evaluateTestBody(t)
catch {
Expand All @@ -29,6 +30,6 @@ object IntputOutputSuite {
}
}

class IntputOutputSuite extends SemanticRuleSuite {
class IntputOutputSuite extends AbstractSemanticRuleSuite with FunSuiteLike {
runAllTests()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scalafix.internal.sbt

import coursierapi.Repository
import coursierapi.{MavenRepository, Repository}
import org.eclipse.jgit.lib.AbbreviatedObjectId
import org.scalatest.Tag
import sbt.complete.Parser
Expand Down Expand Up @@ -32,7 +32,12 @@ class SbtCompletionsSuite extends AnyFunSuite {
.fromToolClasspath(
"2.12",
Seq(exampleDependency),
Seq(Repository.central)
Seq(
Repository.central,
MavenRepository.of(
"https://oss.sonatype.org/content/repositories/snapshots"
)
)
)()
val loadedRules = mainArgs.availableRules.toList

Expand Down
9 changes: 7 additions & 2 deletions src/test/scala/scalafix/internal/sbt/ScalafixAPISuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scalafix.internal.sbt
import java.io.{ByteArrayOutputStream, PrintStream}
import java.nio.file.Files

import coursierapi.Repository
import coursierapi.{MavenRepository, Repository}
import org.scalactic.source.Position
import sbt._
import sbt.internal.sbtscalafix.Compat
Expand Down Expand Up @@ -31,7 +31,12 @@ class ScalafixAPISuite extends AnyFunSuite {
.fromToolClasspath(
"2.12",
List("ch.epfl.scala" %% "example-scalafix-rule" % "1.4.0"),
Seq(Repository.central),
Seq(
Repository.central,
MavenRepository.of(
"https://oss.sonatype.org/content/repositories/snapshots"
)
),
logger
)()
.withArgs(Arg.PrintStream(new PrintStream(baos)))
Expand Down

0 comments on commit 8cdca64

Please sign in to comment.