Skip to content

Commit 70f834e

Browse files
committed
Migrate build to Gradle
1 parent dddc6c5 commit 70f834e

22 files changed

Lines changed: 741 additions & 544 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: DeterminateSystems/magic-nix-cache-action@v13
2323

2424
- name: Main project tests
25-
run: nix develop .#jdk${{ matrix.java }} --command sbt test
25+
run: nix develop .#jdk${{ matrix.java }} --command gradle test --no-daemon
2626

2727
docker_test:
2828
runs-on: ubuntu-latest
@@ -83,8 +83,8 @@ jobs:
8383

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

86-
- run: nix develop --command sbt cli/pack
87-
- run: echo "$PWD/scip-java/target/pack/bin" >> "$GITHUB_PATH"
86+
- run: nix develop --command gradle :scip-java:installDist --no-daemon
87+
- run: echo "$PWD/scip-java/build/install/scip-java/bin" >> "$GITHUB_PATH"
8888
- name: Auto-index scip-java codebase
8989
run: |
9090
# shellcheck disable=SC2016
@@ -113,10 +113,10 @@ jobs:
113113
- uses: DeterminateSystems/magic-nix-cache-action@v13
114114

115115
- name: scip-kotlinc tests
116-
run: nix develop --command sbt scipKotlinc/test
116+
run: nix develop --command gradle :scip-kotlinc:test --no-daemon
117117

118118
- name: Regenerate snapshots
119-
run: nix develop --command sbt scipSnapshots/run
119+
run: nix develop --command gradle :scip-snapshots:saveSnapshots --no-daemon
120120

121121
- name: Check snapshot drift
122122
run: |
@@ -141,13 +141,13 @@ jobs:
141141

142142
- run: |
143143
nix develop .#jdk${{ matrix.java }} --command \
144-
sbt --error cli/pack publishM2 publishLocal
144+
gradle --no-daemon :scip-java:installDist publishToMavenLocal
145145
SCIP_JAVA_VERSION="$(
146-
sed -n 's/^version:=//p' scip-java/target/pack/VERSION
146+
sed -n 's/^version:=//p' scip-java/build/install/scip-java/VERSION
147147
)"
148148
test -n "$SCIP_JAVA_VERSION"
149149
printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$GITHUB_ENV"
150-
printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/target/pack/bin/scip-java" >> "$GITHUB_ENV"
150+
printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/build/install/scip-java/bin/scip-java" >> "$GITHUB_ENV"
151151
152152
- run: |
153153
nix develop "$GITHUB_WORKSPACE#jdk${{ matrix.java }}" --command \

.github/workflows/release-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
cd "$OUT_DIR"
3838
3939
VERSION=${VERSION#v}
40-
ARTIFACT="com.sourcegraph:scip-java_2.13:${VERSION}"
40+
ARTIFACT="com.sourcegraph:scip-java:${VERSION}"
4141
4242
for attempt in {1..10}; do
4343
if cs resolve "$ARTIFACT" >/dev/null 2>&1; then

.github/workflows/release-maven.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,20 @@ jobs:
1515
with:
1616
summarize: false
1717
- uses: DeterminateSystems/magic-nix-cache-action@v13
18-
- name: Publish ${{ github.ref }}
19-
run: nix develop --command sbt ci-release
18+
- name: Publish snapshot ${{ github.ref }}
19+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
20+
run: nix develop --command gradle --no-daemon publishToSonatype
21+
env:
22+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
23+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
24+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
25+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
26+
- name: Publish release ${{ github.ref }}
27+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
28+
run: |
29+
version="${GITHUB_REF_NAME#v}"
30+
nix develop --command env VERSION="$version" \
31+
gradle --no-daemon publishToSonatype closeAndReleaseSonatypeStagingRepository
2032
env:
2133
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
2234
PGP_SECRET: ${{ secrets.PGP_SECRET }}

.gitignore

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
result
66
result-*
77

8-
# sbt specific
8+
# build tool output
9+
.gradle/
10+
build/
911
.cache
1012
.history
1113
.lib/
1214
dist/*
1315
target/
1416
lib_managed/
1517
src_managed/
16-
project/boot/
17-
project/plugins/project/
1818
.bloop
1919

2020
_site/
@@ -79,7 +79,3 @@ scip-snapshots/META-INF/
7979
# writes META-INF/scip/sources/Test.kt.scip relative to the test
8080
# cwd.
8181
scip-kotlinc/META-INF/
82-
83-
# Standard sbt project metadata directories.
84-
project/target/
85-
project/project/

CONTRIBUTING.md

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ nix develop .#jdk17 # JDK 17
1414
nix develop .#jdk21 # JDK 21
1515
```
1616

17-
This drops you into a shell with `sbt`, `maven`, `gradle`, `bazelisk`,
18-
`nodejs`, `yarn`, `git`, `jq`, etc. all pinned to the versions used in CI.
17+
This drops you into a shell with `gradle`, `maven`, `bazelisk`, `nodejs`,
18+
`yarn`, `git`, `jq`, etc. all pinned to the versions used in CI.
1919

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

@@ -43,25 +43,23 @@ These are the main components of the project.
4343
interface.
4444
- `scip-java/src/test`: build-tool integration tests and fixtures for the
4545
`scip-java` command-line interface.
46-
- `build.sbt`: the sbt build definition.
47-
- `project/plugins.sbt`: plugins for the sbt build.
46+
- `settings.gradle.kts`: Gradle project layout.
47+
- `build.gradle.kts`: Gradle build definition.
48+
- `gradle/libs.versions.toml`: dependency and plugin versions.
4849

4950
## Helpful commands
5051

51-
| Command | Where | Description |
52-
| ------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------- |
53-
| `sbt` | terminal | Start interactive sbt shell with Java 11 (run from `nix develop`). Takes a while to load on the first run. |
54-
| `unit/test` | sbt | Run fast unit tests. |
55-
| `~unit/test` | sbt | Start watch mode to run tests on file save, good for local edit-and-test workflows. |
56-
| `cli/test` | sbt | Run slow build tool tests (Gradle, Maven). |
57-
| `snapshots/testOnly tests.MinimizedSnapshotScipTest` | sbt | Runs fast snapshot tests. Indexes a small set of files under `tests/minimized`. |
58-
| `snapshots/test` | sbt | Runs all snapshot tests. |
59-
| `snapshots/run` | sbt | Update only the Java snapshot goldens under `tests/snapshots`. |
60-
| `scipKotlincMinimized/kotlincSnapshots` | sbt | Update only the Kotlin snapshot goldens under `scip-kotlinc/minimized`. |
61-
| `regenerateSnapshots` | sbt | Regenerate ALL snapshot goldens (Java + Kotlin). Run after fixing a bug. |
62-
| `cli/run --cwd DIRECTORY` | sbt | Run `scip-java` command-line tool against a given Gradle/Maven build. |
63-
| `google-java-format --replace $(git ls-files '*.java')` | terminal | Format Java sources (from `nix develop`). Enforced by `nix flake check`. |
64-
| `ktfmt --kotlinlang-style $(git ls-files '*.kt')` | terminal | Format Kotlin sources (from `nix develop`). Enforced by `nix flake check`. |
52+
| Command | Where | Description |
53+
| ------------------------------------------------------- | -------- | ----------------------------------------------------------------------- |
54+
| `gradle test --no-daemon` | terminal | Run all Gradle tests. |
55+
| `gradle :scip-java:test --no-daemon` | terminal | Run CLI build-tool integration tests (Gradle, Maven, SCIP config). |
56+
| `gradle :scip-kotlinc:test --no-daemon` | terminal | Run Kotlin compiler-plugin tests. |
57+
| `gradle :scip-snapshots:test --no-daemon` | terminal | Compare Java and Kotlin snapshot goldens. |
58+
| `gradle :scip-snapshots:saveSnapshots --no-daemon` | terminal | Regenerate Java and Kotlin snapshot goldens. |
59+
| `gradle :scip-java:installDist --no-daemon` | terminal | Build a local `scip-java` distribution under `scip-java/build/install/`. |
60+
| `gradle :scip-java:run --args='--cwd DIRECTORY'` | terminal | Run `scip-java` against a given Gradle/Maven build. |
61+
| `google-java-format --replace $(git ls-files '*.java')` | terminal | Format Java sources (from `nix develop`). Enforced by `nix flake check`. |
62+
| `ktfmt --kotlinlang-style $(git ls-files '*.kt')` | terminal | Format Kotlin sources (from `nix develop`). Enforced by `nix flake check`. |
6563

6664
## Import the project into IntelliJ
6765

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

83-
Finally, run "File > Project From Existing Sources" to import the sbt build into
84-
IntelliJ. Select the "sbt" option if it asks you to choose between
85-
sbt/BSP/Bloop.
81+
Finally, run "File > Project From Existing Sources" to import the Gradle build
82+
into IntelliJ. Select the "Gradle" option if it asks you to choose a build
83+
model.
8684

87-
It's best to run tests from the sbt shell, not from the IntelliJ UI.
85+
It's best to run tests from Gradle, not from the IntelliJ UI.
8886

8987
## Tests are written in Java with JUnit 5
9088

91-
The unit tests (`tests/unit`) and snapshot tests (`tests/snapshots`) are plain
92-
Java using [JUnit 5](https://junit.org/junit5/), wired into sbt via
93-
[sbt-jupiter-interface](https://github.com/sbt/sbt-jupiter-interface). The
94-
snapshot suite is a JUnit `@TestFactory` that emits one dynamic test per
95-
generated document, comparing it against the committed goldens under
96-
`tests/snapshots/src/main/generated`
97-
([snapshot testing](https://jestjs.io/docs/en/snapshot-testing) is heavily used
98-
in this codebase). Build-tool tests (`scip-java/src/test`) are written in
99-
Kotlin.
89+
The Java tests use [JUnit 5](https://junit.org/junit5/) through Gradle's JUnit
90+
Platform support. The snapshot suite is a JUnit `@TestFactory` that emits one
91+
dynamic test per generated document, comparing it against the committed goldens
92+
under `scip-snapshots/expected`. Build-tool tests (`scip-java/src/test`) are
93+
written in Kotlin.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN git config --global --add safe.directory *
1717

1818
COPY . .
1919

20-
RUN sbt cli/pack && mkdir -p /app/scip-java && cp -R scip-java/target/pack/. /app/scip-java/
20+
RUN gradle --no-daemon :scip-java:installDist && mkdir -p /app/scip-java && cp -R scip-java/build/install/scip-java/. /app/scip-java/
2121

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

bin/docker-setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ set -eux
33
curl -fLo /usr/local/bin/cs https://github.com/coursier/coursier/releases/download/v2.1.5/coursier
44
chmod +x /usr/local/bin/cs
55
ln -sf /usr/local/bin/cs /usr/local/bin/coursier
6-
cs setup --yes --apps cs,coursier,sbt
6+
cs setup --yes --apps cs,coursier
77

88
curl -fLo maven.zip https://archive.apache.org/dist/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.zip
99
unzip -d /opt/maven maven.zip
1010
rm maven.zip
1111
mv /opt/maven/*/* /opt/maven
1212

13-
curl -fLo gradle.zip https://services.gradle.org/distributions/gradle-7.6.1-bin.zip
13+
curl -fLo gradle.zip https://services.gradle.org/distributions/gradle-8.10-bin.zip
1414
unzip -d /opt/gradle gradle.zip
1515
rm gradle.zip
1616
mv /opt/gradle/*/* /opt/gradle

0 commit comments

Comments
 (0)