-
Notifications
You must be signed in to change notification settings - Fork 15
[BLD] Add Makefile for common development tasks #78
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,228 @@ | ||
| # ChromaDB Java Client Makefile | ||
| # This Makefile provides convenient commands for common development tasks | ||
|
|
||
| # Variables | ||
| MAVEN := mvn | ||
| JAVA := java | ||
| CHROMA_VERSIONS := 0.4.24 0.5.0 0.5.5 0.5.15 | ||
|
|
||
| # Color output | ||
| RED := \033[0;31m | ||
| GREEN := \033[0;32m | ||
| YELLOW := \033[0;33m | ||
| BLUE := \033[0;34m | ||
| NC := \033[0m # No Color | ||
|
|
||
| # Default target | ||
| .DEFAULT_GOAL := help | ||
|
|
||
| # Check for required tools | ||
| .PHONY: check-tools | ||
| check-tools: | ||
| @command -v $(JAVA) >/dev/null 2>&1 || { echo "$(RED)Error: Java is not installed$(NC)"; exit 1; } | ||
| @command -v $(MAVEN) >/dev/null 2>&1 || { echo "$(RED)Error: Maven is not installed$(NC)"; exit 1; } | ||
| @echo "$(GREEN)✓ All required tools are installed$(NC)" | ||
|
|
||
| ##@ Core Build Targets | ||
|
|
||
| .PHONY: build | ||
| build: check-tools ## Clean and compile the project | ||
| @echo "$(BLUE)Building project...$(NC)" | ||
| $(MAVEN) clean compile | ||
|
|
||
| .PHONY: test | ||
| test: check-tools ## Run all tests | ||
| @echo "$(BLUE)Running tests...$(NC)" | ||
| $(MAVEN) test | ||
|
|
||
| .PHONY: package | ||
| package: check-tools ## Create JAR package | ||
| @echo "$(BLUE)Creating JAR package...$(NC)" | ||
| $(MAVEN) clean package | ||
|
|
||
| .PHONY: install | ||
| install: check-tools ## Install to local Maven repository | ||
| @echo "$(BLUE)Installing to local Maven repository...$(NC)" | ||
| $(MAVEN) clean install | ||
|
|
||
| .PHONY: clean | ||
| clean: check-tools ## Clean build artifacts | ||
| @echo "$(BLUE)Cleaning build artifacts...$(NC)" | ||
| $(MAVEN) clean | ||
|
|
||
| ##@ Testing Targets | ||
|
|
||
| .PHONY: test-unit | ||
| test-unit: check-tools ## Run unit tests only | ||
| @echo "$(BLUE)Running unit tests...$(NC)" | ||
| $(MAVEN) test -Dtest="!TestAPI,!*Integration*" | ||
|
|
||
| .PHONY: test-integration | ||
| test-integration: check-tools ## Run integration tests only | ||
| @echo "$(BLUE)Running integration tests...$(NC)" | ||
| $(MAVEN) test -Dtest="TestAPI,*Integration*" | ||
|
|
||
| .PHONY: test-version | ||
| test-version: check-tools ## Test with specific ChromaDB version (use CHROMA_VERSION=x.x.x) | ||
| ifndef CHROMA_VERSION | ||
| @echo "$(RED)Error: CHROMA_VERSION not specified$(NC)" | ||
| @echo "Usage: make test-version CHROMA_VERSION=0.5.15" | ||
| @exit 1 | ||
| endif | ||
| @echo "$(BLUE)Testing with ChromaDB version $(CHROMA_VERSION)...$(NC)" | ||
| CHROMA_VERSION=$(CHROMA_VERSION) $(MAVEN) test | ||
|
|
||
| .PHONY: test-all-versions | ||
| test-all-versions: check-tools ## Run tests against all supported ChromaDB versions | ||
| @echo "$(BLUE)Testing against all supported ChromaDB versions...$(NC)" | ||
| @for version in $(CHROMA_VERSIONS); do \ | ||
| echo "$(YELLOW)Testing with ChromaDB $$version...$(NC)"; \ | ||
| CHROMA_VERSION=$$version $(MAVEN) test || exit 1; \ | ||
| done | ||
| @echo "$(GREEN)✓ All version tests passed$(NC)" | ||
|
|
||
| .PHONY: test-class | ||
| test-class: check-tools ## Run specific test class (use TEST=ClassName) | ||
| ifndef TEST | ||
| @echo "$(RED)Error: TEST not specified$(NC)" | ||
| @echo "Usage: make test-class TEST=TestAPI" | ||
| @exit 1 | ||
| endif | ||
| @echo "$(BLUE)Running test class $(TEST)...$(NC)" | ||
| $(MAVEN) test -Dtest=$(TEST) | ||
|
|
||
| .PHONY: test-method | ||
| test-method: check-tools ## Run specific test method (use TEST=ClassName#methodName) | ||
| ifndef TEST | ||
| @echo "$(RED)Error: TEST not specified$(NC)" | ||
| @echo "Usage: make test-method TEST=TestAPI#testCreateCollection" | ||
| @exit 1 | ||
| endif | ||
| @echo "$(BLUE)Running test method $(TEST)...$(NC)" | ||
| $(MAVEN) test -Dtest=$(TEST) | ||
|
|
||
| ##@ Code Generation | ||
|
|
||
| .PHONY: generate | ||
| generate: check-tools ## Generate API client from OpenAPI spec | ||
| @echo "$(BLUE)Generating API client from OpenAPI spec...$(NC)" | ||
| $(MAVEN) generate-sources | ||
|
|
||
| .PHONY: generate-clean | ||
| generate-clean: check-tools ## Clean and regenerate API client | ||
| @echo "$(BLUE)Cleaning generated sources...$(NC)" | ||
| rm -rf target/generated-sources | ||
| @echo "$(BLUE)Regenerating API client...$(NC)" | ||
| $(MAVEN) generate-sources | ||
|
|
||
| ##@ Development Utilities | ||
|
|
||
| .PHONY: deps | ||
| deps: check-tools ## Download/update dependencies | ||
| @echo "$(BLUE)Resolving dependencies...$(NC)" | ||
| $(MAVEN) dependency:resolve | ||
|
|
||
| .PHONY: deps-tree | ||
| deps-tree: check-tools ## Display dependency tree | ||
| @echo "$(BLUE)Displaying dependency tree...$(NC)" | ||
| $(MAVEN) dependency:tree | ||
|
|
||
| .PHONY: deps-analyze | ||
| deps-analyze: check-tools ## Analyze dependencies for conflicts | ||
| @echo "$(BLUE)Analyzing dependencies...$(NC)" | ||
| $(MAVEN) dependency:analyze | ||
|
|
||
| .PHONY: versions | ||
| versions: check-tools ## Check for dependency updates | ||
| @echo "$(BLUE)Checking for dependency updates...$(NC)" | ||
| $(MAVEN) versions:display-dependency-updates | ||
|
|
||
| .PHONY: compile | ||
| compile: check-tools ## Compile source code without cleaning | ||
| @echo "$(BLUE)Compiling source code...$(NC)" | ||
| $(MAVEN) compile | ||
|
|
||
| .PHONY: test-compile | ||
| test-compile: check-tools ## Compile test source code | ||
| @echo "$(BLUE)Compiling test source code...$(NC)" | ||
| $(MAVEN) test-compile | ||
|
|
||
| ##@ Release Targets | ||
|
|
||
| .PHONY: release-prepare | ||
| release-prepare: check-tools ## Prepare for release (update versions) | ||
| @echo "$(YELLOW)Preparing for release...$(NC)" | ||
| @echo "Current version: $$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout)" | ||
| @read -p "Enter new version: " VERSION && \ | ||
| $(MAVEN) versions:set -DnewVersion=$$VERSION && \ | ||
| echo "$(GREEN)✓ Version updated to $$VERSION$(NC)" | ||
|
|
||
| .PHONY: release-rollback | ||
| release-rollback: check-tools ## Rollback version changes | ||
| @echo "$(YELLOW)Rolling back version changes...$(NC)" | ||
| $(MAVEN) versions:revert | ||
|
|
||
| .PHONY: snapshot | ||
| snapshot: check-tools ## Deploy snapshot version | ||
| @echo "$(BLUE)Deploying snapshot...$(NC)" | ||
| $(MAVEN) clean deploy | ||
|
|
||
| .PHONY: release | ||
| release: check-tools ## Full release (CI only - requires GPG signing) | ||
| @echo "$(YELLOW)⚠️ This target is intended for CI use only$(NC)" | ||
| @echo "$(BLUE)Performing full release...$(NC)" | ||
| $(MAVEN) clean deploy -P release | ||
|
|
||
| ##@ Docker Targets | ||
|
|
||
| .PHONY: docker-test | ||
| docker-test: ## Run tests in Docker environment | ||
| @echo "$(BLUE)Running tests in Docker...$(NC)" | ||
| docker run --rm -v $(PWD):/workspace -w /workspace maven:3-openjdk-8 mvn test | ||
|
|
||
| .PHONY: docker-build | ||
| docker-build: ## Build project in Docker environment | ||
| @echo "$(BLUE)Building in Docker...$(NC)" | ||
| docker run --rm -v $(PWD):/workspace -w /workspace maven:3-openjdk-8 mvn clean package | ||
|
|
||
| ##@ Utility Targets | ||
|
|
||
| .PHONY: info | ||
| info: check-tools ## Display project information | ||
| @echo "$(BLUE)Project Information:$(NC)" | ||
| @echo " Name: $$($(MAVEN) help:evaluate -Dexpression=project.name -q -DforceStdout)" | ||
| @echo " Group ID: $$($(MAVEN) help:evaluate -Dexpression=project.groupId -q -DforceStdout)" | ||
| @echo " Artifact ID: $$($(MAVEN) help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" | ||
| @echo " Version: $$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout)" | ||
| @echo " Java Version: $$($(JAVA) -version 2>&1 | head -1)" | ||
| @echo " Maven Version: $$($(MAVEN) -version | head -1)" | ||
|
|
||
| .PHONY: help | ||
| help: ## Display this help message | ||
| @echo "ChromaDB Java Client - Development Tasks" | ||
| @echo "" | ||
| @echo "Usage: make [target]" | ||
| @echo "" | ||
| @awk 'BEGIN {FS = ":.*##"; printf "$(YELLOW)Available targets:$(NC)\n"} \ | ||
| /^[a-zA-Z_-]+:.*?##/ { printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2 } \ | ||
| /^##@/ { printf "\n$(BLUE)%s$(NC)\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
| @echo "" | ||
| @echo "$(YELLOW)Examples:$(NC)" | ||
| @echo " make build # Build the project" | ||
| @echo " make test # Run all tests" | ||
| @echo " make test-version CHROMA_VERSION=0.5.15 # Test with specific version" | ||
| @echo " make test-class TEST=TestAPI # Run specific test class" | ||
| @echo " make help # Show this help" | ||
|
|
||
| # Quick shortcuts | ||
| .PHONY: b | ||
| b: build ## Shortcut for build | ||
|
|
||
| .PHONY: t | ||
| t: test ## Shortcut for test | ||
|
|
||
| .PHONY: c | ||
| c: clean ## Shortcut for clean | ||
|
|
||
| .PHONY: i | ||
| i: install ## Shortcut for install | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file is missing a trailing newline at the end. This can cause issues with some Unix tools and version control systems that expect files to end with a newline character. Adding a blank line after the last line would follow standard file format conventions and prevent potential "No newline at end of file" warnings in git.
Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.