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
19 changes: 0 additions & 19 deletions .github/workflows/mdoc.yml

This file was deleted.

106 changes: 105 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,107 @@
# Contributing guide

See https://sourcegraph.github.io/scip-java/docs/contributing.html
This page documents tips and tricks for contributing to the
[sourcegraph/scip-java](https://github.com/sourcegraph/scip-java) codebase.

## System dependencies

The recommended way to get a working development environment is via
[Nix](https://nixos.org/download) and the provided [flake](https://github.com/sourcegraph/scip-java/blob/main/flake.nix):

```sh
nix develop # default shell (JDK 11)
nix develop .#jdk17 # JDK 17
nix develop .#jdk21 # JDK 21
```

This drops you into a shell with `sbt`, `cs` (coursier), `maven`, `gradle`,
`bazelisk`, `scalafmt`, `nodejs`, `yarn`, `git`, `jq`, etc. all pinned to the
versions used in CI.

If you'd rather install tools manually, you'll need at least:

- `java`: any version should work
- `git`: any version should work
- `gradle`: `brew install gradle`, or see
[general installation guide](https://gradle.org/install/).
- `mvn`: `brew install maven`, or see
[general installation guide](https://www.baeldung.com/install-maven-on-windows-linux-mac).

## Project structure

These are the main components of the project.

- `semanticdb-javac/src/main/java`: the Java compiler plugin that creates
SemanticDB files.
- `tests/minimized`: minimized Java source files that reproduce interesting test
cases.
- `tests/unit`: fast running unit tests that are helpful for local edit-and-test
workflows.
- `tests/snapshots`: slow running
["snapshot tests"](https://jestjs.io/docs/en/snapshot-testing) that index a
corpus of published Java libraries.
- `cli/src/main/scala`: implementation of the `scip-java` command-line
interface.
- `build.sbt`: the sbt build definition.
- `project/plugins.sbt`: plugins for the sbt build.

## Helpful commands

| Command | Where | Description |
| ------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------- |
| `sbt` | terminal | Start interactive sbt shell with Java 11 (run from `nix develop`). Takes a while to load on the first run. |
| `unit/test` | sbt | Run fast unit tests. |
| `~unit/test` | sbt | Start watch mode to run tests on file save, good for local edit-and-test workflows. |
| `buildTools/test` | sbt | Run slow build tool tests (Gradle, Maven). |
| `snapshots/testOnly tests.MinimizedSnapshotSuite` | sbt | Runs fast snapshot tests. Indexes a small set of files under `tests/minimized`. |
| `snapshots/testOnly tests.MinimizedSnapshotSuite -- *InnerClasses*` | sbt | Runs only individual tests cases matching the name "InnerClasses". |
| `snapshots/testOnly tests.LibrarySnapshotSuite` | sbt | Runs slow snapshot tests. Indexes a corpus of external Java libraries. |
| `snapshots/test` | sbt | Runs all snapshot tests. |
| `snapshots/run` | sbt | Update snapshot tests. Use this command after you have fixed a bug. |
| `cli/run --cwd DIRECTORY` | sbt | Run `scip-java` command-line tool against a given Gradle/Maven build. |
| `fixAll` | sbt | Run Scalafmt, Scalafix and Javafmt on all sources. Run this before opening a PR. |

## Import the project into IntelliJ

It's recommended to use IntelliJ when editing code in this codebase.

First, install the
[IntelliJ Community Edition](https://www.jetbrains.com/idea/download/). The
community edition is
[open source](https://github.com/JetBrains/intellij-community) and free to use.

Next, install the following IntelliJ plugins:

- IntelliJ Scala plugin.
- Google Java Format

Next, follow
[these instructions](https://github.com/HPI-Information-Systems/Metanome/wiki/Installing-the-google-styleguide-settings-in-intellij-and-eclipse)
here to configure the Google Java formatter.

Finally, run "File > Project From Existing Sources" to import the sbt build into
IntelliJ. Select the "sbt" option if it asks you to choose between
sbt/BSP/Bloop.

It's best to run tests from the sbt shell, not from the IntelliJ UI.

## Importing the project with Metals

While the cross-language support won't be as rich as it is in IntelliJ,
[Metals](https://scalameta.org/metals/) does offer rich language support for
Scala and basic Java navigation support (thanks to scip-java!). When using
Metals and your editor of choice it's recommended to use sbt as your build
server. This isn't the default with Metals, so you'll want to use the `Metals:
Switch build server` command and choose `sbt`.

## Tests are written in Scala

This codebases uses the Scala library [MUnit](https://scalameta.org/munit/) to
write tests because:

- MUnit has built-in assertions that print readable multiline diffs in color.
- MUnit makes it easy to implement
[snapshot testing](https://jestjs.io/docs/en/snapshot-testing), which is a
testing technique that's heavily used in this codebase.
- Multiline literal strings in Scala make it easy to write unit tests for source
code (which is always multiline).
22 changes: 1 addition & 21 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ commands +=
commands +=
Command.command("checkAll") { s =>
"javafmtCheckAll" :: "scalafmtCheckAll" :: "scalafmtSbtCheck" ::
"scalafixAll --check" :: "publishLocal" :: "docs/docusaurusCreateSite" ::
s
"scalafixAll --check" :: "publishLocal" :: s
}

lazy val semanticdb = project
Expand Down Expand Up @@ -724,25 +723,6 @@ lazy val bench = project
.dependsOn(unit)
.enablePlugins(JmhPlugin)

lazy val docs = project
.in(file("scip-java-docs"))
.settings(
publishLocal / skip := true,
publish / skip := true,
moduleName := "scip-java-docs",
mdocOut :=
(ThisBuild / baseDirectory).value / "website" / "target" / "docs",
fork := false,
mdocVariables :=
Map[String, String](
"VERSION" -> version.value,
"SCALA_VERSION" -> scalaVersion.value,
"STABLE_VERSION" -> version.value.replaceFirst("\\-.*", "")
)
)
.dependsOn(unit)
.enablePlugins(DocusaurusPlugin)

lazy val javaOnlySettings = List[Def.Setting[_]](
javafmtOnCompile := false,
autoScalaLibrary := false,
Expand Down
1 change: 0 additions & 1 deletion docs/assets/semanticdb-javac-pipeline.svg

This file was deleted.

28 changes: 0 additions & 28 deletions docs/benchmarks.md

This file was deleted.

113 changes: 0 additions & 113 deletions docs/contributing.md

This file was deleted.

2 changes: 0 additions & 2 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ that generates one
every `*.java` source file. After compilation completes, the SemanticDB files
are processed to produce SCIP.

![A three stage pipeline that starts with a list of Java sources, creates a list of SemanticDB files that then become a single SCIP index.](assets/semanticdb-javac-pipeline.svg)

### Why Java compiler plugin?

There are several benefits to implementing scip-java as a compiler plugin:
Expand Down
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.11.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.5.5")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.3")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
addSbtPlugin("com.sourcegraph" % "sbt-sourcegraph" % "0.4.4")
Expand Down
1 change: 0 additions & 1 deletion website/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion website/.tool-versions

This file was deleted.

25 changes: 0 additions & 25 deletions website/README.md

This file was deleted.

Loading
Loading