Skip to content

Commit 29ed2c7

Browse files
committed
Add Java formatting tasks and CI check
1 parent 19ee45c commit 29ed2c7

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ permissions:
99
contents: read
1010

1111
jobs:
12+
format:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: zulu
20+
java-version: '17'
21+
- name: Set up Gradle
22+
uses: gradle/actions/setup-gradle@v4
23+
- name: Check Java formatting
24+
run: ./gradlew formatCheck
25+
1226
build:
1327
runs-on: ubuntu-latest
1428
steps:

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ Run `./gradlew publishToMavenLocal` to publish all three artifacts to your local
3838
Maven repository, using the version from the `artifacts/` configuration files.
3939
The published class files target Java 7, matching earlier SoLoader releases.
4040

41+
## Formatting Java sources
42+
43+
From this directory, run `./gradlew format` to format all Java sources, or
44+
`./gradlew formatCheck` to check them without making changes. Both commands work
45+
in a standalone checkout or in `fbsource/fbandroid/libraries/soloader` and use a
46+
pinned Google Java Format version downloaded by Gradle. No formatter binary is
47+
stored in the repository.
48+
4149
The existing [Buck](https://buckbuild.com/) build is also available. Once you have
4250
Buck installed, run the following commands from the project root directory:
4351
```shell

‎build.gradle‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
plugins {
22
id 'com.android.library' version '9.2.1' apply false
3+
id 'com.diffplug.spotless' version '8.0.0'
4+
}
5+
6+
spotless {
7+
java {
8+
target 'java/**/*.java'
9+
googleJavaFormat('1.25.2')
10+
}
11+
}
12+
13+
tasks.register('format') {
14+
group = 'formatting'
15+
description = 'Format all SoLoader Java sources.'
16+
dependsOn 'spotlessApply'
17+
}
18+
19+
tasks.register('formatCheck') {
20+
group = 'verification'
21+
description = 'Check formatting of all SoLoader Java sources.'
22+
dependsOn 'spotlessCheck'
323
}
424

525
def artifactVersions = ['ANNOTATION', 'NATIVELOADER', 'SOLOADER'].collect { artifact ->

0 commit comments

Comments
 (0)