@@ -5,18 +5,19 @@ intelligence for Scala projects on Sourcegraph.
55
66- works with Scala 2.11, 2.12 and 2.13
77- works with self-hosted Sourcegraph instances
8- - requires sbt v1.3 or newer
8+ - requires sbt v1.4 or newer
99
1010** Overview** :
1111
1212- [ Getting started] ( #getting-started )
1313- [ Configuration] ( #configuration )
1414- [ Disable plugin for specific project] ( #disable-plugin-for-specific-project )
1515- [ Known limitations] ( #known-limitations )
16+ - [ Troubleshooting] ( #troubleshooting )
1617
1718## Getting started
1819
19- First, make sure you are using sbt v1.3 or newer. This plugin does not work with
20+ First, make sure you are using sbt v1.4 or newer. This plugin does not work with
2021older versions of sbt.
2122
2223Next, add the sbt plugin to your build in ` project/plugins.sbt ` .
@@ -28,23 +29,72 @@ Next, add the sbt plugin to your build in `project/plugins.sbt`.
2829+ addSbtPlugin("com.sourcegraph" % "sbt-sourcegraph" % "LATEST_VERSION")
2930```
3031
31- Next, enable SemanticDB in ` build.sbt ` .
32+ Next, enable SemanticDB in ` build.sbt ` and use the latest version of SemanticDB.
33+ [ ![ ] ( https://index.scala-lang.org/scalameta/scalameta/latest.svg?color=blue )] ( https://mvnrepository.com/artifact/org.scalameta/semanticdb-scalac )
3234
3335``` diff
3436 // build.sbt
3537+ ThisBuild / semanticdbEnabled := true
38+ + ThisBuild / semanticdbVersion := "LATEST_VERSION"
3639 lazy val myproject1 = project
3740 .settings(
3841 ...
3942 )
4043 lazy val myproject2 = project
4144```
4245
43- Optionally, enable SemanticDB on a per-project basis instead of via ` ThisBuild ` .
46+ Next, add a GitHub Actions workflow to your repository to configure your CI to
47+ upload indexes on pull requests and merge into your main branch.
48+
49+ ``` sh
50+ mkdir -p .github/workflows && \
51+ curl -L https://raw.githubusercontent.com/sourcegraph/sbt-sourcegraph/master/.github/workflows/sourcegraph.yml > .github/workflows/sourcegraph.yml
52+ ```
53+
54+ Optionally, adjust ` sourcegraph.yml ` to your needs. For example, you may want to
55+ disable the upload job for pull requests and use Java 11.
56+
57+ ``` diff
58+ // .github/workslows/sourcegraph.yml
59+ on:
60+ push:
61+ branches:
62+ - main
63+ - pull_request:
64+ jobs:
65+ lsif:
66+ steps:
67+ - uses: olafurpg/setup-scala@v10
68+ + with:
69+ 70+ - uses: actions/setup-go@v2
71+ with:
72+ go-version: "1.15.6"
73+ ```
74+
75+ Commit the new file and push it to GitHub to trigger the upload job. Once the
76+ upload job completes, you should be able to observe precise code intelligence on
77+ GitHub.
78+
79+ ### Other ways to enable SemanticDB
80+
81+ If you don't want to enable SemanticDB in ` build.sbt ` , you can do it a single
82+ sbt session inside the upload CI job.
83+
84+ ``` sh
85+ $ sbt \
86+ ' set every semanticdbEnabled := true' \
87+ ' set every semanticdbVersion := "LATEST_VERSION"' \
88+ sourcegraphUpload
89+ ```
90+
91+ If you have projects that don't work with SemanticDB, you can optionally enable
92+ SemanticDB on a per-project basis instead of via ` ThisBuild ` .
4493
4594``` diff
4695 // build.sbt
4796- ThisBuild / semanticdbEnabled := true
97+ ThisBuild / semanticdbVersion := "LATEST_VERSION"
4898 lazy val myproject1 = project
4999 .settings(
50100 ...
@@ -53,28 +103,14 @@ Optionally, enable SemanticDB on a per-project basis instead of via `ThisBuild`.
53103 lazy val myproject2 = project
54104```
55105
56- Next, add a GitHub Actions workflow to your repository to configure your CI to
57- upload indexes on pull requests and merge into your main branch. See the section
58- on [ other CI systems] ( #other-ci-systems ) for how to configure this plugin if you
59- are not using GitHub Actions.
60-
61- ``` sh
62- mkdir -p .github/workflows && \
63- curl -L https://raw.githubusercontent.com/sourcegraph/sbt-sourcegraph/master/.github/workflows/sourcegraph.yml > .github/workflows/sourcegraph.yml
64- ```
65-
66- Feel free to adjust ` sourcegraph.yml ` to your needs, for example to disable
67- uploading on pull requests. Commit the new file and push it to GitHub to trigger
68- the upload job. Once the upload job completes, you should be able to observe
69- precise code intelligence on GitHub.
70-
71106### Other CI systems
72107
73- This plugin can be used with any CI system. In short, the installation steps
74- from [ ` sourcegraph.yml ` ] ( .github/workflows/sourcegraph.yml ) document all of the
75- requirements to run this plugin.
108+ This plugin can be used with any CI system. If you don't use GitHub Actions, you
109+ can adjust the installation steps from
110+ [ ` sourcegraph.yml ` ] ( .github/workflows/sourcegraph.yml ) to work with your own CI
111+ system.
76112
77- First, install the following binaries to ` $PATH ` .
113+ In short, first install the following binaries to ` $PATH ` .
78114
79115- https://github.com/sourcegraph/lsif-semanticdb as ` lsif-semanticdb `
80116- https://github.com/sourcegraph/src-cli as ` src `
@@ -144,3 +180,22 @@ known issues:
144180- Find references returns buggy results in some cases.
145181- ` crossScalaVersions ` is not supported. It's only possible to upload indexes
146182 for a single Scala version.
183+
184+ ## Troubleshooting
185+
186+ ### ` NoSuchMethodError: sbt.Def$.ifS() `
187+
188+ The error below happens when you use this plugin with sbt v1.3 or older
189+ versions.
190+
191+ ```
192+ java.lang.NoSuchMethodError: sbt.Def$.ifS(Lsbt/internal/util/Init$Initialize;Lsbt/internal/util/Init$Initialize;Lsbt/internal/util/Init$Initialize;)Lsbt/internal/util/Init$Initialize;
193+ ```
194+
195+ To fix this problem, upgrade to sbt v1.4.6 or newer.
196+
197+ ``` diff
198+ # project/build.properties
199+ - sbt.version=1.3.10
200+ + sbt.version=1.4.6
201+ ```
0 commit comments