Skip to content

Commit e4a6058

Browse files
committed
[DOP-18232] Replace SBT with Gradle
1 parent 338ead4 commit e4a6058

File tree

17 files changed

+546
-182
lines changed

17 files changed

+546
-182
lines changed

.bsp/sbt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"sbt","version":"1.8.3","bspVersion":"2.1.0-M1","languages":["scala"],"argv":["/home/maxim/.sdkman/candidates/java/11.0.22-tem/bin/java","-Xms100m","-Xmx100m","-classpath","/home/maxim/.sdkman/candidates/sbt/1.7.1/bin/sbt-launch.jar","-Dsbt.script=/home/maxim/.sdkman/candidates/sbt/current/bin/sbt","xsbt.boot.Boot","-bsp"]}

.github/workflows/codeql-check.yml

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,68 +18,17 @@ jobs:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020

21-
- name: Cache SBT
22-
uses: actions/cache@v3
23-
with:
24-
path: |
25-
~/.ivy2/cache
26-
~/.sbt
27-
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
28-
29-
- name: Setup JDK 8
21+
- name: Setup JDK 11
3022
uses: actions/setup-java@v4
3123
with:
32-
java-version: '8'
24+
java-version: '11'
3325
distribution: 'temurin'
3426

35-
- name: Setup Scala and SBT
36-
uses: olafurpg/setup-scala@v14
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v3
3729
with:
38-
java-version: '8'
39-
40-
- name: Check and format code with Scalafmt
41-
run: sbt scalafmtAll
30+
cache-read-only: false
31+
cache-overwrite-existing: true
4232

43-
- name: Check and fix code with Scalafix
44-
run: sbt scalafixAll
45-
46-
- name: Check for changes and commit
47-
id: git-check
48-
run: |
49-
if [ -n "$(git status --porcelain | grep -v '^??')" ]; then
50-
echo "changes=true" >> $GITHUB_ENV # Use environment file to set output
51-
git config --global user.name 'GitHub Actions Bot'
52-
git config --global user.email '[email protected]'
53-
git add -u
54-
git commit -m "Apply code quality checks (auto-formatted)"
55-
git fetch --prune
56-
git pull --rebase origin ${{ github.head_ref }}
57-
git push origin HEAD:${{ github.head_ref }}
58-
else
59-
echo "No changes to commit."
60-
fi
61-
env:
62-
CI: true
63-
64-
- name: Post retry comment
65-
if: env.changes == 'true'
66-
uses: actions/github-script@v7
67-
with:
68-
script: |
69-
const prNumber = context.payload.pull_request ? context.payload.pull_request.number : null;
70-
if (prNumber) {
71-
const { data: pr } = await github.rest.pulls.get({
72-
owner: context.repo.owner,
73-
repo: context.repo.repo,
74-
pull_number: prNumber,
75-
});
76-
const newBody = pr.body + '\n\nAuto-commit applied. A retry was triggered due to a failure in formatting/linting checks.';
77-
await github.rest.pulls.update({
78-
owner: context.repo.owner,
79-
repo: context.repo.repo,
80-
pull_number: prNumber,
81-
body: newBody
82-
});
83-
} else {
84-
console.log('No pull request context found, unable to update PR description.');
85-
}
33+
- name: Run all checks
34+
run: ./gradlew checkScalafix checkScalafmtAll

.github/workflows/release.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,32 @@ on:
66
jobs:
77
publish:
88
runs-on: ubuntu-latest
9+
if: github.repository == 'MobileTeleSystems/spark-dialect-extension' # prevent running on forks
10+
911
steps:
1012
- uses: actions/checkout@v4
1113
with:
1214
fetch-depth: 0
1315

14-
- uses: actions/setup-java@v4
16+
- name: Setup JDK 11
17+
uses: actions/setup-java@v4
1518
with:
16-
distribution: temurin
17-
java-version: 8
18-
cache: sbt
19+
java-version: '11'
20+
distribution: 'temurin'
1921

20-
- name: Cache SBT
21-
uses: actions/cache@v3
22-
with:
23-
path: |
24-
~/.ivy2/cache
25-
~/.sbt
26-
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v3
24+
25+
- run: ./gradlew jar sourcesJar scaladocJar
2726

28-
- run: sbt ci-release
27+
- run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
2928
env:
30-
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
31-
PGP_SECRET: ${{ secrets.PGP_SECRET }}
32-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
33-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
29+
# https://vanniktech.github.io/gradle-maven-publish-plugin/central/#in-memory-gpg-key
30+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_PASSWORD }}
31+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_USERNAME }}
32+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_PASSPHRASE }}
33+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_PUBLIC_KEY_ID_SHORT }}
34+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
3435

3536
- name: Create Github release
3637
id: create_release
@@ -41,4 +42,4 @@ jobs:
4142
prerelease: false
4243
token: ${{ secrets.GITHUB_TOKEN }}
4344
files: |
44-
target/scala-2.12/*.jar
45+
build/libs/*.jar

.github/workflows/tests_clickhouse.yml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,28 @@ jobs:
2424
- name: Checkout code
2525
uses: actions/checkout@v4
2626

27-
- name: Cache SBT
28-
uses: actions/cache@v3
29-
with:
30-
path: |
31-
~/.ivy2/cache
32-
~/.sbt
33-
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
34-
35-
- name: Setup JDK 8
27+
- name: Setup JDK 11
3628
uses: actions/setup-java@v4
3729
with:
38-
java-version: '8'
30+
java-version: '11'
3931
distribution: 'temurin'
4032

41-
- name: Setup Scala and SBT
42-
uses: olafurpg/setup-scala@v14
43-
with:
44-
java-version: '8'
33+
- name: Setup Gradle
34+
uses: gradle/actions/setup-gradle@v3
4535

46-
- name: Compile .jar package with SBT
47-
run: |
48-
sbt package
36+
- name: Setup Gradle
37+
uses: gradle/actions/setup-gradle@v3
38+
with:
39+
cache-read-only: false
40+
cache-overwrite-existing: true
4941

5042
- name: Run Integration Tests with Coverage
5143
run: |
52-
sbt clean coverage test coverageReport
44+
./gradlew test
5345
5446
- name: Upload Coverage to Codecov
5547
uses: codecov/codecov-action@v4
5648
with:
5749
token: ${{ secrets.CODECOV_TOKEN }}
58-
files: target/scala-2.12/scoverage-report/scoverage.xml
50+
files: build/reports/jacoco/test/*.xml
5951
fail_ci_if_error: true

.gitignore

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@
33
*.log
44
*~
55

6-
# sbt specific
7-
dist/*
8-
target/
9-
lib_managed/
10-
src_managed/
11-
project/boot/
12-
project/plugins/project/
13-
project/local-plugins.sbt
14-
.history
15-
.bsp
16-
.metals
17-
.bloop
18-
196
# Scala-IDE specific
207
.scala_dependencies
218
.cache
@@ -35,3 +22,7 @@ classes/
3522

3623
# Visual Studio Code
3724
.vscode
25+
26+
# Gradle-specific
27+
.gradle/
28+
build/

CONTRIBUTING.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ This document provides detailed steps to build the Spark Dialect Extension from
66

77
Before you start, ensure you have the following installed:
88
- **Java**: Java 8 or higher. [Java Installation Guide](https://adoptopenjdk.net/)
9-
- **Scala**: [Scala Installation Guide](https://scala-lang.org/download/)
10-
- **SBT**: [SBT Installation Guide](https://www.scala-sbt.org/download.html)
9+
- **Gradle**: [Gradle Installation Guide](https://docs.gradle.org/current/userguide/installation.html)
1110

1211
### Compile the Project
1312

1413
To compile the project and generate a JAR file, run the following command in the project's root directory:
1514

1615
```bash
17-
sbt package
16+
./gradlew crossBuildV212Jar crossBuildV213Jar
1817
```
1918

20-
This command compiles the source code and packages it into a .jar file located in the ``target/scala-2.12`` directory.
19+
This command compiles the source code and packages it into a .jar files located in the ``build/libs`` directory.
2120

2221

2322
## Running Scala Tests
@@ -33,20 +32,14 @@ docker-compose -f docker-compose.test.yml up -d
3332
```
3433

3534
### Execute Tests
36-
To run the Scala tests, execute:
3735

38-
```bash
39-
sbt test
40-
```
41-
42-
### With Coverage Report
43-
To run the tests with coverage and generate a report, use:
36+
To run the Scala tests, execute:
4437

4538
```bash
46-
sbt clean coverage test coverageReport
39+
./gradlew test
4740
```
4841

49-
After the tests, you can view the coverage report by opening the ``target/scala-2.12/scoverage-report/index.html`` file in your web browser.
42+
After the tests, you can view the coverage report by opening the ``build/reports/tests/test/index.html`` file in your web browser.
5043

5144
### Stopping Docker Containers
5245
After completing the tests, you can stop the Docker containers with:
@@ -61,14 +54,14 @@ docker-compose -f docker-compose.test.yml down
6154

6255
To format all Scala source files in the project, execute the following command from the project's root directory:
6356
```bash
64-
sbt scalafmtAll
57+
./gradlew scalafmtAll
6558
```
6659

6760
## Using Scalafix for Linting and Refactoring
6861

6962
To lint and refactor the code, run Scalafix using the following command:
7063
```bash
71-
sbt scalafixAll
64+
./gradlew scalafix
7265
```
7366
This command checks the code against various rules specified in the ```.scalafix.conf``` file and applies fixes where possible.
7467

@@ -86,7 +79,7 @@ git pull -p
8679
2. Copy version (it must start with **v**, e.g. **v1.0.0**)
8780

8881
```bash
89-
VERSION=$(cat VERSION)
82+
VERSION=$(./gradlew -q printVersion)
9083
```
9184

9285
3. Commit and push changes to ``develop`` branch
@@ -118,7 +111,7 @@ git push origin "$VERSION"
118111
```bash
119112
git checkout develop
120113
NEXT_VERSION=$(echo "$VERSION" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
121-
echo "$NEXT_VERSION" > VERSION
114+
sed -i "s/version = \".*\"/version = \"$NEXT_VERSION\"/" build.gradle
122115
git add .
123116
git commit -m "Bump version"
124117
git push

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)