Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(java): Organize Java package paths #195

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d5b7406
feat(java): Initialize Java SDK
booniepepper Jul 27, 2023
41115e3
fix(java): Fix incorrect license url
booniepepper Jul 28, 2023
514cb29
fix(java): Fix mustache generation by moving files out of a 'Java' di…
booniepepper Aug 1, 2023
dbe75e1
clean(java): Remove base template files also present in libraries/native
booniepepper Aug 1, 2023
7f62f8f
clean(java): Remove more unneeded or unused templates
booniepepper Aug 1, 2023
9edd375
test(java): Add Java integration tests (#160)
booniepepper Aug 2, 2023
203695a
fix(java): Update to use JsonMapper (#166)
booniepepper Aug 4, 2023
13648d4
test(java): Add unit tests (#170)
booniepepper Aug 8, 2023
4a19dbd
clean(java): Add note on HttpClientMock, remove unused mustache templ…
booniepepper Aug 8, 2023
9665f9a
misc(java): Rename package path of client components (#174)
booniepepper Aug 11, 2023
94f167e
feat(java): Add SDK Configuration (#173)
booniepepper Aug 16, 2023
1e2b59e
refactor(java): Update Java package path (#179)
booniepepper Aug 16, 2023
25a8b43
refactor(java): Async (#180)
booniepepper Aug 18, 2023
913ed67
ci(java): Make sure only Gradle CI is rendered (#186)
booniepepper Aug 18, 2023
6d1ff30
fix(java): Add .get() on void async requests in test (#188)
booniepepper Aug 21, 2023
76cc8bc
feat(java): Configuration overrides (#189)
booniepepper Aug 24, 2023
449aece
chore(java): add readme shell (#193)
rhamzeh Aug 28, 2023
e02fad0
refactor(java): Misc changes (#191)
booniepepper Aug 28, 2023
3547c9c
refactor(java): sdk cleanup (#194)
booniepepper Aug 29, 2023
17b265f
refactor(java): Move error and util classes around
booniepepper Aug 30, 2023
027b6f6
refactor(java): Remove an unused date format class
booniepepper Aug 30, 2023
a98253d
refactor(java): Move auth classes to their own space
booniepepper Aug 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,56 @@ jobs:
GITHUB_ORG_ID: ${{ secrets.PYTHON_SDK_GITHUB_ORG_ID }}
GITHUB_REPO_ID: ${{ secrets.PYTHON_SDK_GITHUB_REPO_ID }}
SSH_KEY: ${{ secrets.PYTHON_SDK_SSH_KEY }}

build-and-test-java-sdk:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'temurin'
cache: 'gradle'

- name: Setup git
run: ./scripts/setup_git.sh
env:
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}

# - name: Clone the existing SDK
# run: ./scripts/clone_sdk.sh
# env:
# GITHUB_ORG_ID: ${{ secrets.JAVA_SDK_GITHUB_ORG_ID }}
# GITHUB_REPO_ID: ${{ secrets.JAVA_SDK_GITHUB_REPO_ID }}
# SSH_KEY: ${{ secrets.JAVA_SDK_SSH_KEY }}
# SDK_PATH: clients/fga-java-sdk
# KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# TODO: Don't run this twice. For some reason, the initial run of
# `make build-client-java` doesn't work, but subsequent runs do.
- name: Build Java SDK
continue-on-error: true
run: |-
mkdir -p clients/fga-java-sdk
make build-client-java

- name: Run All Tests
run: |-
make test-integration-client-java

# - name: Check for SDK changes
# run: ./scripts/commit_push_changes.sh
# env:
# SDK_PATH: clients/fga-java-sdk
# DRY_RUN: 1
# TAGGING_DISABLE: 1
# GITHUB_ORG_ID: ${{ secrets.JAVA_SDK_GITHUB_ORG_ID }}
# GITHUB_REPO_ID: ${{ secrets.JAVA_SDK_GITHUB_REPO_ID }}
# SSH_KEY: ${{ secrets.JAVA_SDK_SSH_KEY }}
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GO_DOCKER_TAG = 1
DOTNET_DOCKER_TAG = 6.0
GOLINT_DOCKER_TAG = v1.51-alpine
BUSYBOX_DOCKER_TAG = 1
GRADLE_DOCKER_TAG = 8.2
PYTHON_DOCKER_TAG = 3.10
# Other config
CONFIG_DIR = ${PWD}/config
Expand All @@ -28,6 +29,7 @@ pull-docker-images:
docker pull golangci/golangci-lint:${GOLINT_DOCKER_TAG}
docker pull mcr.microsoft.com/dotnet/sdk:${DOTNET_DOCKER_TAG}
docker pull busybox:${BUSYBOX_DOCKER_TAG}
docker pull gradle:${GRADLE_DOCKER_TAG}

## Publishing
publish-client-dotnet: build-client-dotnet
Expand All @@ -42,10 +44,10 @@ test: test-all-clients
build: build-all-clients

.PHONY: test-all-clients
test-all-clients: test-client-js test-client-go test-client-dotnet test-client-python
test-all-clients: test-client-js test-client-go test-client-dotnet test-client-python test-client-java

.PHONY: build-all-clients
build-all-clients: build-client-js build-client-go build-client-dotnet build-client-python
build-all-clients: build-client-js build-client-go build-client-dotnet build-client-python build-client-java

### JavaScript
.PHONY: tag-client-js
Expand Down Expand Up @@ -129,6 +131,7 @@ run-in-docker:
-v "${CLIENTS_OUTPUT_DIR}/fga-${sdk_language}-sdk":/module \
-v ${CONFIG_DIR}:/config \
-w /module \
--net="host" \
${image} \
${command}

Expand Down Expand Up @@ -202,3 +205,19 @@ shellcheck:
.PHONY: setup-new-sdk
setup-new-sdk:
./scripts/setup_new_sdk.sh

.PHONY: build-client-java
build-client-java:
make build-client sdk_language=java tmpdir=${TMP_DIR}
make run-in-docker sdk_language=java image=gradle:${GRADLE_DOCKER_TAG} command="/bin/sh -c 'chmod +x ./gradlew && gradle fmt build'"

.PHONY: test-integration-client-java
test-integration-client-java: build-client-java
docker container rm --force openfga-for-java-client || true
docker run --detach --name openfga-for-java-client -p 8080:8080 openfga/openfga run
make run-in-docker sdk_language=java image=gradle:${GRADLE_DOCKER_TAG} command="/bin/sh -c './gradlew test-integration'"
docker container rm --force openfga-for-java-client

.PHONY: test-client-java
test-client-java: build-client-java
make run-in-docker sdk_language=java image=gradle:${GRADLE_DOCKER_TAG} command="/bin/sh -c 'gradle test'"
16 changes: 16 additions & 0 deletions config/clients/java/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Used but at a different location
**/client/Configuration.java
**/client/Pair.java
**/client/ApiException.java

# Unused
**/ServerConfiguration.java
**/ServerVariable.java
**/JSON.java
**/RFC3339DateFormat.java
src/main/AndroidManifest.xml
build.sbt
pom.xml
.github/workflows/maven.yml
git_push.sh
.travis.yml
Empty file.
105 changes: 105 additions & 0 deletions config/clients/java/config.overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"sdkId": "java",
"gitRepoId": "java-sdk",
"packageName": "dev.openfga:openfga-sdk",
"artifactId": "openfga-sdk",
"groupId": "dev.openfga",
"artifactVersion": "0.0.1",
"packageVersion": "0.0.1",
"apiPackage": "dev.openfga.sdk.api",
"invokerPackage": "dev.openfga.sdk.api.client",
"modelPackage": "dev.openfga.sdk.api.model",
"snapshotVersion": false,
"packageDescription": "Java SDK for OpenFGA",
"artifactDescription": "Java SDK for OpenFGA",
"packageDetailedDescription": "This is an autogenerated Java SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api).",
"developerEmail": "community@openfga.dev",
"developerName": "OpenFGA Contributors",
"developerOrganization": "OpenFGA",
"developerOrganizationUrl": "https://openfga.dev",
"licenseName": "Apache-2.0",
"licenseUrl": "https://github.com/openfga/java-sdk/blob/main/LICENSE",
"scmConnection": "scm:git:git@github.com:openfga/java-sdk.git",
"scmDeveloperConnection": "scm:git:git@github.com:openfga/java-sdk.git",
"scmUrl": "https://github.com/openfga/java-sdk",
"library": "native",
"asyncNative": true,
"disallowAdditionalPropertiesIfNotPresent": false,
"enumUnknownDefaultCase": true,
"allowUnicodeIdentifiers": true,
"caseInsensitiveResponseHeaders": true,
"files": {
"build.gradle.mustache" : {
"destinationFilename": "build.gradle",
"templateType": "SupportingFiles"
},
".github/workflows/main.yml.mustache" : {
"destinationFilename": ".github/workflows/main.yml",
"templateType": "SupportingFiles"
},
"creds-CredentialsMethod.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/api/auth/CredentialsMethod.java",
"templateType": "SupportingFiles"
},
"creds-ApiBearerToken.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/api/auth/ApiBearerToken.java",
"templateType": "SupportingFiles"
},
"creds-ClientCredentials.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/api/auth/ClientCredentials.java",
"templateType": "SupportingFiles"
},
"creds-ClientCredentialsTest.java.mustache" : {
"destinationFilename": "src/test/java/dev/openfga/sdk/api/auth/ClientCredentialsTest.java",
"templateType": "SupportingFiles"
},
"config-BaseConfiguration.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/api/configuration/BaseConfiguration.java",
"templateType": "SupportingFiles"
},
"config-Configuration.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/api/configuration/Configuration.java",
"templateType": "SupportingFiles"
},
"config-ConfigurationOverride.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/api/configuration/ConfigurationOverride.java",
"templateType": "SupportingFiles"
},
"config-ConfigurationTest.java.mustache" : {
"destinationFilename": "src/test/java/dev/openfga/sdk/api/configuration/ConfigurationTest.java",
"templateType": "SupportingFiles"
},
"Pair.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/util/Pair.java",
"templateType": "SupportingFiles"
},
"util-StringUtil.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/util/StringUtil.java",
"templateType": "SupportingFiles"
},
"util-StringUtilTest.java.mustache" : {
"destinationFilename": "src/test/java/dev/openfga/util/StringUtilTest.java",
"templateType": "SupportingFiles"
},
"libraries/native/apiException.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/errors/ApiException.java",
"templateType": "SupportingFiles"
},
"FgaInvalidParameterException.java.mustache" : {
"destinationFilename": "src/main/java/dev/openfga/sdk/errors/FgaInvalidParameterException.java",
"templateType": "SupportingFiles"
},
"OpenFgaApiTest.java.mustache" : {
"destinationFilename": "src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java",
"templateType": "SupportingFiles"
},
"OpenFgaApiIntegrationTest.java.mustache" : {
"destinationFilename": "src/test-integration/java/dev/openfga/sdk/api/OpenFgaApiIntegrationTest.java",
"templateType": "SupportingFiles"
},
"gradle-wrapper.properties.mustache" : {
"destinationFilename": "gradle/wrapper/gradle-wrapper.properties",
"templateType": "SupportingFiles"
}
}
}
1 change: 1 addition & 0 deletions config/clients/java/generator.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java
7 changes: 7 additions & 0 deletions config/clients/java/template-source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"repo": "https://github.com/OpenAPITools/openapi-generator",
"branch": "master",
"commit": "90eacb685c57308e67c65e436b19d160091f91e1",
"url": "https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/Java",
"docs": "https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/java.md"
}
27 changes: 27 additions & 0 deletions config/clients/java/template/.github/workflows/main.yml.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Java CI with Gradle

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
name: Build {{{appName}}}
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '11', '17', '20' ]
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.2
- name: Set up JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
with:
{{=< >=}}
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
run: |
./gradlew build
Loading
Loading