Skip to content

Commit 5496edb

Browse files
authored
chore: Move DTOs to sdk-common-jvm shared lib (#58)
* chore: Move DTOs to sdk-common-jvm dep * project builds * add test cases * cleanup more stuff * all tests pass * spotless * test * test2 * remove * use dep from jitpack * version bump * use official artifacts now * fix gradle config * fix artifact id * add project credentials * version bump * fix moved method * remove unneeded deps * remove test cases * fix spotless for CI * remove more test cases * configure github actions for releasing * fix CI * make test-data * fix is CI check * only publish snapshots on push to main * small nit * set version to 2.5.0
1 parent 5ccfe02 commit 5496edb

File tree

77 files changed

+2563
-3540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2563
-3540
lines changed

.github/workflows/lint-test-sdk.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
paths:
66
- '**/*'
77

8+
env:
9+
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
10+
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
11+
CI: true
12+
813
jobs:
914
lint-test-sdk:
1015
runs-on: ubuntu-latest
@@ -13,6 +18,8 @@ jobs:
1318
java-version: ['8', '11', '17'] # Define the Java versions to test against
1419
steps:
1520
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
1623

1724
- name: Set up JDK ${{ matrix.java-version }}
1825
uses: actions/setup-java@v4
@@ -21,4 +28,4 @@ jobs:
2128
distribution: 'adopt'
2229

2330
- name: Run tests
24-
run: make test
31+
run: make test-data && ./gradlew check --no-daemon --stacktrace

.github/workflows/publish-sdk.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
name: Publish JAVA sdk to the Maven Central Repository
1+
name: Publish SDK to the Maven Central Repository
2+
23
on:
34
release:
45
types: [published]
6+
7+
env:
8+
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
9+
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
10+
CI: true
11+
512
jobs:
613
publish:
714
runs-on: ubuntu-latest
@@ -14,24 +21,14 @@ jobs:
1421
java-version: '8'
1522
distribution: 'temurin'
1623
server-id: ossrh
17-
server-username: MAVEN_USERNAME
18-
server-password: MAVEN_PASSWORD
1924
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
20-
gpg-passphrase: GPG_PASSPHRASE
25+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
2126

2227
- name: Download test data
2328
run: make test-data
2429

25-
- name: Publish package with debug logging
26-
run: mvn --batch-mode deploy -X
27-
env:
28-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
29-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
30-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
31-
32-
- name: Release the staging repository
33-
run: mvn nexus-staging:release -X
30+
- name: Publish package to Maven Central
31+
run: ./gradlew check publish --no-daemon
3432
env:
35-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
36-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
33+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
3734
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish SDK Snapshot artifact
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
env:
8+
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
9+
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
10+
CI: true
11+
12+
jobs:
13+
publish-snapshot:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: 17
24+
distribution: 'adopt'
25+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
26+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
27+
28+
- name: Publish Snapshot artifact
29+
run: make test-data && ./gradlew check publish --no-daemon --stacktrace
30+
env:
31+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
32+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.gitignore

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
# Shared test files
2-
src/test/resources/assignment-v2
3-
src/test/resources/rac-experiments-v3.json
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
46

57
### IntelliJ IDEA ###
8+
.idea/modules.xml
9+
.idea/jarRepositories.xml
10+
.idea/compiler.xml
11+
.idea/libraries/
12+
*.iws
613
*.iml
7-
.idea/
14+
*.ipr
815
out/
9-
target/
1016
!**/src/main/**/out/
1117
!**/src/test/**/out/
1218

@@ -33,4 +39,7 @@ bin/
3339
.vscode/
3440

3541
### Mac OS ###
36-
.DS_Store
42+
.DS_Store
43+
.idea/
44+
src/test/resources/assignment-v2/
45+
src/test/resources/rac-experiments-v3.json

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ help: Makefile
2626

2727
.PHONY: build
2828
build: test-data
29-
mvn --batch-mode --update-snapshots package
29+
./gradlew assemble
3030

3131
## test-data
3232
testDataDir := src/test/resources
@@ -47,4 +47,4 @@ test-data:
4747

4848
.PHONY: test
4949
test: test-data build
50-
mvn test
50+
./gradlew check

README.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,60 @@
11
# Eppo Server-Side SDK for Java
22

3-
## Getting Started
3+
## Usage
44

5-
Refer to our [SDK documentation](https://docs.geteppo.com/feature-flags/sdks/server-sdks/java) for how to install and use the SDK.
5+
### build.gradle:
6+
7+
```groovy
8+
dependencies {
9+
implementation 'cloud.eppo:eppo-server-sdk:2.0.0'
10+
}
11+
```
12+
13+
Refer to our [SDK documentation](https://docs.geteppo.com/sdks/server-sdks/java/) for how to install and use the SDK.
614

715
## Contributing
816

9-
A version of Java 8 is required to locally compile the SDK.
17+
Java 8 is required to locally compile the SDK.
1018

1119
### Apple M-Series
1220

1321
Download a `arm64` compatible build: https://www.azul.com/downloads/?version=java-8-lts&architecture=arm-64-bit&package=jdk#zulu
22+
23+
## Releasing a new version
24+
25+
For publishing a release locally, follow the steps below.
26+
27+
### Prerequisites
28+
29+
1. [Generate a user token](https://central.sonatype.org/publish/generate-token/) on `s01.oss.sonatype.org`;
30+
2. [Configure a GPG key](https://central.sonatype.org/publish/requirements/gpg/) for signing the artifact. Don't forget to upload it to the key server;
31+
3. Make sure you have the following vars in your `~/.gradle/gradle.properties` file:
32+
1. `ossrhUsername` - User token username for Sonatype generated in step 1
33+
2. `ossrhPassword` - User token password for Sonatype generated in step 1
34+
3. `signing.keyId` - GPG key ID generated in step 2
35+
4. `signing.password` - GPG key password generated in step 2
36+
5. `signing.secretKeyRingFile` - Path to GPG key file generated in step 2
37+
38+
Once you have the prerequisites, follow the steps below to release a new version:
39+
40+
1. Bump the project version in `build.gradle`
41+
2. Run `./gradlew publish`
42+
3. Follow the steps in [this page](https://central.sonatype.org/publish/release/#credentials) to promote your release
43+
44+
## Using Snapshots
45+
46+
If you would like to live on the bleeding edge, you can try running against a snapshot build. Keep in mind that snapshots
47+
represent the most recent changes on master and may contain bugs.
48+
Snapshots are published automatically after each push to `main` branch.
49+
50+
### build.gradle:
51+
52+
```groovy
53+
repositories {
54+
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots" }
55+
}
56+
57+
dependencies {
58+
implementation 'cloud.eppo:eppo-server-sdk:3.0.0-SNAPSHOT'
59+
}
60+
```

build.gradle

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'signing'
5+
id "com.diffplug.spotless" version "6.13.0"
6+
}
7+
8+
group = 'cloud.eppo'
9+
version = '2.5.0-SNAPSHOT'
10+
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
11+
12+
import org.apache.tools.ant.filters.ReplaceTokens
13+
14+
processResources {
15+
with copySpec {
16+
from 'src/main/filteredResources'
17+
filter(ReplaceTokens, tokens: [version: project.properties.version])
18+
}
19+
}
20+
21+
repositories {
22+
mavenCentral()
23+
mavenLocal()
24+
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
25+
}
26+
27+
dependencies {
28+
implementation 'cloud.eppo:sdk-common-jvm:1.0.0'
29+
implementation 'com.github.zafarkhaja:java-semver:0.10.2'
30+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1'
31+
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
32+
implementation 'org.ehcache:ehcache:3.9.8'
33+
implementation 'org.slf4j:slf4j-api:2.0.13'
34+
// Logback classic 1.3.x is compatible with java 8
35+
implementation 'ch.qos.logback:logback-classic:1.3.14'
36+
37+
testImplementation 'org.projectlombok:lombok:1.18.24'
38+
testImplementation platform('org.junit:junit-bom:5.10.0')
39+
testImplementation 'org.junit.jupiter:junit-jupiter'
40+
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.2'
41+
testImplementation 'org.mockito:mockito-core:4.11.0'
42+
}
43+
44+
test {
45+
useJUnitPlatform()
46+
}
47+
48+
spotless {
49+
ratchetFrom 'origin/main'
50+
51+
format 'misc', {
52+
// define the files to apply `misc` to
53+
target '*.gradle', '.gitattributes', '.gitignore'
54+
55+
// define the steps to apply to those files
56+
trimTrailingWhitespace()
57+
indentWithSpaces(2) // or spaces. Takes an integer argument if you don't like 4
58+
endWithNewline()
59+
}
60+
java {
61+
// apply a specific flavor of google-java-format
62+
googleJavaFormat('1.7')
63+
// fix formatting of type annotations
64+
formatAnnotations()
65+
}
66+
}
67+
68+
java {
69+
withJavadocJar()
70+
withSourcesJar()
71+
}
72+
73+
publishing {
74+
publications {
75+
mavenJava(MavenPublication) {
76+
artifactId = 'eppo-server-sdk'
77+
from components.java
78+
versionMapping {
79+
usage('java-api') {
80+
fromResolutionOf('runtimeClasspath')
81+
}
82+
usage('java-runtime') {
83+
fromResolutionResult()
84+
}
85+
}
86+
pom {
87+
name = 'Eppo JVM SDK'
88+
description = 'Eppo SDK for JVM'
89+
url = 'https://github.com/Eppo-exp/java-server-sdk'
90+
licenses {
91+
license {
92+
name = 'MIT License'
93+
url = 'http://www.opensource.org/licenses/mit-license.php'
94+
}
95+
}
96+
developers {
97+
developer {
98+
name = 'Eppo'
99+
email = 'https://geteppo.com'
100+
}
101+
}
102+
scm {
103+
connection = 'scm:git:git://github.com/Eppo-exp/java-server-sdk'
104+
developerConnection = 'scm:git:ssh://github.com/Eppo-exp/java-server-sdk'
105+
url = 'http://github.com/Eppo-exp/java-server-sdk'
106+
}
107+
}
108+
}
109+
}
110+
repositories {
111+
maven {
112+
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
113+
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
114+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
115+
credentials {
116+
username = ossrhUsername
117+
password = ossrhPassword
118+
}
119+
}
120+
}
121+
}
122+
123+
signing {
124+
sign publishing.publications.mavenJava
125+
if (System.env['CI']) {
126+
useInMemoryPgpKeys(System.env.GPG_PRIVATE_KEY, System.env.GPG_PASSPHRASE)
127+
}
128+
}
129+
130+
131+
javadoc {
132+
if (JavaVersion.current().isJava9Compatible()) {
133+
options.addBooleanOption('html5', true)
134+
}
135+
}

gradle/wrapper/gradle-wrapper.jar

59.3 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu Jun 06 13:59:33 PDT 2024
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)