Skip to content

Commit 8144be7

Browse files
Shrey BanaShrey Bana
authored andcommitted
feat(java): Publishing to central-sonatype.
1 parent ac646ab commit 8144be7

File tree

11 files changed

+138
-171
lines changed

11 files changed

+138
-171
lines changed

.github/workflows/ci_check_pr.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: CI Checks on PRs
22

33
on:
44
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
58

69
concurrency:
710
group: ${{ github.workflow }}-${{ github.ref }}
@@ -138,3 +141,41 @@ jobs:
138141
make test CI=1
139142
env:
140143
APP_ENV: "TEST"
144+
145+
java-build:
146+
name: Java build
147+
runs-on: ubuntu-latest
148+
defaults:
149+
run:
150+
working-directory: clients/java
151+
152+
steps:
153+
- name: Checkout code
154+
uses: actions/checkout@v4
155+
156+
- name: Set up JDK 17
157+
uses: actions/setup-java@v4
158+
with:
159+
java-version: '17'
160+
distribution: 'temurin'
161+
162+
- name: Make gradlew executable
163+
run: chmod +x gradlew
164+
165+
- name: Run Gradle assemble
166+
run: ./gradlew assemble
167+
168+
## This requires more setup. Specifically, we need the server to be up w/
169+
## some dummy data.
170+
# - name: Run tests
171+
# run: ./gradlew test
172+
173+
- name: Upload build artifacts
174+
if: failure()
175+
uses: actions/upload-artifact@v4
176+
with:
177+
name: build-reports
178+
path: |
179+
build/reports/
180+
build/test-results/
181+
retention-days: 7

.github/workflows/java-cicd.yaml

Lines changed: 0 additions & 103 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 25 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -289,29 +289,25 @@ jobs:
289289
if: github.ref == 'refs/heads/main'
290290
runs-on: ubuntu-latest
291291
env:
292-
VERSION: ${{ needs.tag-release.outputs.version }}
293-
AWS_REGION: ${{ vars.AWS_REGION }}
294-
CODEARTIFACT_DOMAIN: ${{ vars.CODEARTIFACT_DOMAIN }}
295-
CODEARTIFACT_REPOSITORY: ${{ vars.CODEARTIFACT_REPOSITORY }}
292+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY }}
293+
JRELEASER_GPG_PUBLIC_KEY: ${{ vars.SONATYPE_MAVEN_SIGNING_PUB_KEY }}
294+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY_PASSWORD }}
295+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_USERNAME }}
296+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.SONATYPE_MAVEN_PASSWORD }}
297+
VERSION: ${{ needs.tag-release.outputs.version }}
298+
defaults:
299+
run:
300+
working-directory: clients/java
301+
296302
steps:
297-
- name: Checkout repository
303+
- name: Checkout code
298304
uses: actions/checkout@v4
299-
with:
300-
fetch-depth: 0
301-
302-
- name: Configure AWS Credentials
303-
uses: aws-actions/configure-aws-credentials@v4.1.0
304-
with:
305-
audience: sts.amazonaws.com
306-
aws-region: ${{ env.AWS_REGION }}
307-
role-session-name: superposition-release
308-
role-to-assume: ${{ secrets.AWS_ARTIFACT_ROLE }}
309305

310-
- name: Install JDK 17
306+
- name: Set up JDK 17
311307
uses: actions/setup-java@v4
312308
with:
313-
java-version: "17"
314-
distribution: "temurin"
309+
java-version: '17'
310+
distribution: 'temurin'
315311

316312
- name: Download all rust binary artifacts
317313
uses: actions/download-artifact@v4
@@ -327,7 +323,7 @@ jobs:
327323
328324
- name: Extract and organize native libraries
329325
run: |
330-
mkdir -p clients/java/bindings/src/main/resources
326+
mkdir -p bindings/src/main/resources
331327
mkdir temp_extract
332328
# Extract all native libraries
333329
for zip_file in rust-binaries/*.zip; do
@@ -364,7 +360,7 @@ jobs:
364360
esac
365361
366362
# Create the platform-specific directory
367-
target_dir="clients/java/bindings/src/main/resources/$platform"
363+
target_dir="bindings/src/main/resources/$platform"
368364
mkdir -p "$target_dir"
369365
370366
# Copy the file
@@ -378,36 +374,16 @@ jobs:
378374
379375
# List what we have
380376
echo "Native libraries in bindings package:"
381-
ls -lar clients/java/bindings/src/main/resources/
377+
ls -lar bindings/src/main/resources/
382378
383-
- name: Configure CodeArtifact for Gradle
384-
run: |
385-
# Get CodeArtifact authorization token
386-
export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \
387-
--domain $CODEARTIFACT_DOMAIN \
388-
--query authorizationToken --output text)
379+
- name: Make gradlew executable
380+
run: chmod +x gradlew
389381

390-
# Get repository endpoint
391-
export CODEARTIFACT_REPOSITORY_ENDPOINT=$(aws codeartifact get-repository-endpoint \
392-
--domain $CODEARTIFACT_DOMAIN \
393-
--repository $CODEARTIFACT_REPOSITORY \
394-
--format maven --query repositoryEndpoint --output text)
382+
- name: Publish
383+
run: ./gradlew clean publish
395384

396-
echo "CODEARTIFACT_AUTH_TOKEN=$CODEARTIFACT_AUTH_TOKEN" >> $GITHUB_ENV
397-
echo "CODEARTIFACT_REPOSITORY_ENDPOINT=$CODEARTIFACT_REPOSITORY_ENDPOINT" >> $GITHUB_ENV
398-
399-
- name: Build Java packages
400-
run: |
401-
cd clients/java
402-
./gradlew build -x test
403-
404-
- name: Publish Java packages
405-
run: |
406-
cd clients/java
407-
./gradlew publish
408-
env:
409-
CODEARTIFACT_AUTH_TOKEN: ${{ env.CODEARTIFACT_AUTH_TOKEN }}
410-
CODEARTIFACT_REPOSITORY_ENDPOINT: ${{ env.CODEARTIFACT_REPOSITORY_ENDPOINT }}
385+
- name: Deploy to Sonatype
386+
run: ./gradlew jreleaserDeploy --info --stacktrace
411387

412388
generate-python-packages:
413389
needs: [tag-release, generate-rust-binary]
@@ -609,7 +585,7 @@ jobs:
609585
toolchain: 1.86.0
610586
targets: wasm32-unknown-unknown
611587
components: rustfmt, clippy, cargo
612-
588+
613589
- name: install cargo-edit to perform set-version
614590
uses: baptiste0928/cargo-install@v2.2.0
615591
with:
@@ -632,7 +608,7 @@ jobs:
632608
cargo publish --package superposition_types
633609
cargo publish --package superposition_core
634610
cargo publish --package superposition_provider
635-
611+
636612
release:
637613
needs: [tag-release, generate-rust-binary]
638614
runs-on: ubuntu-latest

clients/java/bindings/build.gradle.kts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
plugins {
2-
`java-library-conventions`
32
`publishing-conventions`
4-
kotlin("jvm") version "1.9.10"
3+
`kotlin-conventions`
4+
`java-library`
5+
}
6+
7+
java {
8+
withSourcesJar()
9+
toolchain {
10+
languageVersion.set(JavaLanguageVersion.of(17))
11+
}
512
}
613

714
extra["displayName"] = "Superposition Foreign Function Interface"

clients/java/build.gradle.kts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ allprojects {
1515
}
1616
}
1717

18+
configurations.all {
19+
resolutionStrategy {
20+
force(
21+
"com.fasterxml.jackson.core:jackson-core:2.16.0",
22+
"com.fasterxml.jackson:jackson-bom:2.16.0",
23+
"com.fasterxml.jackson.core:jackson-databind:2.16.0",
24+
"com.fasterxml.jackson.core:jackson-annotations:2.16.0"
25+
)
26+
}
27+
}
28+
1829
/*
1930
* Jreleaser (https://jreleaser.org) config.
2031
*/
@@ -55,7 +66,7 @@ jreleaser {
5566
active = Active.ALWAYS
5667
url = "https://central.sonatype.com/api/v1/publisher"
5768
snapshotSupported = true
58-
stagingRepository(rootProject.layout.buildDirectory.dir("staging-deploy").get().asFile.path)
69+
stagingRepository(rootProject.layout.buildDirectory.dir("m2").get().asFile.path)
5970
}
6071
}
6172
}

clients/java/buildSrc/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,16 @@ repositories {
77
mavenCentral()
88
google()
99
}
10+
11+
dependencies {
12+
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.10")
13+
implementation("org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:2.0.0")
14+
constraints {
15+
// org.owasp.dependencycheck needs at least this version of jackson. Other plugins pull in older versions..
16+
add("implementation", "com.fasterxml.jackson:jackson-bom:2.16.1")
17+
18+
// org.owasp.dependencycheck needs these versions. Other plugins pull in older versions..
19+
add("implementation", "org.apache.commons:commons-lang3:3.14.0")
20+
add("implementation", "org.apache.commons:commons-text:1.11.0")
21+
}
22+
}

clients/java/buildSrc/src/main/kotlin/java-library-conventions.gradle.kts

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
plugins {
2+
kotlin("jvm")
3+
id("org.jetbrains.dokka")
4+
}
5+
6+
kotlin {
7+
jvmToolchain(17)
8+
}
9+
10+
tasks.register<Jar>("dokkaJavadocJar") {
11+
dependsOn(tasks.dokkaJavadoc)
12+
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
13+
archiveClassifier.set("javadoc")
14+
}

clients/java/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ publishing {
1414
create<MavenPublication>("maven") {
1515
from(components["java"])
1616
val displayName: String by extra
17+
tasks.findByName("dokkaJavadocJar")?.let {
18+
artifact(it)
19+
}
1720
pom {
1821
name.set(displayName)
1922
description.set(project.description)
@@ -45,7 +48,7 @@ publishing {
4548
}
4649
repositories {
4750
maven {
48-
url = uri(layout.buildDirectory.dir("staging-deploy"))
51+
url = uri(rootProject.layout.buildDirectory.dir("m2"))
4952
}
5053
}
5154
}

0 commit comments

Comments
 (0)