Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: scalacenter/bloop
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.7
Choose a base ref
...
head repository: scalacenter/bloop
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5.8
Choose a head ref
  • 14 commits
  • 10 files changed
  • 4 contributors

Commits on Jun 26, 2023

  1. chore: Make source generator tests more reselient

    Previously, if python was not available on PATH we would fail the tests. Now, we check both python and python 3 executables first, if none of them exists then we ignore the tests. This will pop up on CI if source generators are broken.
    tgodzik authored and ckipp01 committed Jun 26, 2023
    Copy the full SHA
    3c132f6 View commit details

Commits on Jul 3, 2023

  1. improvement: Try and find latest supported semanticdb version

    Previously, we wouldn't produce semanticdb files for older version of Scala since we wouldn't find the correct artifact if we stopped publishing for a particular version.
    
    Now, we try and find the latest version that still supported that Scala version.
    
    This is similar to the change we did in Metals in regards to the presentation compiler interface, where we would fetch old mtags for unsupported scala version and this way always support a particular version.
    tgodzik committed Jul 3, 2023
    Copy the full SHA
    c8d68ab View commit details
  2. Merge pull request #2097 from tgodzik/fallback-semanticdb

    improvement: Try and find latest supported semanticdb version
    tgodzik authored Jul 3, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d46a3fa View commit details

Commits on Jul 4, 2023

  1. Copy the full SHA
    7fbcef9 View commit details
  2. Merge pull request #2098 from scalacenter/update/scalafmt-core-3.7.6

    build(deps): Update scalafmt-core from 3.7.5 to 3.7.6
    ckipp01 authored Jul 4, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    01ef1fe View commit details
  3. Merge pull request #2085 from tgodzik/fix-python

    chore: Make source generator tests more resilient
    tgodzik authored Jul 4, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6742c9a View commit details
  4. Copy the full SHA
    9022fb5 View commit details
  5. Merge pull request #2099 from tgodzik/fix-release

    chore: Update coursier.json and run release on Java 8 for the time being
    tgodzik authored Jul 4, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b9ab27c View commit details

Commits on Jul 5, 2023

  1. Update overview.md

    Fury was completely redone and no longer works with Bloop. The link for Metals was crazy old.
    ckipp01 authored Jul 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    15ac821 View commit details
  2. Merge pull request #2100 from scalacenter/ckipp01-patch-1

    docs: update overview.md with corrections
    ckipp01 authored Jul 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4fdc19b View commit details
  3. chore: Revert JGit to a version compatible with JDK 8

    Alternative would be adding everywhere the -release option, but since we plan to drop the support later on, I think it's easier to do this.
    tgodzik committed Jul 5, 2023
    Copy the full SHA
    5a4a6cb View commit details
  4. Merge pull request #2101 from tgodzik/revert-jgit

    chore: Revert JGit to a version compatible with JDK 8
    tgodzik authored Jul 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2b5a28d View commit details
  5. Copy the full SHA
    29be817 View commit details
  6. Merge pull request #2102 from tgodzik/add-release-notes

    chore: Release notes for Bloop 1.5.8
    tgodzik authored Jul 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    63f7e60 View commit details
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -241,7 +241,7 @@ jobs:
fetch-depth: 0
- uses: coursier/setup-action@v1
with:
jvm: 'temurin:11.0.18'
jvm: 'temurin:8'
- uses: actions/setup-node@v3
with:
node-version: "16"
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.7.5"
version = "3.7.6"
runner.dialect = scala213
maxColumn = 100
docstrings.style = Asterisk
3 changes: 1 addition & 2 deletions docs/build-tools/overview.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ Bloop supports several build tools with varying degree of functionality.
| Mill || |
| Bazel || |
| Pants | 🚧 work-in-progress | |
| Fury || |

## Build Export

@@ -26,7 +25,7 @@ all you need to get started with Bloop.
Exporting your build is supported by a large array of popular Scala and Java
build tools. However, it's a tedious process that users must remember to run
whenever their build changes (client integrations such as
[Metals](https://metals.rocks) can export the build automatically, but that's
[Metals](https://scalameta.org/metals/) can export the build automatically, but that's
usually not the case if you're interfacing directly with the bloop CLI).

## Built-in compile, test and run
2 changes: 1 addition & 1 deletion etc/bloop-coursier.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,6 @@
"launcherType": "graalvm-native-image",
"prebuilt": "$PREBUILT",
"dependencies": [
"ch.epfl.scala:bloopgun_2.12:$VERSION"
"ch.epfl.scala:bloopgun-core_2.13:$VERSION"
]
}
Original file line number Diff line number Diff line change
@@ -2,21 +2,30 @@ package bloop.engine.caches

import java.nio.file.Path

import scala.collection.JavaConverters._
import scala.concurrent.Await
import scala.concurrent.duration.FiniteDuration
import scala.util.Failure
import scala.util.Success
import scala.util.Try

import bloop.DependencyResolution
import bloop.SemanticDBCacheLock
import bloop.engine.ExecutionContext
import bloop.io.AbsolutePath
import bloop.io.Paths
import bloop.logging.Logger
import bloop.task.Task

import sbt.internal.inc.BloopComponentCompiler
import sbt.internal.inc.BloopComponentManager
import sbt.internal.inc.IfMissing
import java.util.concurrent.ConcurrentHashMap
import scala.concurrent.Future

object SemanticDBCache {
// to avoid resolving the same fallback semanticdb version multiple times
private val supportedFallbackSemanticdbVersions = new ConcurrentHashMap[String, String]()
private def fetchPlugin(
artifact: DependencyResolution.Artifact,
logger: Logger
@@ -57,6 +66,41 @@ object SemanticDBCache {
}
}

private def fallbackSemanticdbFetch(
scalaVersion: String,
artifact: DependencyResolution.Artifact,
logger: Logger
): Either[String, AbsolutePath] = {
// if scala version is no longer supported find the latest supported semanticdb version
def versionFuture =
Future {
coursierapi.Complete
.create()
.withScalaVersion(scalaVersion)
.withScalaBinaryVersion(scalaVersion.split('.').take(2).mkString("."))
.withInput(s"org.scalameta:semanticdb-scalac_$scalaVersion:")
.complete()
.getCompletions()
.asScala
.lastOption
}(ExecutionContext.ioScheduler)

def version =
try
Await.result(versionFuture, FiniteDuration(10, "s"))
catch {
case _: Throwable => None
}

Option(supportedFallbackSemanticdbVersions.get(scalaVersion)).orElse(version) match {
case None =>
Left(s"After retry no existing semanticdb version found for scala version $scalaVersion")
case Some(semanticdbVersion) =>
supportedFallbackSemanticdbVersions.put(scalaVersion, semanticdbVersion)
fetchPlugin(artifact.copy(version = semanticdbVersion), logger)
}
}

@volatile private var latestResolvedScalaSemanticDB: Path = null
def fetchScalaPlugin(
scalaVersion: String,
@@ -77,7 +121,16 @@ object SemanticDBCache {
latestResolvedPlugin
}
}
} else fetchPlugin(artifact, logger)
} else {
fetchPlugin(artifact, logger) match {
case Right(plugin) => Right(plugin)
case Left(error) =>
fallbackSemanticdbFetch(scalaVersion, artifact, logger) match {
case Left(newError) => Left(error + "\n" + newError)
case Right(plugin) => Right(plugin)
}
}
}
}

@volatile private var latestResolvedJavaSemanticDB: Path = null
48 changes: 32 additions & 16 deletions frontend/src/test/scala/bloop/SourceGeneratorSpec.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
package bloop

import scala.sys.process
import scala.util.control.NonFatal

import bloop.Compiler.Result.Success
import bloop.cli.ExitStatus
import bloop.config.Config
import bloop.internal.build.BuildTestInfo
import bloop.io.AbsolutePath
import bloop.logging.RecordingLogger
import bloop.util.CrossPlatform
import bloop.util.TestProject
import bloop.util.TestUtil

object SourceGeneratorSpec extends bloop.testing.BaseSuite {

lazy val hasPython3 = hasPythonNamed("python3")
lazy val hasPython2 = hasPythonNamed("python")

private val generator: List[String] =
if (CrossPlatform.isWindows) List("python", BuildTestInfo.sampleSourceGenerator.getAbsolutePath)
else List(BuildTestInfo.sampleSourceGenerator.getAbsolutePath)
if (hasPython3) List("python3", BuildTestInfo.sampleSourceGenerator.getAbsolutePath)
else if (hasPython2) List("python", BuildTestInfo.sampleSourceGenerator.getAbsolutePath)
else Nil

private def hasPythonNamed(executable: String) = try {
process.Process(Seq(executable, "--version")).! == 0
} catch {
case NonFatal(_) => false
}

test("compile a project having a source generator") {
lazy val hasPython = hasPython2 || hasPython3

def testOnlyWithPython(name: String)(fun: => Any): Unit = {
if (hasPython) test(name)(fun)
else ignore(name, label = s"IGNORED: no python found on path")(fun)
}

testOnlyWithPython("compile a project having a source generator") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (workspace, project, state) =>
writeFile(project.srcFor("Foo.scala", exists = false), assertNInputs(n = 3))
writeFile(workspace.resolve("file_one.in"), "file one")
@@ -30,7 +49,7 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("compile projects with dependent source generators") {
testOnlyWithPython("compile projects with dependent source generators") {
TestUtil.withinWorkspace { workspace =>
val sourcesA = List(
"""/main/scala/Foo.scala
@@ -91,7 +110,7 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("source generator failure yields compilation failure") {
testOnlyWithPython("source generator failure yields compilation failure") {
TestUtil.withinWorkspace { workspace =>
val logger = new RecordingLogger(ansiCodesSupported = false)
val sourceGenerator = Config.SourceGenerator(
@@ -107,15 +126,15 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("source generator is run when there are no matching input files") {
testOnlyWithPython("source generator is run when there are no matching input files") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (_, project, state) =>
writeFile(project.srcFor("test.scala", exists = false), assertNInputs(n = 0))
val compiledState = state.compile(project)
assertExitStatus(compiledState, ExitStatus.Ok)
}
}

test("source generator is re-run when an input file is removed") {
testOnlyWithPython("source generator is re-run when an input file is removed") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (workspace, project, state) =>
writeFile(workspace.resolve("hello.in"), "hello")
writeFile(project.srcFor("test.scala", exists = false), assertNInputs(n = 1))
@@ -130,7 +149,7 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("source generator is re-run when an input file is added") {
testOnlyWithPython("source generator is re-run when an input file is added") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (workspace, project, state) =>
writeFile(workspace.resolve("hello.in"), "hello")
writeFile(project.srcFor("test.scala", exists = false), assertNInputs(n = 1))
@@ -145,7 +164,7 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("source generator is re-run when an input file is modified") {
testOnlyWithPython("source generator is re-run when an input file is modified") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (workspace, project, state) =>
writeFile(workspace.resolve("hello.in"), "hello")
writeFile(project.srcFor("test.scala", exists = false), assertNInputs(n = 1))
@@ -163,7 +182,7 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("source generator is re-run when an output file is modified") {
testOnlyWithPython("source generator is re-run when an output file is modified") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (workspace, project, state) =>
val generatorOutput = project.config.sourceGenerators
.flatMap(_.headOption)
@@ -186,7 +205,7 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("source generator is re-run when an output file is deleted") {
testOnlyWithPython("source generator is re-run when an output file is deleted") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (workspace, project, state) =>
val generatorOutput = project.config.sourceGenerators
.flatMap(_.headOption)
@@ -209,11 +228,8 @@ object SourceGeneratorSpec extends bloop.testing.BaseSuite {
}
}

test("source generator is not re-run when nothing has changed") {
testOnlyWithPython("source generator is not re-run when nothing has changed") {
singleProjectWithSourceGenerator("glob:*.in" :: Nil) { (workspace, project, state) =>
val generatorOutput = project.config.sourceGenerators
.flatMap(_.headOption)
.map(p => AbsolutePath(p.outputDirectory))
writeFile(workspace.resolve("hello.in"), "hello")
writeFile(project.srcFor("test.scala", exists = false), assertNInputs(n = 1))
val compiledState1 = state.compile(project)
60 changes: 34 additions & 26 deletions frontend/src/test/scala/bloop/bsp/BspMetalsClientSpec.scala
Original file line number Diff line number Diff line change
@@ -87,32 +87,6 @@ class BspMetalsClientSpec(
}
}

test("do not initialize metals client and save settings with unsupported scala version") {
TestUtil.withinWorkspace { workspace =>
val `A` = TestProject(workspace, "A", Nil, scalaVersion = Some("2.12.4"))
val projects = List(`A`)
val configDir = TestProject.populateWorkspace(workspace, projects)
val logger = new RecordingLogger(ansiCodesSupported = false)
val extraParams = BloopExtraBuildParams(
ownsBuildFiles = None,
clientClassesRootDir = None,
semanticdbVersion = Some(semanticdbVersion), // Doesn't support 2.12.4
supportedScalaVersions = Some(List(testedScalaVersion)),
javaSemanticdbVersion = Some(javaSemanticdbVersion)
)

loadBspState(workspace, projects, logger, "Metals", bloopExtraParams = extraParams) { state =>
assertNoDiffInSettingsFile(
configDir,
expectedConfig
)
// Expect only range positions to be added, semanticdb is not supported
assertScalacOptions(state, `A`, "-Yrangepos")
assertNoDiff(logger.warnings.mkString(lineSeparator), "")
}
}
}

test("initialize metals client in workspace with already enabled semanticdb") {
TestUtil.withinWorkspace { workspace =>
val pluginPath = s"-Xplugin:path-to-plugin/$semanticdbJar"
@@ -333,6 +307,40 @@ class BspMetalsClientSpec(
}
}

test("compile with old semanticDB") {
TestUtil.withinWorkspace { workspace =>
object JavacOptions {
// This will cause to use the forked javac compiler, since addong any `-J` property causes it
val A = List("-J-Xms48m")
}

val `A` =
TestProject(
workspace,
"A",
dummyFooScalaAndBarJavaSources,
javacOptions = JavacOptions.A,
// this Scala version is not supported in the newest semanticdb
scalaVersion = Some("2.12.8")
)
val projects = List(`A`)
val configDir = TestProject.populateWorkspace(workspace, projects)
val logger = new RecordingLogger(ansiCodesSupported = false)
WorkspaceSettings.writeToFile(
configDir,
WorkspaceSettings
.fromSemanticdbSettings("0.5.7", semanticdbVersion, List(testedScalaVersion)),
logger
)
loadBspState(workspace, projects, logger) { state =>
val compiledState = state.compile(`A`).toTestState
assert(compiledState.status == ExitStatus.Ok)
assertSemanticdbFileFor("Foo.scala", compiledState)
assertSemanticdbFileFor("Bar.java", compiledState)
}
}
}

test("compile with semanticDB using cached plugin") {
TestUtil.withinWorkspace { workspace =>
val `A` = TestProject(workspace, "A", dummyFooScalaAndBarJavaSources)
32 changes: 32 additions & 0 deletions notes/v1.5.8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# bloop `v1.5.8`

Bloop v1.5.8 is a bugfix release.

## Installing Bloop

For more details about installing Bloop, please see [Bloop's Installation Guide](https://scalacenter.github.io/bloop/setup))

## Merged pull requests

Here's a list of pull requests that were merged:

- Chore: Revert JGit to a version compatible with JDK 8 [#2101]
- Docs: update overview.md with corrections [#2100]
- Chore: Update coursier.json and run release on Java 8 for the time being [#2099]
- Chore: Make source generator tests more resilient [#2085]
- Build(deps): Update scalafmt-core from 3.7.5 to 3.7.6 [#2098]
- Improvement: Try and find latest supported semanticdb version [#2097]


[#2101]: https://github.com/scalacenter/bloop/pull/2101
[#2100]: https://github.com/scalacenter/bloop/pull/2100
[#2099]: https://github.com/scalacenter/bloop/pull/2099
[#2085]: https://github.com/scalacenter/bloop/pull/2085
[#2098]: https://github.com/scalacenter/bloop/pull/2098
[#2097]: https://github.com/scalacenter/bloop/pull/2097


## Contributors

According to `git shortlog -sn --no-merges v1.5.7..v1.5.8`, the following people have contributed to
this `v1.5.8` release: Tomasz Godzik, Chris Kipp, scala-center-steward[bot], tgodzik.
5 changes: 2 additions & 3 deletions project/GitUtils.scala
Original file line number Diff line number Diff line change
@@ -78,9 +78,8 @@ object GitUtils {
def authSshKey(keyFile: File = getEnvSshKey): GitAuth = {
import _root_.com.jcraft.jsch.Session
import _root_.org.eclipse.jgit.api.TransportConfigCallback
import _root_.org.eclipse.jgit.transport.{Transport, SshTransport}
import _root_.org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory
import _root_.org.eclipse.jgit.transport.ssh.jsch.OpenSshConfig.Host
import _root_.org.eclipse.jgit.transport.{JschConfigSessionFactory, Transport, SshTransport}
import _root_.org.eclipse.jgit.transport.OpenSshConfig.Host
import _root_.org.eclipse.jgit.util.FS

val sessionFactory = new JschConfigSessionFactory {
6 changes: 4 additions & 2 deletions project/build.sbt
Original file line number Diff line number Diff line change
@@ -17,8 +17,10 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")

updateOptions := updateOptions.value.withLatestSnapshots(false)
libraryDependencies ++= List(
"org.eclipse.jgit" % "org.eclipse.jgit" % "6.6.0.202305301015-r",
"org.eclipse.jgit" % "org.eclipse.jgit.ssh.jsch" % "6.6.0.202305301015-r",
// set to jgit 5, because 6 is compatible only with java 11,
// context https://github.com/scalacenter/bloop/pull/2101
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.2.202306221912-r",
"org.eclipse.jgit" % "org.eclipse.jgit.ssh.jsch" % "5.13.2.202306221912-r",
"commons-codec" % "commons-codec" % "1.16.0",
("ch.epfl.scala" % "jarjar" % "1.7.2-patched")
.exclude("org.apache.ant", "ant")