Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = "2.7.5"
version = "3.9.8"
runner.dialect = scala213source3
assumeStandardLibraryStripMargin = true
docstrings.style = Asterisk
docstrings.wrap = "yes"
Expand Down
43 changes: 25 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lazy val V =
val requests = "0.8.0"
val minimalMillVersion = "0.10.0"
val millScipVersion = "0.3.6"
val kotlinVersion = "1.9.22"
val kotlinVersion = "2.1.20"
}

inThisBuild(
Expand Down Expand Up @@ -286,7 +286,13 @@ lazy val cli = project
"com.lihaoyi" %% "requests" % V.requests,
"org.scalameta" %% "moped" % V.moped,
"org.scalameta" %% "ascii-graphs" % "0.1.2",
"org.jetbrains.kotlin" % "kotlin-compiler-embeddable" % V.kotlinVersion
"org.jetbrains.kotlin" % "kotlin-compiler-embeddable" % V.kotlinVersion,
"org.jetbrains.kotlin" % "kotlin-scripting-common" % V.kotlinVersion,
"org.jetbrains.kotlin" % "kotlin-scripting-jvm" % V.kotlinVersion,
"org.jetbrains.kotlin" % "kotlin-scripting-dependencies" %
V.kotlinVersion,
"org.jetbrains.kotlin" % "kotlin-scripting-dependencies-maven" %
V.kotlinVersion
),
(Compile / resourceGenerators) +=
Def
Expand Down Expand Up @@ -410,19 +416,18 @@ lazy val minimized8 = project
.dependsOn(agent, javacPlugin)
.disablePlugins(JavaFormatterPlugin)

def javacModuleOptions =
List(
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
)
def javacModuleOptions = List(
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"-J--add-exports",
"-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
)

lazy val minimized17 = project
.in(file("tests/minimized/.j17"))
Expand Down Expand Up @@ -459,7 +464,7 @@ lazy val unit = project
.in(file("tests/unit"))
.settings(
testSettings,
//javaOptions ++= Seq( "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
// javaOptions ++= Seq( "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
buildInfoKeys :=
Seq[BuildInfoKey](
version,
Expand All @@ -486,9 +491,11 @@ lazy val buildTools = project
(Test / javaOptions) ++=
List(
s"-javaagent:${(agent / Compile / Keys.`package`).value}",
s"-Dsemanticdb.pluginpath=${(javacPlugin / Compile / Keys.`package`).value}",
s"-Dsemanticdb.pluginpath=${(javacPlugin / Compile / Keys.`package`)
.value}",
s"-Dsemanticdb.sourceroot=${(ThisBuild / baseDirectory).value}",
s"-Dsemanticdb.targetroot=${(agent / Compile / target).value / "semanticdb-targetroot"}"
s"-Dsemanticdb.targetroot=${(agent / Compile / target).value /
"semanticdb-targetroot"}"
),
Test / envVars ++=
Map(
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.11.2
sbt.version=1.11.3
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.14")
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.9.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.3")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
addSbtPlugin("com.sourcegraph" % "sbt-sourcegraph" % "0.4.3")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.6.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ object Dependencies {
.addRepositories(defaultExtraRepositories: _*)

if (artifact.endsWith("-jvm")) {
val dependency = Dependencies
.parseDependency(s"$group:${artifact.stripSuffix("-jvm")}:$version")
val dependency = Dependencies.parseDependency(
s"$group:${artifact.stripSuffix("-jvm")}:$version"
)
val result = task.addDependencies(dependency).runResult()
return Some(result.files.head.toPath)
}

val dependency = Dependencies
.parseDependency(s"$group:$artifact-common:$version")
val dependency = Dependencies.parseDependency(
s"$group:$artifact-common:$version"
)
val result = task.addDependencies(dependency).runResult()
result.files.head.toPath
}.toOption
Expand Down Expand Up @@ -145,8 +147,10 @@ object Dependencies {
}.toList

def parseDependencyEither(lib: String): Either[String, Dependency] = {
DependencyParser
.dependency(lib, defaultScalaVersion = BuildInfo.scalaVersion)
DependencyParser.dependency(
lib,
defaultScalaVersion = BuildInfo.scalaVersion
)
}

private def parseDependency(lib: String): Dependency = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import os.CommandResult

object Embedded {

def semanticdbJar(tmpDir: Path): Path =
copyFile(tmpDir, "semanticdb-plugin.jar")
def semanticdbJar(tmpDir: Path): Path = copyFile(
tmpDir,
"semanticdb-plugin.jar"
)

def gradlePluginJar(tmpDir: Path): Path =
copyFile(tmpDir, "gradle-plugin.jar")
def gradlePluginJar(tmpDir: Path): Path = copyFile(
tmpDir,
"gradle-plugin.jar"
)

def agentJar(tmpDir: Path): Path = copyFile(tmpDir, "semanticdb-agent.jar")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@ object BuildTool {
// detected, we should at least give a meaningful error message
autoOrdered(index) :+ new BazelBuildTool(index)

def autoOrdered(index: IndexCommand): List[BuildTool] =
List(
// The order in this list is important -
// first detected build tool will be used in `auto` mode
// Bazel is missing because it isn't supported by auto-indexing
def autoOrdered(index: IndexCommand): List[BuildTool] = List(
// The order in this list is important -
// first detected build tool will be used in `auto` mode
// Bazel is missing because it isn't supported by auto-indexing

// first as it indicates user's intent to use SCIP auto-indexing
new ScipBuildTool(index),
// Maven first, then Gradle, then SBT
// To match the order indicated in IntelliJ Java and Scala developer surveys 2022:
// 1. https://www.jetbrains.com/lp/devecosystem-2022/java/#which-build-systems-do-you-regularly-use-if-any-
// 2. https://www.jetbrains.com/lp/devecosystem-2022/scala/#which-build-systems-do-you-regularly-use-if-any-
new MavenBuildTool(index),
new GradleBuildTool(index),
new SbtBuildTool(index),
new MillBuildTool(index)
)
def allNames: String =
all(IndexCommand()).filterNot(_.isHidden).map(_.name).mkString(", ")
// first as it indicates user's intent to use SCIP auto-indexing
new ScipBuildTool(index),
// Maven first, then Gradle, then SBT
// To match the order indicated in IntelliJ Java and Scala developer surveys 2022:
// 1. https://www.jetbrains.com/lp/devecosystem-2022/java/#which-build-systems-do-you-regularly-use-if-any-
// 2. https://www.jetbrains.com/lp/devecosystem-2022/scala/#which-build-systems-do-you-regularly-use-if-any-
new MavenBuildTool(index),
new GradleBuildTool(index),
new SbtBuildTool(index),
new MillBuildTool(index)
)
def allNames: String = all(IndexCommand())
.filterNot(_.isHidden)
.map(_.name)
.mkString(", ")

def generateScipFromTargetroot(
generateSemanticdbResult: CommandResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object ClasspathEntry {
* "dependencies.txt" - for example if they come from a multi-module build.
*
* @param targetroot
* @return
* @return
*/
def fromTargetroot(
targetroot: Path,
Expand All @@ -61,7 +61,8 @@ object ClasspathEntry {
* for multiple projects.
*
* @param targetroot
* @return classpath entries read from the discovered files
* @return
* classpath entries read from the discovered files
*/
private def discoverDependenciesFromFiles(
targetroot: Path
Expand Down Expand Up @@ -155,8 +156,9 @@ object ClasspathEntry {
* given jar file.
*/
private def fromClasspathJarFile(jar: Path): Option[ClasspathEntry] = {
val pom = jar
.resolveSibling(jar.getFileName.toString.stripSuffix(".jar") + ".pom")
val pom = jar.resolveSibling(
jar.getFileName.toString.stripSuffix(".jar") + ".pom"
)
val sources = Option(
jar.resolveSibling(
jar.getFileName.toString.stripSuffix(".jar") + ".sources"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
"build.gradle",
"build.gradle.kts"
)
gradleFiles
.exists(name => Files.isRegularFile(index.workingDirectory.resolve(name)))
gradleFiles.exists(name =>
Files.isRegularFile(index.workingDirectory.resolve(name))
)
}

override def generateScip(): Int = {
BuildTool
.generateScipFromTargetroot(generateSemanticdb(), targetroot, index)
BuildTool.generateScipFromTargetroot(
generateSemanticdb(),
targetroot,
index
)
}

def targetroot: Path = index.finalTargetroot(defaultTargetroot)

private def defaultTargetroot: Path =
Paths.get("build", "semanticdb-targetroot")
private def defaultTargetroot: Path = Paths.get(
"build",
"semanticdb-targetroot"
)
private def generateSemanticdb(): CommandResult = {
val gradleWrapper: Path = index
.workingDirectory
Expand Down Expand Up @@ -127,14 +133,14 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
)
}

def semanticdbScalacGroovySyntax(): String =
BuildInfo
.semanticdbScalacVersions
.removed(
"2.12.3"
) // Not supported because the last semanticdb-scalac_2.12.3 release doesn't support the option -P:semanticdb:targetroot:PATH.
.map { case (key, value) =>
s"'$key':'$value'"
}.mkString("[", ", ", "]")
def semanticdbScalacGroovySyntax(): String = BuildInfo
.semanticdbScalacVersions
.removed(
"2.12.3"
) // Not supported because the last semanticdb-scalac_2.12.3 release doesn't support the option -P:semanticdb:targetroot:PATH.
.map { case (key, value) =>
s"'$key':'$value'"
}
.mkString("[", ", ", "]")

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ case class GradleJavaToolchains(

def isJavaAtLeast(version: Int): Boolean = {
val actualVersion = javaVersion.getOrElse(sys.props("java.version"))
GradleJavaToolchains
.isJavaAtLeast(actualVersion, math.max(version, 0).toString())
GradleJavaToolchains.isJavaAtLeast(
actualVersion,
math.max(version, 0).toString()
)
}

def executableJavacPath(): Option[Path] = {
Expand Down Expand Up @@ -79,8 +81,9 @@ object GradleJavaToolchains {
val scalaEnabledPath = tmp.resolve("scala-enabled.txt")
val kotlinEnabledPath = tmp.resolve("kotlin-enabled.txt")
val javaVersionPath = tmp.resolve("java-version.txt")
val kotlinMultiplatformEnabledPath = tmp
.resolve("kotlin-multiplatform-enabled.txt")
val kotlinMultiplatformEnabledPath = tmp.resolve(
"kotlin-multiplatform-enabled.txt"
)
val gradleVersionPath = tmp.resolve("gradle-version.txt")
val taskName = "scipDetectJavaToolchains"
@Language("Groovy")
Expand Down Expand Up @@ -186,8 +189,9 @@ object GradleJavaToolchains {
isJavaEnabled = Files.isRegularFile(javaEnabledPath),
isScalaEnabled = Files.isRegularFile(scalaEnabledPath),
isKotlinEnabled = Files.isRegularFile(kotlinEnabledPath),
isKotlinMultiplatformEnabled = Files
.isRegularFile(kotlinMultiplatformEnabledPath),
isKotlinMultiplatformEnabled = Files.isRegularFile(
kotlinMultiplatformEnabledPath
),
gradleCommand = gradleCommand,
tmp = tmp
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import os.CommandResult

class MavenBuildTool(index: IndexCommand) extends BuildTool("Maven", index) {

override def usedInCurrentDirectory(): Boolean =
Files.isRegularFile(index.workingDirectory.resolve("pom.xml"))
override def usedInCurrentDirectory(): Boolean = Files.isRegularFile(
index.workingDirectory.resolve("pom.xml")
)

override def generateScip(): Int = {
BuildTool.generateScipFromTargetroot(
Expand All @@ -23,8 +24,10 @@ class MavenBuildTool(index: IndexCommand) extends BuildTool("Maven", index) {
)
}

private def defaultTargetroot: Path =
Paths.get("target", "semanticdb-targetroot")
private def defaultTargetroot: Path = Paths.get(
"target",
"semanticdb-targetroot"
)

private def generateSemanticdb(): CommandResult = {
TemporaryFiles.withDirectory(index) { tmp =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import com.sourcegraph.scip_java.commands.IndexCommand

class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) {

override def usedInCurrentDirectory(): Boolean =
Files.isRegularFile(index.workingDirectory.resolve("build.sc"))
override def usedInCurrentDirectory(): Boolean = Files.isRegularFile(
index.workingDirectory.resolve("build.sc")
)

override def generateScip(): Int =
millVersion() match {
Expand Down
Loading