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

Add new Java SDK #6656

Merged
merged 7 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
42 changes: 42 additions & 0 deletions .github/workflows/java-api-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,48 @@ on:
description: Tag/version to publish

jobs:
deploy-legacy: # TODO(1.0): Remove this job after releasing 1.0
runs-on: ubuntu-20.04
environment: Treeverse signing
steps:
- name: Checkout
uses: actions/checkout@v3

# Extract the version to 'version' based on workflow_dispatch or triggered tag in the published event
- name: Extract version
shell: bash
run: |
if [ "${{ github.event.inputs.tag }}" != "" ]; then
echo "tag=$(echo ${{ github.event.inputs.tag }} | sed s/^v//)" >> $GITHUB_OUTPUT
else
echo "tag=$(echo ${GITHUB_REF##*/} | sed s/^v//)" >> $GITHUB_OUTPUT
fi
id: version

- name: Java generate package
run: make client-java-legacy PACKAGE_VERSION=${{ steps.version.outputs.tag }}

- name: Install secret key for signing
run: |
cat <(echo -e '${{ secrets.OSSRH_GPG_SECRET_KEY }}') | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG

- name: Set up Java and Maven Central Repository
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Build and publish package
working-directory: clients/java-legacy
run: mvn --batch-mode deploy -Dgpg.executable="${GITHUB_WORKSPACE}/scripts/gpg_loopback.sh" --activate-profiles sign-artifacts
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

deploy:
runs-on: ubuntu-20.04
environment: Treeverse signing
Expand Down
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ PROTOC=$(DOCKER) run --rm -v $(shell pwd):/mnt $(PROTOC_IMAGE)
CLIENT_JARS_BUCKET="s3://treeverse-clients-us-east/"

# https://openapi-generator.tech
OPENAPI_GENERATOR_IMAGE=openapitools/openapi-generator-cli:v5.3.0
OPENAPI_LEGACY_GENERATOR_IMAGE=openapitools/openapi-generator-cli:v5.3.0
OPENAPI_LEGACY_GENERATOR=$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_LEGACY_GENERATOR_IMAGE)
OPENAPI_GENERATOR_IMAGE=openapitools/openapi-generator-cli:v7.0.0
OPENAPI_GENERATOR=$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE)

GOLANGCI_LINT_VERSION=v1.53.3
Expand Down Expand Up @@ -113,7 +115,7 @@ client-python: api/swagger.yml ## Generate SDK for Python client
# remove the build folder as it also holds lakefs_client folder which keeps because we skip it during find
rm -rf clients/python/build; cd clients/python && \
find . -depth -name lakefs_client -prune -o ! \( -name Gemfile -or -name Gemfile.lock -or -name _config.yml -or -name .openapi-generator-ignore -or -name templates -or -name setup.mustache -or -name client.mustache \) -delete
$(OPENAPI_GENERATOR) generate \
$(OPENAPI_LEGACY_GENERATOR) generate \
-i /mnt/$< \
-g python \
-t /mnt/clients/python/templates \
Expand All @@ -124,18 +126,32 @@ client-python: api/swagger.yml ## Generate SDK for Python client
-c /mnt/clients/python-codegen-config.yaml \
-o /mnt/clients/python

client-java: api/swagger.yml ## Generate SDK for Java (and Scala) client
rm -rf clients/java
$(OPENAPI_GENERATOR) generate \
client-java-legacy: api/swagger.yml api/java-gen-ignore ## Generate legacy SDK for Java (and Scala) client
rm -rf clients/java-legacy
$(OPENAPI_LEGACY_GENERATOR) generate \
-i /mnt/$< \
--ignore-file-override /mnt/api/java-gen-ignore \
-g java \
--invoker-package io.lakefs.clients.api \
--http-user-agent "lakefs-java-sdk/$(PACKAGE_VERSION)" \
--additional-properties=hideGenerationTimestamp=true,artifactVersion=$(PACKAGE_VERSION),parentArtifactId=lakefs-parent,parentGroupId=io.lakefs,parentVersion=0,groupId=io.lakefs,artifactId='api-client',artifactDescription='lakeFS OpenAPI Java client',artifactUrl=https://lakefs.io,apiPackage=io.lakefs.clients.api,modelPackage=io.lakefs.clients.api.model,mainPackage=io.lakefs.clients.api,[email protected],developerName='Treeverse lakeFS dev',developerOrganization='lakefs.io',developerOrganizationUrl='https://lakefs.io',licenseName=apache2,licenseUrl=http://www.apache.org/licenses/,scmConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmDeveloperConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmUrl=https://github.com/treeverse/lakeFS \
--http-user-agent "lakefs-java-sdk/$(PACKAGE_VERSION)-legacy" \
--additional-properties hideGenerationTimestamp=true,artifactVersion=$(PACKAGE_VERSION),parentArtifactId=lakefs-parent,parentGroupId=io.lakefs,parentVersion=0,groupId=io.lakefs,artifactId='api-client',artifactDescription='lakeFS OpenAPI Java client legacy SDK',artifactUrl=https://lakefs.io,apiPackage=io.lakefs.clients.api,modelPackage=io.lakefs.clients.api.model,mainPackage=io.lakefs.clients.api,[email protected],developerName='Treeverse lakeFS dev',developerOrganization='lakefs.io',developerOrganizationUrl='https://lakefs.io',licenseName=apache2,licenseUrl=http://www.apache.org/licenses/,scmConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmDeveloperConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmUrl=https://github.com/treeverse/lakeFS \
-o /mnt/clients/java-legacy

client-java: api/swagger.yml api/java-gen-ignore ## Generate SDK for Java (and Scala) client
rm -rf clients/java
mkdir -p clients/java
cp api/java-gen-ignore clients/java/.openapi-generator-ignore
$(OPENAPI_GENERATOR) generate \
-i /mnt/api/swagger.yml \
-g java \
--invoker-package io.lakefs.clients.sdk \
--http-user-agent "lakefs-java-sdk/$(PACKAGE_VERSION)-v1" \
--additional-properties disallowAdditionalPropertiesIfNotPresent=false,useSingleRequestParameter=true,hideGenerationTimestamp=true,artifactVersion=$(PACKAGE_VERSION),parentArtifactId=lakefs-parent,parentGroupId=io.lakefs,parentVersion=0,groupId=io.lakefs,artifactId='sdk-client',artifactDescription='lakeFS OpenAPI Java client',artifactUrl=https://lakefs.io,apiPackage=io.lakefs.clients.sdk,modelPackage=io.lakefs.clients.sdk.model,mainPackage=io.lakefs.clients.sdk,[email protected],developerName='Treeverse lakeFS dev',developerOrganization='lakefs.io',developerOrganizationUrl='https://lakefs.io',licenseName=apache2,licenseUrl=http://www.apache.org/licenses/,scmConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmDeveloperConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmUrl=https://github.com/treeverse/lakeFS \
-o /mnt/clients/java

.PHONY: clients client-python client-java
clients: client-python client-java

.PHONY: clients client-python client-java client-java-legacy
clients: client-python client-java client-java-legacy

package-python: client-python
$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt -e HOME=/tmp/ -w /mnt/clients/python $(PYTHON_IMAGE) /bin/bash -c \
Expand Down
4 changes: 4 additions & 0 deletions api/java-gen-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Files to ignore (skip) when generating Java client
maven.yml
.github/
Copy link
Contributor

@Jonathan-Rosenberg Jonathan-Rosenberg Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.github/
.github/
git_push.sh

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now really re-done.

git_push.sh
11 changes: 6 additions & 5 deletions clients/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
java/** linguist-generated
python/** linguist-generated
python/Gemfile linguist-generated=false
python/Gemfile.lock linguist-generated=false
python/_config.yml linguist-generated=false
java/** linguist-generated
java-legacy/** linguist-generated
python/** linguist-generated
python/Gemfile linguist-generated=false
python/Gemfile.lock linguist-generated=false
python/_config.yml linguist-generated=false
21 changes: 21 additions & 0 deletions clients/java-legacy/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions clients/java-legacy/.openapi-generator-ignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading