Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
a21fc50
feat(client): ensure compat with proguard
stainless-app[bot] Jul 29, 2025
6bf3387
feat: add retryable exception
stainless-app[bot] Jul 29, 2025
4d46e62
fix(client): r8 support
stainless-app[bot] Jul 31, 2025
ba337ee
chore(internal): reduce proguard ci logging
stainless-app[bot] Jul 31, 2025
c9b431a
chore(internal): bump ci test timeout
stainless-app[bot] Jul 31, 2025
337955a
codegen metadata
stainless-app[bot] Aug 29, 2025
d06f656
chore(internal): codegen related update
stainless-app[bot] Aug 29, 2025
32b3512
feat(api)!: define shared model ConversionRateConfig
stainless-app[bot] Sep 2, 2025
d43255b
feat(api): api update
stainless-app[bot] Sep 2, 2025
efc7891
fix(ci): use java-version 21 for publish step
stainless-app[bot] Sep 3, 2025
c89ade2
feat: extract minimum composite to type
stainless-app[bot] Sep 3, 2025
6180a95
feat(api): api update
stainless-app[bot] Sep 3, 2025
ee76ab8
feat(api): api update
stainless-app[bot] Sep 5, 2025
a790d45
feat(api): api update
stainless-app[bot] Sep 10, 2025
e2b7b1e
feat(api): api update
stainless-app[bot] Sep 12, 2025
1612dd1
fix(client): incorrect `getPackageVersion` impl
stainless-app[bot] Sep 15, 2025
f06d033
feat(api): api update
stainless-app[bot] Sep 16, 2025
1bc7983
feat(client): expose sleeper option
stainless-app[bot] Sep 19, 2025
d631c4d
feat(api): api update
stainless-app[bot] Sep 19, 2025
537aba1
chore(internal): change some comment formatting
stainless-app[bot] Sep 23, 2025
d4ef4ac
fix(client): deserialization of empty objects
stainless-app[bot] Sep 25, 2025
a05fab4
feat(api): api update
stainless-app[bot] Sep 29, 2025
db43b87
codegen metadata
stainless-app[bot] Sep 29, 2025
c4c96c6
feat(api): api update
stainless-app[bot] Sep 30, 2025
c427776
feat(api): api update
stainless-app[bot] Oct 3, 2025
a9326c1
feat(api): api update
stainless-app[bot] Oct 3, 2025
11cfcca
feat(api): api update
stainless-app[bot] Oct 6, 2025
4c2a026
feat(api): api update
stainless-app[bot] Oct 7, 2025
93761f0
feat(api): api update
stainless-app[bot] Oct 10, 2025
55ad4a4
codegen metadata
stainless-app[bot] Oct 10, 2025
6d42811
feat(api): api update
stainless-app[bot] Oct 13, 2025
0285f3a
feat(api): api update
stainless-app[bot] Oct 15, 2025
f47c49b
codegen metadata
stainless-app[bot] Oct 16, 2025
a58f47b
feat(api): api update
stainless-app[bot] Oct 17, 2025
f6987c9
feat(api): api update
stainless-app[bot] Oct 23, 2025
85206bc
codegen metadata
stainless-app[bot] Oct 27, 2025
1e5d30b
codegen metadata
stainless-app[bot] Oct 27, 2025
42c2d10
feat(api): api update
stainless-app[bot] Oct 29, 2025
83ad00c
feat(api): api update
stainless-app[bot] Oct 30, 2025
a1a92f4
feat(api): api update
stainless-app[bot] Oct 31, 2025
680265b
feat(api): api update
stainless-app[bot] Oct 31, 2025
9c2441e
feat(api): api update
stainless-app[bot] Nov 3, 2025
fd82100
feat(api): api update
stainless-app[bot] Nov 4, 2025
914623a
feat(api): api update
stainless-app[bot] Nov 5, 2025
25c6f8c
fix(schema): Rename unit price type to avoid naming conflict
stainless-app[bot] Dec 4, 2025
99993b1
feat(api): api update
stainless-app[bot] Nov 7, 2025
2eb59cf
feat(api): api update
stainless-app[bot] Nov 7, 2025
bdc7d3a
fix(client): multi-value header serialization
stainless-app[bot] Nov 13, 2025
0f366e8
feat(api): api update
stainless-app[bot] Nov 13, 2025
af8a41f
feat(api): api update
stainless-app[bot] Nov 16, 2025
74b29ea
feat(api): api update
stainless-app[bot] Nov 16, 2025
cfe2c88
feat(api): api update
stainless-app[bot] Nov 18, 2025
9d7a717
codegen metadata
stainless-app[bot] Nov 24, 2025
bbe220c
feat(api): api update
stainless-app[bot] Nov 25, 2025
012b348
feat(api): api update
stainless-app[bot] Dec 2, 2025
7e95cda
docs: remove `$` for better copy-pasteabality
stainless-app[bot] Dec 2, 2025
68203a3
feat(api): api update
stainless-app[bot] Dec 3, 2025
80b799e
codegen metadata
stainless-app[bot] Dec 4, 2025
e4e8d24
feat(api): api update
stainless-app[bot] Dec 6, 2025
936fe66
chore(internal): codegen related update
stainless-app[bot] Dec 11, 2025
9afda8f
codegen metadata
stainless-app[bot] Dec 12, 2025
b604e38
chore(internal): codegen related update
stainless-app[bot] Dec 17, 2025
3239df5
chore(internal): codegen related update
stainless-app[bot] Dec 17, 2025
6024a22
codegen metadata
stainless-app[bot] Dec 17, 2025
844eb52
chore(internal): codegen related update
stainless-app[bot] Dec 18, 2025
b0ad475
chore(internal): codegen related update
stainless-app[bot] Dec 18, 2025
a11d6c7
release: 1.12.0
stainless-app[bot] Dec 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 27 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

jobs:
lint:
timeout-minutes: 10
timeout-minutes: 15
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
Expand All @@ -36,8 +36,33 @@ jobs:

- name: Run lints
run: ./scripts/lint

build:
timeout-minutes: 15
name: build
runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork

steps:
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
8
21
cache: gradle

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build SDK
run: ./scripts/build

test:
timeout-minutes: 10
timeout-minutes: 15
name: test
runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
distribution: temurin
java-version: |
8
17
21
cache: gradle

- name: Set up Gradle
Expand All @@ -33,7 +33,7 @@ jobs:
export -- GPG_SIGNING_KEY_ID
printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD"
GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')"
./gradlew publishAndReleaseToMavenCentral -Dorg.gradle.jvmargs="-Xmx8g" --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache
./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache
env:
SONATYPE_USERNAME: ${{ secrets.ORB_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.ORB_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
.gradle
.idea
.kotlin
build
build/
codegen.log
kls_database.db
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.11.0"
".": "1.12.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 118
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-4f31d46f5ba187fc4d702c9f9f1573dacb891edbd086f935707578d7c4f5fed8.yml
openapi_spec_hash: 25b1019f20a47b8af665aae5f8fd0025
config_hash: 5135e9237207028f293049a77428c775
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-59c57f1cbc067a477f6bf673882c28065e01418b86fcff390bba0d4438c58105.yml
openapi_spec_hash: 4da2681664f766985d1c20df40240cd9
config_hash: 05c94c0e6dbeab2c9b554c2e0d6371a0
80 changes: 80 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,85 @@
# Changelog

## 1.12.0 (2025-12-18)

Full Changelog: [v1.11.0...v1.12.0](https://github.com/orbcorp/orb-kotlin/compare/v1.11.0...v1.12.0)

### ⚠ BREAKING CHANGES

* **api:** define shared model ConversionRateConfig

### Features

* add retryable exception ([6bf3387](https://github.com/orbcorp/orb-kotlin/commit/6bf3387e9efe151b2db48c51a454f4ac9abb03e1))
* **api:** api update ([e4e8d24](https://github.com/orbcorp/orb-kotlin/commit/e4e8d24b25879216965e7c55c5e23ab3bbbc69f8))
* **api:** api update ([68203a3](https://github.com/orbcorp/orb-kotlin/commit/68203a34d2c36b47aecb227b408452f65f4db572))
* **api:** api update ([012b348](https://github.com/orbcorp/orb-kotlin/commit/012b348959220609a650011f38e967b55aa6c906))
* **api:** api update ([bbe220c](https://github.com/orbcorp/orb-kotlin/commit/bbe220c8813cd6a5c491da043f0b39cffe06edca))
* **api:** api update ([cfe2c88](https://github.com/orbcorp/orb-kotlin/commit/cfe2c8868aead2144f69f0b04e304de948adbf8d))
* **api:** api update ([74b29ea](https://github.com/orbcorp/orb-kotlin/commit/74b29eac5934c4d52380859df2df42a5c6b8db46))
* **api:** api update ([af8a41f](https://github.com/orbcorp/orb-kotlin/commit/af8a41f71ca341c4ca6362158c555810a217ec49))
* **api:** api update ([0f366e8](https://github.com/orbcorp/orb-kotlin/commit/0f366e8c6196b679186999278cb93686eda3c6a9))
* **api:** api update ([2eb59cf](https://github.com/orbcorp/orb-kotlin/commit/2eb59cfcbe3b452746ef31a5f7c89f43276cffe5))
* **api:** api update ([99993b1](https://github.com/orbcorp/orb-kotlin/commit/99993b17f65917b21e1f87b14699f5ac5cb63e1e))
* **api:** api update ([914623a](https://github.com/orbcorp/orb-kotlin/commit/914623ae6f05e8ea28761331aba3b36676f10a99))
* **api:** api update ([fd82100](https://github.com/orbcorp/orb-kotlin/commit/fd821005e293869c0199d3d5261f3a806df74e41))
* **api:** api update ([9c2441e](https://github.com/orbcorp/orb-kotlin/commit/9c2441e3488e02d6e3f130dbbc1e1a9c821ac15d))
* **api:** api update ([680265b](https://github.com/orbcorp/orb-kotlin/commit/680265b0add2f0c05eee02f1410cda5d14bd758b))
* **api:** api update ([a1a92f4](https://github.com/orbcorp/orb-kotlin/commit/a1a92f48d35131e22f8e4e9ce51f6a31c8445277))
* **api:** api update ([83ad00c](https://github.com/orbcorp/orb-kotlin/commit/83ad00cb56d547e695b01e7e02e923247856f3c8))
* **api:** api update ([42c2d10](https://github.com/orbcorp/orb-kotlin/commit/42c2d10e801b46d82791cb26511cc237c5a9614a))
* **api:** api update ([f6987c9](https://github.com/orbcorp/orb-kotlin/commit/f6987c9fd19277bfdb124bf896a74584ae69090b))
* **api:** api update ([a58f47b](https://github.com/orbcorp/orb-kotlin/commit/a58f47b9e018a45680b2819cbc6ff9945779573d))
* **api:** api update ([0285f3a](https://github.com/orbcorp/orb-kotlin/commit/0285f3a1dd36ff49e345c862ac5dd8e714019df1))
* **api:** api update ([6d42811](https://github.com/orbcorp/orb-kotlin/commit/6d42811246f63cd57f9c2b9917a291ba9ef5b6ae))
* **api:** api update ([93761f0](https://github.com/orbcorp/orb-kotlin/commit/93761f0a10e3a553c7ca56701f746de784ee2516))
* **api:** api update ([4c2a026](https://github.com/orbcorp/orb-kotlin/commit/4c2a026cdd5327b5d58a42f2ae81975b5a8b6821))
* **api:** api update ([11cfcca](https://github.com/orbcorp/orb-kotlin/commit/11cfcca024a9abce1fbe8d3097c3d3aeb66eee34))
* **api:** api update ([a9326c1](https://github.com/orbcorp/orb-kotlin/commit/a9326c1fc925f51377493ccb1d50cdbcd444df07))
* **api:** api update ([c427776](https://github.com/orbcorp/orb-kotlin/commit/c427776d050d0cc71128bbd7c1f985bf70df342c))
* **api:** api update ([c4c96c6](https://github.com/orbcorp/orb-kotlin/commit/c4c96c6e42c74985376828b8efe6d03e0dcb91b5))
* **api:** api update ([a05fab4](https://github.com/orbcorp/orb-kotlin/commit/a05fab462983dba1d6c3755e1e1a65d24a527f60))
* **api:** api update ([d631c4d](https://github.com/orbcorp/orb-kotlin/commit/d631c4dd6dbf3657a11731eebdb772ed770ad154))
* **api:** api update ([f06d033](https://github.com/orbcorp/orb-kotlin/commit/f06d033e7331f839b77ae33d33b878be2c797e5f))
* **api:** api update ([e2b7b1e](https://github.com/orbcorp/orb-kotlin/commit/e2b7b1ee8a2594a363552c3289326b63a87112ec))
* **api:** api update ([a790d45](https://github.com/orbcorp/orb-kotlin/commit/a790d458789e5a7336dc8510510b593b0d36ce73))
* **api:** api update ([ee76ab8](https://github.com/orbcorp/orb-kotlin/commit/ee76ab871131d964501afbc390d2ba11595003bd))
* **api:** api update ([6180a95](https://github.com/orbcorp/orb-kotlin/commit/6180a95d21214a3bf90989d6a80e55cf2c066fc8))
* **api:** api update ([d43255b](https://github.com/orbcorp/orb-kotlin/commit/d43255b2f3030d1575c1c88898e1e1be202a13b6))
* **api:** define shared model ConversionRateConfig ([32b3512](https://github.com/orbcorp/orb-kotlin/commit/32b35124936f5fea58bf91d92313b242f0d56e97))
* **client:** ensure compat with proguard ([a21fc50](https://github.com/orbcorp/orb-kotlin/commit/a21fc50739926011c56bb30b47999d83bf7462e1))
* **client:** expose sleeper option ([1bc7983](https://github.com/orbcorp/orb-kotlin/commit/1bc798369b1883ba86b50ac4829ccb9f5331bca5))
* extract minimum composite to type ([c89ade2](https://github.com/orbcorp/orb-kotlin/commit/c89ade2708c48dfd327c4260ab1afe01e051e8c9))


### Bug Fixes

* **ci:** use java-version 21 for publish step ([efc7891](https://github.com/orbcorp/orb-kotlin/commit/efc789114af507dd96e591c18696a07dffad9af6))
* **client:** deserialization of empty objects ([d4ef4ac](https://github.com/orbcorp/orb-kotlin/commit/d4ef4acd10993041451835b56cf0d1ce4d145f71))
* **client:** ensure single timer is created per client ([1bc7983](https://github.com/orbcorp/orb-kotlin/commit/1bc798369b1883ba86b50ac4829ccb9f5331bca5))
* **client:** incorrect `getPackageVersion` impl ([1612dd1](https://github.com/orbcorp/orb-kotlin/commit/1612dd121630d64f7d0ba6cfad7807e38765eda3))
* **client:** multi-value header serialization ([bdc7d3a](https://github.com/orbcorp/orb-kotlin/commit/bdc7d3aa262fe9d79e9ce81dbc79b4ad7ac748eb))
* **client:** r8 support ([4d46e62](https://github.com/orbcorp/orb-kotlin/commit/4d46e6201e6bf0a1963f05e3982ecc97bcb9519c))
* **schema:** Rename unit price type to avoid naming conflict ([25c6f8c](https://github.com/orbcorp/orb-kotlin/commit/25c6f8c58010e5c2dd909f8161c8fee5465f2847))


### Chores

* **internal:** bump ci test timeout ([c9b431a](https://github.com/orbcorp/orb-kotlin/commit/c9b431af1e09f27dd08de5d1b247b72f70d160ae))
* **internal:** change some comment formatting ([537aba1](https://github.com/orbcorp/orb-kotlin/commit/537aba177c709243ce291115eb15e8c1fd0adfa4))
* **internal:** codegen related update ([b0ad475](https://github.com/orbcorp/orb-kotlin/commit/b0ad475dd5023f009b7d8a9a111a1b09c2e9f433))
* **internal:** codegen related update ([844eb52](https://github.com/orbcorp/orb-kotlin/commit/844eb52c3959f68a8c6230accf8e570edcd553e4))
* **internal:** codegen related update ([3239df5](https://github.com/orbcorp/orb-kotlin/commit/3239df52ca72a667fccc76f7bdf4799644b8322b))
* **internal:** codegen related update ([b604e38](https://github.com/orbcorp/orb-kotlin/commit/b604e38e11b64d22569de6c59c7e40c02e048b9e))
* **internal:** codegen related update ([936fe66](https://github.com/orbcorp/orb-kotlin/commit/936fe660fab9ecefb656d1db54b3288ec14fb235))
* **internal:** codegen related update ([d06f656](https://github.com/orbcorp/orb-kotlin/commit/d06f6564fcaeaf124295a7cc5db061e7092e4771))
* **internal:** reduce proguard ci logging ([ba337ee](https://github.com/orbcorp/orb-kotlin/commit/ba337ee683dea8296441855e1c5583c86bfa7f04))


### Documentation

* remove `$` for better copy-pasteabality ([7e95cda](https://github.com/orbcorp/orb-kotlin/commit/7e95cda57ad7eef980190010d8c68db1fb7f9eb3))

## 1.11.0 (2025-07-26)

Full Changelog: [v1.10.0...v1.11.0](https://github.com/orbcorp/orb-kotlin/compare/v1.10.0...v1.11.0)
Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-kotlin)](https://central.sonatype.com/artifact/com.withorb.api/orb-kotlin/1.11.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-kotlin)](https://central.sonatype.com/artifact/com.withorb.api/orb-kotlin/1.12.0)

<!-- x-release-please-end -->

Expand All @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho
### Gradle

```kotlin
implementation("com.withorb.api:orb-kotlin:1.11.0")
implementation("com.withorb.api:orb-kotlin:1.12.0")
```

### Maven
Expand All @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-kotlin:1.11.0")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-kotlin</artifactId>
<version>1.11.0</version>
<version>1.12.0</version>
</dependency>
```

Expand Down Expand Up @@ -229,6 +229,8 @@ The SDK throws custom unchecked exception types:

- [`OrbIoException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbIoException.kt): I/O networking errors.

- [`OrbRetryableException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt): Generic error indicating a failure that could be retried by the client.

- [`OrbInvalidDataException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.

- [`OrbException`](orb-kotlin-core/src/main/kotlin/com/withorb/api/errors/OrbException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.
Expand Down Expand Up @@ -293,13 +295,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square
Enable logging by setting the `ORB_LOG` environment variable to `info`:

```sh
$ export ORB_LOG=info
export ORB_LOG=info
```

Or to `debug` for more verbose logging:

```sh
$ export ORB_LOG=debug
export ORB_LOG=debug
```

## Webhook Verification
Expand All @@ -312,6 +314,12 @@ both of which will raise an error if the signature is invalid.
Note that the `body` parameter must be the raw JSON string sent from the server (do not parse it first).
The `.unwrap()` method can parse this JSON for you.

## ProGuard and R8

Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `orb-kotlin-core` is published with a [configuration file](orb-kotlin-core/src/main/resources/META-INF/proguard/orb-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).

ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.

## Jackson

The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.
Expand Down
14 changes: 13 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
allprojects {
group = "com.withorb.api"
version = "1.11.0" // x-release-please-version
version = "1.12.0" // x-release-please-version
}

subprojects {
// These are populated with dependencies by `buildSrc` scripts.
tasks.register("format") {
group = "Verification"
description = "Formats all source files."
}
tasks.register("lint") {
group = "Verification"
description = "Verifies all source files are formatted."
}
}
1 change: 0 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ repositories {
}

dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
}
94 changes: 83 additions & 11 deletions buildSrc/src/main/kotlin/orb.java.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
`java-library`
id("com.diffplug.spotless")
}

repositories {
mavenCentral()
}

configure<SpotlessExtension> {
java {
importOrder()
removeUnusedImports()
palantirJavaFormat()
toggleOffOn()
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
Expand Down Expand Up @@ -53,3 +42,86 @@ tasks.withType<Test>().configureEach {
exceptionFormat = TestExceptionFormat.FULL
}
}

val palantir by configurations.creating
dependencies {
palantir("com.palantir.javaformat:palantir-java-format:2.73.0")
}

fun registerPalantir(
name: String,
description: String,
) {
val javaName = "${name}Java"
tasks.register<JavaExec>(javaName) {
group = "Verification"
this.description = description

classpath = palantir
mainClass = "com.palantir.javaformat.java.Main"

// Avoid an `IllegalAccessError` on Java 9+.
jvmArgs(
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
)

// Use paths relative to the current module.
val argumentFile =
project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile
val lastRunTimeFile =
project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile

// Read the time when this task was last executed for this module (if ever).
val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L

// Use a `fileTree` relative to the module's source directory.
val javaFiles = project.fileTree("src") { include("**/*.java") }

// Determine if any files need to be formatted or linted and continue only if there is at least
// one file.
onlyIf { javaFiles.any { it.lastModified() > lastRunTime } }

inputs.files(javaFiles)

doFirst {
// Create the argument file and set the preferred formatting style.
argumentFile.parentFile.mkdirs()
argumentFile.writeText("--palantir\n")

if (name == "lint") {
// For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of
// the default 0) if any files need to be formatted, indicating that linting has failed.
argumentFile.appendText("--dry-run\n")
argumentFile.appendText("--set-exit-if-changed\n")
} else {
// `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive.
argumentFile.appendText("--replace\n")
}

// Write the modified files to the argument file.
javaFiles.filter { it.lastModified() > lastRunTime }
.forEach { argumentFile.appendText("${it.absolutePath}\n") }
}

doLast {
// Record the last execution time for later up-to-date checking.
lastRunTimeFile.writeText(System.currentTimeMillis().toString())
}

// Pass the argument file using the @ symbol
args = listOf("@${argumentFile.absolutePath}")

outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } }
}

tasks.named(name) {
dependsOn(tasks.named(javaName))
}
}

registerPalantir(name = "format", description = "Formats all Java source files.")
registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.")
Loading
Loading