Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
db24917
Update Java toolchain configuration and bump OAuth2 client version
Jul 8, 2025
b97c575
use openapi generator
Jul 8, 2025
b25f1e9
remove all generated files
Jul 8, 2025
e5b09ab
add retryoauth test back
Jul 9, 2025
10f315e
ignore files for genration
Jul 9, 2025
6d13bd9
use generated classes
Jul 10, 2025
776d28c
multi module project
Jul 14, 2025
d8162ef
remove unused configuration and RetryingOAuth implementation
Jul 14, 2025
5e6fcc4
add GitHub Packages repository configuration for publishing snapshots
Jul 22, 2025
fc6e1c8
update GitHub Actions workflow to use dynamic signing parameters and …
Jul 22, 2025
9498f26
refactor build.gradle to use dynamic project versioning and improve d…
Jul 22, 2025
65ca762
add Sonatype credentials to GitHub Actions workflow for snapshot publ…
Jul 22, 2025
2de217c
update GitHub Actions workflow to include Sonatype credentials in sna…
Jul 22, 2025
8294006
refactor GitHub Actions workflow to separate parameters for improved …
Jul 22, 2025
669b0e0
remove redundant build step for openapi-generator-plugin in snapshot …
Jul 22, 2025
f41cce2
refactor: qualify Thread.currentThread() with java.lang to avoid ambi…
Jul 22, 2025
db4c479
refactor: move plugin build step to the beginning of the workflow for…
Jul 22, 2025
6c209af
refactor: add publish step for openapi-generator-plugin to Maven Local
Jul 22, 2025
21bf61d
checkpoint
Jul 23, 2025
1a3a9d5
refactor: remove synchronous part creation methods for cleaner API
Jul 23, 2025
c66f852
refactor: remove openapi-generator-plugin publish step from PR snapsh…
Jul 23, 2025
f573aba
refactor: update publish command to target Sonatype in PR snapshot wo…
Jul 23, 2025
a53a557
refactor: update build.gradle to use mavenLocal and clean up publish …
Jul 23, 2025
39f13b0
refactor: streamline build and publish steps in PR snapshot workflow
Jul 23, 2025
adc62d9
refactor: update build step to include publishing the plugin to Maven…
Jul 23, 2025
8e66988
refactor: add snapshot flag to gradle commands in build workflow
Jul 23, 2025
07bf267
fix: add space in gradlew command for proper execution in build workflow
Jul 23, 2025
f5ded02
use convention plugins
Jul 23, 2025
ed0c7bb
refactor: streamline build.gradle files by removing unnecessary confi…
Jul 23, 2025
17f4145
refactor: update build workflow to remove plugin publishing step and …
Jul 23, 2025
cc3a474
feat: add initial build.gradle configuration for project setup and ne…
Jul 23, 2025
f6a9817
fix: remove version specification for nexus publish plugin in build.g…
Jul 23, 2025
251708e
fix: update nexus repository URLs in build.gradle for staging environ…
Jul 23, 2025
f1ca7ea
feat: add version check workflow for pull requests to ensure version …
Jul 23, 2025
0cf4eb9
fix: update project version to 0.11.1 in build.gradle
Jul 23, 2025
e663314
fix: improve version extraction logic in version-check workflow
Jul 23, 2025
d96ce13
fix: streamline version extraction and comparison logic in version-ch…
Jul 23, 2025
2cd7820
fix: revert project version to 0.11.0 in build.gradle
Jul 23, 2025
4d67dc3
fix: update build workflow trigger to ignore pushes to main branch
Jul 23, 2025
678d1cd
fix: update version extraction logic in version-lib.sh to match new p…
Jul 23, 2025
e73f633
fix: update version assignment syntax in bump-version.sh to match pro…
Jul 23, 2025
165fa12
fix: update version to 0.11.0 in README.md for Maven, Gradle, and Sbt…
Jul 23, 2025
cddf38e
portable sed in bump version
Jul 24, 2025
449b656
update readme
Jul 24, 2025
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
11 changes: 5 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: build

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

jobs:
build:
Expand All @@ -11,8 +13,5 @@ jobs:
with: { java-version: 17, distribution: temurin }
- name: Build and Verify
run: |
# Build the plugin first and check its contents
./gradlew :openapi-generator-plugin:build

# Now run the full build
./gradlew clean build
# With convention plugins, everything is self-contained
./gradlew -PisSnapshot=true clean build
45 changes: 45 additions & 0 deletions .github/workflows/pr-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: PR Snapshot

on:
push:
branches-ignore:
- main

jobs:
build-and-publish-snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build and Publish Snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
# Sonatype credentials
OSSRH_USERNAME: ${{ secrets.MAVEN_CENTRAL_CREDS_TOKEN_USER }}
OSSRH_PASSWORD: ${{ secrets.MAVEN_CENTRAL_CREDS_TOKEN_PASS }}
# Optional signing environment variables for consistency with publish workflow
SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_signingKey || '' }}
SIGNING_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_signingPassword || '' }}
run: |
# Build the plugin first
./gradlew -PisSnapshot=true :openapi-generator-plugin:build :openapi-generator-plugin:publishToMavenLocal

# Set up parameters based on available secrets
GRADLE_PARAMS="-PisSnapshot=true"
if [ -n "$SIGNING_KEY" ] && [ -n "$SIGNING_PASSWORD" ]; then
GRADLE_PARAMS="$GRADLE_PARAMS -P signingKey=$SIGNING_KEY -P signingPassword=$SIGNING_PASSWORD"
fi

# Publish snapshots to GitHub Packages
./gradlew -PisSnapshot=true \
-P ossrhUsername=${{ secrets.MAVEN_CENTRAL_CREDS_TOKEN_USER }} \
-P ossrhPassword=${{ secrets.MAVEN_CENTRAL_CREDS_TOKEN_PASS }} \
$GRADLE_PARAMS :api-client-library:publishToSonatype
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
./gradlew \
-P signingKey=${{ secrets.ORG_GRADLE_PROJECT_signingKey }} \
-P signingPassword=${{ secrets.ORG_GRADLE_PROJECT_signingPassword }} \
-P ossrhUsername=${{ secrets.OSSRH_USERNAME }} \
-P ossrhPassword=${{ secrets.OSSRH_PASSWORD }} \
-P ossrhUsername=${{ secrets.MAVEN_CENTRAL_CREDS_TOKEN_USER }} \
-P ossrhPassword=${{ secrets.MAVEN_CENTRAL_CREDS_TOKEN_PASS }} \
:api-client-library:publishToSonatype \
:api-client-library:closeAndReleaseSonatypeStagingRepository
closeAndReleaseSonatypeStagingRepository
./scripts/publish.sh
111 changes: 111 additions & 0 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Version Check

on:
pull_request:
branches: [ main ]

jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to compare branches

- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Check Version Increment
run: |
# Extract current version from build.gradle
CURRENT_VERSION=$(grep "def projectVersion" build.gradle | sed -E "s/.*def projectVersion = ['\"]([^'\"]*)['\"].*/\1/")
echo "Current version: $CURRENT_VERSION"

# Validate that we extracted current version correctly
if [ -z "$CURRENT_VERSION" ]; then
echo "❌ Failed to extract current version from build.gradle"
exit 1
fi

# Get the latest Git tag from the target branch
git fetch origin ${{ github.base_ref }}
git checkout origin/${{ github.base_ref }}

LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")

if [ -z "$LATEST_TAG" ]; then
echo "No existing tags found. Assuming this is the first release."
LATEST_TAG="0.0.0"
fi

# Remove 'v' prefix if present
TARGET_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//')
echo "Latest tag version: $TARGET_VERSION"

# Switch back to PR branch
git checkout ${{ github.head_ref }}

# Function to normalize version (ensure 3 parts)
normalize_version() {
local version=$1
IFS='.' read -ra V <<< "$version"

# Ensure we have 3 parts
while [ ${#V[@]} -lt 3 ]; do V+=(0); done

echo "${V[0]}.${V[1]}.${V[2]}"
}

# Function to compare semantic versions
version_compare() {
local version1=$1
local version2=$2

# Normalize both versions
version1=$(normalize_version "$version1")
version2=$(normalize_version "$version2")

# Split versions into arrays
IFS='.' read -ra V1 <<< "$version1"
IFS='.' read -ra V2 <<< "$version2"

# Compare major version
if [ "${V1[0]}" -gt "${V2[0]}" ]; then
return 0 # version1 > version2
elif [ "${V1[0]}" -lt "${V2[0]}" ]; then
return 1 # version1 < version2
fi

# Compare minor version
if [ "${V1[1]}" -gt "${V2[1]}" ]; then
return 0
elif [ "${V1[1]}" -lt "${V2[1]}" ]; then
return 1
fi

# Compare patch version
if [ "${V1[2]}" -gt "${V2[2]}" ]; then
return 0
elif [ "${V1[2]}" -lt "${V2[2]}" ]; then
return 1
fi

# Versions are equal
return 2
}

# Compare versions
if version_compare "$CURRENT_VERSION" "$TARGET_VERSION"; then
echo "✅ Version increment detected: $TARGET_VERSION → $CURRENT_VERSION"
exit 0
elif [ $? -eq 2 ]; then
echo "❌ Version not incremented: $CURRENT_VERSION is the same as $TARGET_VERSION"
echo "Please increment the version in build.gradle"
exit 1
else
echo "❌ Version decreased: $TARGET_VERSION → $CURRENT_VERSION"
echo "Version should only increase, not decrease"
exit 1
fi
112 changes: 40 additions & 72 deletions MULTI_MODULE_README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,26 @@
# Vertex API Client Java - Multi-Module Project
# Vertex API Client Java - Project Architecture

This project has been restructured as a multi-module Gradle project with the following modules:
This project uses a modern Gradle multi-module structure with convention plugins for clean, maintainable builds.

## Modules
## Project Structure

### 1. `openapi-generator-plugin`
Custom Gradle plugin for generating Vertex API client code using OpenAPI Generator.
### Core Modules

**Location**: `openapi-generator-plugin/`

**Purpose**:
- Contains custom OpenAPI code generation logic
- Provides a reusable Gradle plugin for generating the API client
- Includes any custom templates or generators specific to Vertex API

**Build**:
```bash
./gradlew :openapi-generator-plugin:build
./gradlew :openapi-generator-plugin:publishToMavenLocal
```

### 2. `api-client-library`
#### `api-client-library/`
The main API client library generated from the OpenAPI specification.

**Location**: `api-client-library/`

**Purpose**:
- Contains the generated API client code
- Includes authentication utilities
- Provides the core SDK functionality

**Build**:
```bash
./gradlew :api-client-library:build
```
- Includes authentication utilities and models
- Provides the core SDK functionality that gets published to Maven Central

**Generate API Client**:
```bash
./gradlew :api-client-library:openApiGenerate
```

### 3. `examples`
#### `examples/`
Example applications demonstrating how to use the API client library.

**Location**: `examples/`

**Purpose**:
- Contains example code showing API usage
- Contains example code showing API usage patterns
- Includes command-line utilities for common operations
- Demonstrates best practices for using the API client
- Demonstrates best practices for authentication and API calls

**Run Examples**:
```bash
Expand All @@ -57,50 +29,46 @@ Example applications demonstrating how to use the API client library.
./gradlew :examples:listExamples
```

## Build Order

The modules have dependencies on each other and should be built in this order:
### Build Infrastructure

1. `openapi-generator-plugin` (standalone)
2. `api-client-library` (uses the plugin)
3. `examples` (depends on the library)
#### `buildSrc/`
Contains the build logic and custom OpenAPI generator.

## Building the Entire Project
**Purpose**:
- Houses convention plugins (`vertex.java-conventions`, `vertex.openapi-generator`)
- Contains the custom `VertexJavaClientCodegen` generator
- Provides shared build configuration across all modules
- Eliminates circular dependencies and external plugin publishing

To build all modules:
```bash
./gradlew build
```
**Key Files**:
- `src/main/java/com/vertexvis/codegen/VertexJavaClientCodegen.java` - Custom OpenAPI generator
- `src/main/groovy/vertex.java-conventions.gradle` - Common Java build settings
- `src/main/groovy/vertex.openapi-generator.gradle` - OpenAPI generation configuration

To clean and rebuild everything:
```bash
./gradlew clean build
```
## Architecture Benefits

## Publishing
### Convention Plugins
- **Self-contained**: No need to publish plugins separately
- **Consistent**: Shared configuration across all modules
- **Maintainable**: Build logic lives with the code it serves

The library can be published to Maven repositories:
```bash
./gradlew :api-client-library:publishToMavenLocal
./gradlew publish
```
### Simplified Dependencies
- **No circular dependencies**: buildSrc → modules (not modules → plugins → modules)
- **Faster builds**: No separate plugin build/publish cycle
- **Easier development**: Make changes and build immediately

## Development Workflow

1. Make changes to the OpenAPI generator plugin if needed
2. Build and publish the plugin locally: `./gradlew :openapi-generator-plugin:publishToMavenLocal`
3. Regenerate the API client: `./gradlew :api-client-library:openApiGenerate`
4. Build the library: `./gradlew :api-client-library:build`
5. Test with examples: `./gradlew :examples:run`
The build is completely self-contained:

## Migration Notes
```bash
# Everything needed is built automatically
./gradlew build

This project was converted from a single-module to a multi-module structure:
# Test examples
./gradlew :examples:run

- **Original structure**: All code in `src/main/java/com/vertexvis/`
- **New structure**:
- Code generation logic → `openapi-generator-plugin/`
- Core API client → `api-client-library/`
- Examples → `examples/`
# Publish locally for testing
./gradlew :api-client-library:publishToMavenLocal
```

The functionality remains the same, but the code is now better organized and the generator can be reused across projects.
Loading