Skip to content
Closed
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
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@v13

- name: Main project tests
run: nix develop .#jdk${{ matrix.java }} --command gradle test --no-daemon
run: nix develop .#jdk${{ matrix.java }} --command mvn --batch-mode test

docker_test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,6 +62,7 @@ jobs:

- uses: DeterminateSystems/magic-nix-cache-action@v13

- run: nix develop --command mvn --batch-mode -DskipTests install
- run: nix develop --command bazelisk build //... --//scip-javac:enabled=true
- run: nix develop --command bazelisk run scip-aggregator:bazel -- --sourceroot "$PWD"
- run: du -h index.scip
Expand All @@ -83,8 +84,8 @@ jobs:

- uses: DeterminateSystems/magic-nix-cache-action@v13

- run: nix develop --command gradle :scip-java:installDist --no-daemon
- run: echo "$PWD/scip-java/build/install/scip-java/bin" >> "$GITHUB_PATH"
- run: nix develop --command mvn --batch-mode -DskipTests install
- run: echo "$PWD/scip-java/target/install/scip-java/bin" >> "$GITHUB_PATH"
- name: Auto-index scip-java codebase
run: |
# shellcheck disable=SC2016
Expand Down Expand Up @@ -113,10 +114,10 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@v13

- name: scip-kotlinc tests
run: nix develop --command gradle :scip-kotlinc:test --no-daemon
run: nix develop --command mvn --batch-mode -pl scip-kotlinc -am test

- name: Regenerate snapshots
run: nix develop --command gradle :scip-snapshots:saveSnapshots --no-daemon
run: nix develop --command mvn --batch-mode -pl scip-snapshots -am -DskipTests -PsaveSnapshots verify

- name: Check snapshot drift
run: |
Expand All @@ -141,13 +142,13 @@ jobs:

- run: |
nix develop .#jdk${{ matrix.java }} --command \
gradle --no-daemon :scip-java:installDist publishToMavenLocal
mvn --batch-mode -DskipTests install
SCIP_JAVA_VERSION="$(
sed -n 's/^version:=//p' scip-java/build/install/scip-java/VERSION
sed -n 's/^version:=//p' scip-java/target/install/scip-java/VERSION
)"
test -n "$SCIP_JAVA_VERSION"
printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$GITHUB_ENV"
printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/build/install/scip-java/bin/scip-java" >> "$GITHUB_ENV"
printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/target/install/scip-java/bin/scip-java" >> "$GITHUB_ENV"

- run: |
nix develop "$GITHUB_WORKSPACE#jdk${{ matrix.java }}" --command \
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build/
.lib/
dist/*
target/
.flattened-pom.xml
lib_managed/
src_managed/
.bloop
Expand Down
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Root Bazel package for the rules_jvm_external Maven lock file.
36 changes: 19 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ nix develop .#jdk17 # JDK 17
nix develop .#jdk21 # JDK 21
```

This drops you into a shell with `gradle`, `maven`, `bazelisk`, `nodejs`,
This drops you into a shell with `maven`, `gradle`, `bazelisk`, `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).
- `gradle`: `brew install gradle`, or see
[general installation guide](https://gradle.org/install/). The project build
is Maven-based, but the CLI integration tests still exercise Gradle projects.

## Project structure

Expand All @@ -43,21 +44,22 @@ These are the main components of the project.
interface.
- `scip-java/src/test`: build-tool integration tests and fixtures for the
`scip-java` command-line interface.
- `settings.gradle.kts`: Gradle project layout.
- `build.gradle.kts`: Gradle build definition.
- `gradle/libs.versions.toml`: dependency and plugin versions.
- `pom.xml`: Maven reactor, dependency versions, and shared plugin setup.
- `*/pom.xml`: Maven module build definitions.
- `build.gradle.kts`, `settings.gradle.kts`, `gradle/libs.versions.toml`: legacy
Gradle build files kept during the Maven migration experiment.

## Helpful commands

| Command | Where | Description |
| ------------------------------------------------------- | -------- | ----------------------------------------------------------------------- |
| `gradle test --no-daemon` | terminal | Run all Gradle tests. |
| `gradle :scip-java:test --no-daemon` | terminal | Run CLI build-tool integration tests (Gradle, Maven, SCIP config). |
| `gradle :scip-kotlinc:test --no-daemon` | terminal | Run Kotlin compiler-plugin tests. |
| `gradle :scip-snapshots:test --no-daemon` | terminal | Compare Java and Kotlin snapshot goldens. |
| `gradle :scip-snapshots:saveSnapshots --no-daemon` | terminal | Regenerate Java and Kotlin snapshot goldens. |
| `gradle :scip-java:installDist --no-daemon` | terminal | Build a local `scip-java` distribution under `scip-java/build/install/`. |
| `gradle :scip-java:run --args='--cwd DIRECTORY'` | terminal | Run `scip-java` against a given Gradle/Maven build. |
| `mvn --batch-mode test` | terminal | Run all Maven reactor tests. |
| `mvn --batch-mode -pl scip-java -am test` | terminal | Run CLI build-tool integration tests (Gradle, Maven, SCIP config). |
| `mvn --batch-mode -pl scip-kotlinc -am test` | terminal | Run Kotlin compiler-plugin tests. |
| `mvn --batch-mode -pl scip-snapshots -am test` | terminal | Compare Java and Kotlin snapshot goldens. |
| `mvn --batch-mode -pl scip-snapshots -am -DskipTests -PsaveSnapshots verify` | terminal | Regenerate Java and Kotlin snapshot goldens. |
| `mvn --batch-mode -pl scip-java -am -DskipTests package` | terminal | Build a local `scip-java` distribution under `scip-java/target/install/`. |
| `scip-java/target/install/scip-java/bin/scip-java --cwd DIRECTORY index` | terminal | Run `scip-java` against a given Gradle/Maven build after packaging. |
| `google-java-format --replace $(git ls-files '*.java')` | terminal | Format Java sources (from `nix develop`). Enforced by `nix flake check`. |
| `ktfmt --kotlinlang-style $(git ls-files '*.kt')` | terminal | Format Kotlin sources (from `nix develop`). Enforced by `nix flake check`. |

Expand All @@ -78,15 +80,15 @@ 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 Gradle build
into IntelliJ. Select the "Gradle" option if it asks you to choose a build
Finally, run "File > Project From Existing Sources" to import the Maven build
into IntelliJ. Select the "Maven" option if it asks you to choose a build
model.

It's best to run tests from Gradle, not from the IntelliJ UI.
It's best to run tests from Maven, not from the IntelliJ UI.

## Tests are written in Java with JUnit 5

The Java tests use [JUnit 5](https://junit.org/junit5/) through Gradle's JUnit
The Java tests use [JUnit 5](https://junit.org/junit5/) through Maven Surefire's
Platform support. The snapshot suite is a JUnit `@TestFactory` that emits one
dynamic test per generated document, comparing it against the committed goldens
under `scip-snapshots/expected`. Build-tool tests (`scip-java/src/test`) are
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN git config --global --add safe.directory *

COPY . .

RUN gradle --no-daemon :scip-java:installDist && mkdir -p /app/scip-java && cp -R scip-java/build/install/scip-java/. /app/scip-java/
RUN mvn --batch-mode -pl scip-java -am -DskipTests package && mkdir -p /app/scip-java && cp -R scip-java/target/install/scip-java/. /app/scip-java/

COPY ./bin/scip-java-docker-script.sh /usr/bin/scip-java

Expand Down
22 changes: 20 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ maven.install(
"org.scip-code:scip-java-bindings:0.8.0",
],
known_contributing_modules = ["protobuf"],
repositories = ["https://repo1.maven.org/maven2"],
repositories = [
"https://repo1.maven.org/maven2",
],
lock_file = "//:maven_install.json",
)

# Keep changing in-repo tool artifacts unpinned: `mvn install` populates m2Local
# before Bazel runs, avoiding duplicate Bazel-side build rules for these jars.
maven.install(
name = "local_maven",
artifacts = [
"com.sourcegraph:scip-aggregator:0.0.0-SNAPSHOT",
"com.sourcegraph:scip-javac:jar:all:0.0.0-SNAPSHOT",
],
fail_on_missing_checksum = False,
repositories = [
"m2Local",
"https://repo1.maven.org/maven2",
],
)
use_repo(maven, "maven")
use_repo(maven, "maven", "local_maven")
14 changes: 13 additions & 1 deletion examples/bazel-example/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@ maven.install(
],
repositories = ["https://repo1.maven.org/maven2"],
)
use_repo(maven, "maven")

# This source-checkout example consumes scip-java's SNAPSHOT tool jars from
# m2Local. Run `mvn -DskipTests install` at the repository root first.
maven.install(
name = "local_maven",
fail_on_missing_checksum = False,
known_contributing_modules = ["scip_java"],
repositories = [
"m2Local",
"https://repo1.maven.org/maven2",
],
)
use_repo(maven, "maven", "local_maven")
Loading