Skip to content
Open
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
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ jobs:
distribution: "temurin"
cache: "sbt"
java-version: ${{ matrix.java }}
- run: |
ls $JAVA_HOME
sbt scripted +test
shell: bash

- name: SBT 1.x tests
run: sbt scripted +test

- name: SBT 0.13.x tests
run: sbt +publishLocal 'scripted sbt-sourcegraph/basic-sbt0.13'


check:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ object SourcegraphEnable {
if (SemanticdbPlugin.isAvailable()) withSemanticdbPlugin
else withSemanticdbScalac

private lazy val semanticdbJavacVersion = Versions.semanticdbJavacVersion()

private lazy val withSemanticdbPlugin = Command.command(
"sourcegraphEnable",
briefHelp = "Configure SemanticdbPlugin for Sourcegraph.",
Expand All @@ -30,8 +32,6 @@ object SourcegraphEnable {
inConfig(_)(SourcegraphPlugin.relaxScalacOptionsConfigSettings)
)

val semanticdbJavacVersion = Versions.semanticdbJavacVersion()

val settings = for {
(p, semanticdbVersion, overriddenScalaVersion) <- collectProjects(
extracted
Expand Down Expand Up @@ -120,6 +120,16 @@ object SourcegraphEnable {
if (Versions.isJavaAtLeast(17)) javacModuleOptions else Nil
}
),
Option(
allDependencies.in(p) +=
"com.sourcegraph" % "semanticdb-javac" % semanticdbJavacVersion
),
Option(
javacOptions.in(p) += s"-Xplugin:semanticdb " +
s"-build-tool:sbt " +
s"-sourceroot:${baseDirectory.in(ThisBuild).value} " +
s"-targetroot:${classDirectory.in(p, Compile).value.toPath().resolveSibling("semanticdb-classes")}"
),
Option(
javaHome.in(p) := javaHome.in(p).value orElse calculateJavaHome
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package aj;

import geny.Generator;
import org.junit.Assert;

public class A {
public geny.Generator x = a.A.generator();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package a

import org.junit.Assert

object A extends App {
def generator = geny.Generator(1)
Assert.assertEquals(generator, "")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package bj;

public class B {
public geny.Generator generator = a.A.generator();
}
63 changes: 63 additions & 0 deletions src/sbt-test/sbt-sourcegraph/basic-sbt0.13/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import scala.collection.JavaConverters._
import java.nio.file.Paths
import java.nio.file.Files

inThisBuild(
List(
scalaVersion := "2.12.15",
organization := "com.example"
)
)

lazy val a = project
.settings(
libraryDependencies += "com.lihaoyi" %% "geny" % "0.6.10",
libraryDependencies += "junit" % "junit" % "4.13.2"
)

lazy val b = project
.dependsOn(a)
.settings(
// Test to ensure the plugin works with explicitly set java home
// On Java 8 the java.home property returns JRE path, not JDK path.
// so we try and work around it hoping that JAVA_HOME is set by executing
// environment
javaHome := {
println(sys.env.get("JAVA_HOME"))
Some(
new File(
sys.env.getOrElse("JAVA_HOME", System.getProperty("java.home"))
)
)
}
)

commands += Command.command("checkLsif") { s =>
val dumpPath =
baseDirectory.in(ThisBuild).value / "target" / "sbt-sourcegraph" / "index.scip"
val index =
lib.codeintel.scip.Scip.Index.parseFrom(Files.readAllBytes(dumpPath.toPath))

println(index)
val packageNames = index.getDocumentsList.asScala
.flatMap(_.getOccurrencesList.asScala)
.map(_.getSymbol)
.filterNot(_.startsWith("local"))
.map(_.split(" ").toList)
.collect { case _ :: _ :: name :: _ => name }
.filterNot(_ == ".")
.distinct
.sorted
.toList
if (
packageNames != List(
"jdk",
"maven/com.lihaoyi/geny_2.12",
"maven/junit/junit",
"maven/org.scala-lang/scala-library"
)
) {
sys.error(packageNames.toString)
}
s
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.17
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
addSbtPlugin(
"com.sourcegraph" % "sbt-sourcegraph" % sys.props("plugin.version")
)

libraryDependencies += "com.sourcegraph" % "scip-semanticdb" %
sys.props("scip-java.version")
3 changes: 3 additions & 0 deletions src/sbt-test/sbt-sourcegraph/basic-sbt0.13/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> sourcegraphEnable
> sourcegraphCompile
> checkLsif