Skip to content

Commit f63cb9f

Browse files
Shrey BanaShrey Bana
authored andcommitted
feat(java): Publishing to central-sonatype.
1 parent 984c436 commit f63cb9f

File tree

9 files changed

+233
-307
lines changed

9 files changed

+233
-307
lines changed

.github/workflows/java-cicd.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Java CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
# needs: build-and-test
14+
# if: github.event_name == 'workflow_dispatch'
15+
env:
16+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY }}
17+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY_PASSWORD }}
18+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_USERNAME }}
19+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.SONATYPE_MAVEN_PASSWORD }}
20+
defaults:
21+
run:
22+
working-directory: clients/java
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: '17'
32+
distribution: 'temurin'
33+
34+
- name: Make gradlew executable
35+
run: chmod +x gradlew
36+
37+
- name: Publish
38+
run: ./gradlew clean publish
39+
40+
- name: Deploy to Sonatype
41+
run: ./gradlew jreleaserDeploy
42+
# GRADLE_OPTS: >-
43+
# -DsonatypeUsername=${{ secrets.SONATYPE_MAVEN_USERNAME }}
44+
# -DsonatypePassword=${{ secrets.SONATYPE_MAVEN_PASSWORD }}
45+
# -DsigningKey=${{ secrets.SONATYPE_MAVEN_SIGNING_KEY }}
46+
# -DsigningPassword=${{ secrets.SONATYPE_MAVEN_SIGNING_KEY_PASSWORD }}
47+
48+
# build-and-test:
49+
# runs-on: ubuntu-latest
50+
# defaults:
51+
# run:
52+
# working-directory: clients/java
53+
54+
# steps:
55+
# - name: Checkout code
56+
# uses: actions/checkout@v4
57+
58+
# - name: Set up JDK 17
59+
# uses: actions/setup-java@v4
60+
# with:
61+
# java-version: '17'
62+
# distribution: 'temurin'
63+
64+
# - name: Make gradlew executable
65+
# run: chmod +x gradlew
66+
67+
# - name: Run Gradle assemble
68+
# run: ./gradlew assemble
69+
70+
# ## This requires more setup. Specifically, we need the server to be up w/
71+
# ## some dummy data.
72+
# # - name: Run tests
73+
# # run: ./gradlew test
74+
75+
# - name: Upload build artifacts
76+
# if: failure()
77+
# uses: actions/upload-artifact@v4
78+
# with:
79+
# name: build-reports
80+
# path: |
81+
# build/reports/
82+
# build/test-results/
83+
# retention-days: 7
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1-
import java.net.URL
2-
31
plugins {
4-
`maven-publish`
5-
`java-library`
2+
`java-library-conventions`
3+
`publishing-conventions`
64
kotlin("jvm") version "1.9.10"
75
}
86

9-
java {
10-
toolchain {
11-
languageVersion = JavaLanguageVersion.of(17)
12-
}
13-
}
7+
extra["displayName"] = "Superposition Foreign Function Interface"
8+
description = "Bindings for some of superpositions core functions."
149

1510
dependencies {
1611
implementation("org.jetbrains.kotlin:kotlin-stdlib")
1712
implementation("net.java.dev.jna:jna:5.13.0")
1813
}
19-
20-
21-
publishing {
22-
publications {
23-
create<MavenPublication>("maven") {
24-
from(components["kotlin"])
25-
}
26-
}
27-
}

clients/java/build.gradle.kts

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import org.jreleaser.model.Active
2+
3+
plugins {
4+
id("org.jreleaser") version "1.19.0"
5+
id("base")
6+
}
7+
18
allprojects {
29
group = "io.juspay.superposition"
310
version = System.getenv("VERSION") ?: "0.0.1-SNAPSHOT"
@@ -6,17 +13,49 @@ allprojects {
613
google()
714
gradlePluginPortal()
815
}
16+
}
17+
18+
/*
19+
* Jreleaser (https://jreleaser.org) config.
20+
*/
21+
jreleaser {
22+
dryrun = false
923

10-
apply(plugin = "maven-publish")
24+
// Used for creating a tagged release, uploading files and generating changelog.
25+
// In the future we can set this up to push release tags to GitHub, but for now it's
26+
// set up to do nothing.
27+
// https://jreleaser.org/guide/latest/reference/release/index.html
28+
release {
29+
generic {
30+
enabled = true
31+
skipRelease = true
32+
}
33+
}
34+
35+
// Used to announce a release to configured announcers.
36+
// https://jreleaser.org/guide/latest/reference/announce/index.html
37+
announce {
38+
active = Active.NEVER
39+
}
40+
41+
// Signing configuration.
42+
// https://jreleaser.org/guide/latest/reference/signing.html
43+
signing {
44+
active = Active.ALWAYS
45+
armored = true
46+
verify = false
47+
}
1148

12-
configure<PublishingExtension> {
13-
repositories {
14-
maven {
15-
name = "CodeArtifact"
16-
url = uri(System.getenv("CODEARTIFACT_REPOSITORY_ENDPOINT") ?: "https://non.existent.site.here")
17-
credentials {
18-
username = "aws"
19-
password = System.getenv("CODEARTIFACT_AUTH_TOKEN")
49+
// Configuration for deploying to Maven Central.
50+
// https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_gradle
51+
deploy {
52+
maven {
53+
mavenCentral {
54+
create("maven-central") {
55+
active = Active.ALWAYS
56+
url = "https://central.sonatype.com/api/v1/publisher"
57+
snapshotSupported = true
58+
stagingRepository(rootProject.layout.buildDirectory.dir("staging-deploy").get().asFile.path)
2059
}
2160
}
2261
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
mavenCentral()
8+
google()
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
`java-library`
3+
}
4+
5+
java {
6+
// Can't use this as provider is a mixed project.
7+
// withJavadocJar()
8+
withSourcesJar()
9+
toolchain {
10+
languageVersion.set(JavaLanguageVersion.of(17))
11+
}
12+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import org.gradle.api.publish.maven.MavenPublication
2+
import org.gradle.kotlin.dsl.extra
3+
import org.gradle.kotlin.dsl.provideDelegate
4+
5+
plugins {
6+
`maven-publish`
7+
signing
8+
}
9+
10+
publishing {
11+
// Add license spec to all maven publications
12+
publications {
13+
afterEvaluate {
14+
create<MavenPublication>("maven") {
15+
from(components["java"])
16+
val displayName: String by extra
17+
pom {
18+
name.set(displayName)
19+
description.set(project.description)
20+
url.set("https://github.com/juspay/superposition")
21+
licenses {
22+
license {
23+
name.set("Apache License 2.0")
24+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
25+
}
26+
}
27+
developers {
28+
developer {
29+
id.set("superposition")
30+
name.set("superposition")
31+
email.set("superposition@juspay.in")
32+
organization.set("Juspay")
33+
organizationUrl.set("https://juspay.io")
34+
roles.add("developer")
35+
}
36+
}
37+
scm {
38+
connection.set("https://github.com/juspay/superposition.git")
39+
developerConnection.set("https://github.com/juspay/superposition.git")
40+
url.set("https://github.com/juspay/superposition.git")
41+
}
42+
}
43+
}
44+
}
45+
}
46+
repositories {
47+
maven {
48+
url = uri(layout.buildDirectory.dir("staging-deploy"))
49+
}
50+
}
51+
}
52+
53+
signing {
54+
setRequired {
55+
// signing is required only if the artifacts are to be published to a maven repository
56+
gradle.taskGraph.allTasks.any { it is PublishToMavenRepository }
57+
}
58+
59+
// Don't sign the artifacts if we didn't get a key and password to use.
60+
if (project.hasProperty("signingKey") && project.hasProperty("signingPassword")) {
61+
signing {
62+
useInMemoryPgpKeys(
63+
project.properties["signingKey"].toString(),
64+
project.properties["signingPassword"].toString())
65+
sign(publishing.publications["maven"])
66+
}
67+
}
68+
}

clients/java/open-feature-provider/build.gradle.kts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
plugins {
2-
`java-library`
3-
`maven-publish`
2+
`java-library-conventions`
3+
`publishing-conventions`
44
kotlin("jvm") version "1.9.10"
55
id("io.freefair.lombok") version "8.6"
66
}
77

8-
java {
9-
toolchain {
10-
languageVersion = JavaLanguageVersion.of(17)
11-
}
12-
}
13-
14-
kotlin {
15-
jvmToolchain(17)
16-
}
8+
group = "${rootProject.group}.openfeature"
9+
extra["displayName"] = "Superposition Openfeature Provider"
10+
description = "Openfeature provider implementation for Superposition."
1711

1812
dependencies {
1913
implementation(project(":bindings"))
@@ -43,13 +37,3 @@ tasks.test {
4337
showStandardStreams = true
4438
}
4539
}
46-
47-
publishing {
48-
publications {
49-
create<MavenPublication>("maven") {
50-
groupId = "${rootProject.group}.openfeature"
51-
artifactId = "superposition-provider"
52-
from(components["java"])
53-
}
54-
}
55-
}

clients/java/sdk/build.gradle.kts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
plugins {
2-
`java-library`
3-
`maven-publish`
2+
`java-library-conventions`
3+
`publishing-conventions`
44
}
55

6-
java {
7-
toolchain {
8-
languageVersion = JavaLanguageVersion.of(17)
9-
}
10-
}
6+
extra["displayName"] = "Superposition SDK"
7+
description = "Java SDK for Superposition."
118

129
dependencies {
1310
implementation("software.amazon.smithy.java:client-core:0.0.1")
1411
implementation("software.amazon.smithy:smithy-aws-traits:1.55.0")
1512
implementation("software.amazon.smithy.java:aws-client-restjson:0.0.1")
1613
}
17-
18-
publishing {
19-
publications {
20-
create<MavenPublication>("maven") {
21-
from(components["java"])
22-
}
23-
}
24-
}

0 commit comments

Comments
 (0)