diff --git a/.gitignore b/.gitignore index ee0ff72bc..b6f040de3 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,9 @@ obp-api/src/main/scala/code/api/v3_0_0/custom/ marketing_diagram_generation/outputs/* .bloop +!.bloop/*.json .bsp .specstory project/project coursier -*.code-workspace \ No newline at end of file +*.code-workspace diff --git a/.metals-config.json b/.metals-config.json new file mode 100644 index 000000000..ed54fa647 --- /dev/null +++ b/.metals-config.json @@ -0,0 +1,76 @@ +{ + "maven": { + "enabled": true + }, + "metals": { + "serverVersion": "1.0.0", + "javaHome": "/usr/lib/jvm/java-17-openjdk-amd64", + "bloopVersion": "2.0.0", + "superMethodLensesEnabled": true, + "enableSemanticHighlighting": true, + "compileOnSave": true, + "testUserInterface": "Code Lenses", + "inlayHints": { + "enabled": true, + "hintsInPatternMatch": { + "enabled": true + }, + "implicitArguments": { + "enabled": true + }, + "implicitConversions": { + "enabled": true + }, + "inferredTypes": { + "enabled": true + }, + "typeParameters": { + "enabled": true + } + } + }, + "buildTargets": [ + { + "id": "obp-commons", + "displayName": "obp-commons", + "baseDirectory": "file:///home/marko/Tesobe/GitHub/constantine2nd/OBP-API/obp-commons/", + "tags": ["library"], + "languageIds": ["scala", "java"], + "dependencies": [], + "capabilities": { + "canCompile": true, + "canTest": true, + "canRun": false, + "canDebug": true + }, + "dataKind": "scala", + "data": { + "scalaOrganization": "org.scala-lang", + "scalaVersion": "2.12.20", + "scalaBinaryVersion": "2.12", + "platform": "jvm" + } + }, + { + "id": "obp-api", + "displayName": "obp-api", + "baseDirectory": "file:///home/marko/Tesobe/GitHub/constantine2nd/OBP-API/obp-api/", + "tags": ["application"], + "languageIds": ["scala", "java"], + "dependencies": ["obp-commons"], + "capabilities": { + "canCompile": true, + "canTest": true, + "canRun": true, + "canDebug": true + }, + "dataKind": "scala", + "data": { + "scalaOrganization": "org.scala-lang", + "scalaVersion": "2.12.20", + "scalaBinaryVersion": "2.12", + "platform": "jvm" + } + } + ] +} diff --git a/README.md b/README.md index 7578a692d..5de6baca6 100644 --- a/README.md +++ b/README.md @@ -46,11 +46,22 @@ This project is dual licensed under the AGPL V3 (see NOTICE) and commercial lice The project uses Maven 3 as its build tool. To compile and run Jetty, install Maven 3, create your configuration in `obp-api/src/main/resources/props/default.props` and execute: +To compile and run Jetty, install Maven 3, create your configuration in `obp-api/src/main/resources/props/`, copy `sample.props.template` to `default.props` and edit the latter. Then: ```sh mvn install -pl .,obp-commons && mvn jetty:run -pl obp-api ``` +### ZED IDE Setup + +For ZED IDE users, we provide a complete development environment with Scala language server support: + +```bash +./zed/setup-zed-ide.sh +``` + +This sets up automated build tasks, code navigation, and real-time error checking. See [`zed/README.md`](zed/README.md) for complete documentation. + In case the above command fails try the next one: ```sh @@ -207,6 +218,7 @@ Once Postgres is installed (On macOS, use `brew`): 1. Grant all on database `obpdb` to `obp`; (So OBP-API can create tables etc.) #### For newer versions of postgres 16 and above, you need to follow the following instructions + -- Connect to the sandbox database \c sandbox; diff --git a/zed/.metals-config.json b/zed/.metals-config.json new file mode 100644 index 000000000..ed54fa647 --- /dev/null +++ b/zed/.metals-config.json @@ -0,0 +1,76 @@ +{ + "maven": { + "enabled": true + }, + "metals": { + "serverVersion": "1.0.0", + "javaHome": "/usr/lib/jvm/java-17-openjdk-amd64", + "bloopVersion": "2.0.0", + "superMethodLensesEnabled": true, + "enableSemanticHighlighting": true, + "compileOnSave": true, + "testUserInterface": "Code Lenses", + "inlayHints": { + "enabled": true, + "hintsInPatternMatch": { + "enabled": true + }, + "implicitArguments": { + "enabled": true + }, + "implicitConversions": { + "enabled": true + }, + "inferredTypes": { + "enabled": true + }, + "typeParameters": { + "enabled": true + } + } + }, + "buildTargets": [ + { + "id": "obp-commons", + "displayName": "obp-commons", + "baseDirectory": "file:///home/marko/Tesobe/GitHub/constantine2nd/OBP-API/obp-commons/", + "tags": ["library"], + "languageIds": ["scala", "java"], + "dependencies": [], + "capabilities": { + "canCompile": true, + "canTest": true, + "canRun": false, + "canDebug": true + }, + "dataKind": "scala", + "data": { + "scalaOrganization": "org.scala-lang", + "scalaVersion": "2.12.20", + "scalaBinaryVersion": "2.12", + "platform": "jvm" + } + }, + { + "id": "obp-api", + "displayName": "obp-api", + "baseDirectory": "file:///home/marko/Tesobe/GitHub/constantine2nd/OBP-API/obp-api/", + "tags": ["application"], + "languageIds": ["scala", "java"], + "dependencies": ["obp-commons"], + "capabilities": { + "canCompile": true, + "canTest": true, + "canRun": true, + "canDebug": true + }, + "dataKind": "scala", + "data": { + "scalaOrganization": "org.scala-lang", + "scalaVersion": "2.12.20", + "scalaBinaryVersion": "2.12", + "platform": "jvm" + } + } + ] +} diff --git a/zed/README.md b/zed/README.md index 01060b8f2..88ecd432a 100644 --- a/zed/README.md +++ b/zed/README.md @@ -1,133 +1,298 @@ -# Zed IDE Configuration for OBP-API +# ZED IDE Setup for OBP-API Development -This folder contains the recommended Zed IDE configuration for the OBP-API project. Each developer can set up their own personalized Zed environment while maintaining consistent project settings. +> **Complete ZED IDE integration for the Open Bank Project API** -## Quick Setup +This folder contains everything needed to set up ZED IDE with full Scala language server support, automated build tasks, and streamlined development workflows for OBP-API. -Run the setup script to copy the configuration files to your local `.zed` folder: +## ๐Ÿš€ Quick Setup (5 minutes) + +### Prerequisites + +- **Java 17+** (OpenJDK recommended) +- **Maven 3.6+** +- **ZED IDE** (latest version) + +### Single Setup Script -**Linux/macOS:** ```bash -./zed/setup-zed.sh +cd OBP-API +./zed/setup-zed-ide.sh ``` -**Windows:** -```cmd -zed\setup-zed.bat +This unified script automatically: + +- โœ… Installs missing dependencies (Coursier, Bloop) +- โœ… Compiles the project and resolves dependencies +- โœ… Generates dynamic Bloop configurations +- โœ… Sets up Metals language server +- โœ… Copies ZED configuration files to `.zed/` folder +- โœ… Configures build and run tasks +- โœ… Sets up manual-only code formatting + +## ๐Ÿ“ What's Included + +``` +zed/ +โ”œโ”€โ”€ README.md # This comprehensive guide +โ”œโ”€โ”€ setup-zed-ide.sh # Single unified setup script +โ”œโ”€โ”€ generate-bloop-config.sh # Dynamic Bloop config generator +โ”œโ”€โ”€ settings.json # ZED IDE settings template +โ”œโ”€โ”€ tasks.json # Pre-configured build/run tasks +โ”œโ”€โ”€ .metals-config.json # Metals language server config +โ””โ”€โ”€ setup-zed.bat # Windows setup script ``` -This will create a `.zed` folder in the project root with the recommended settings. +## โŒจ๏ธ Essential Keyboard Shortcuts -## What's Included +| Action | Linux | macOS/Windows | Purpose | +| -------------------- | -------------- | ------------- | ----------------------------- | +| **Command Palette** | `Ctrl+Shift+P` | `Cmd+Shift+P` | Access all tasks | +| **Go to Definition** | `F12` | `F12` | Navigate to symbol definition | +| **Find References** | `Shift+F12` | `Shift+F12` | Find all symbol usages | +| **Quick Open File** | `Ctrl+P` | `Cmd+P` | Fast file navigation | +| **Format Code** | `Ctrl+Shift+I` | `Cmd+Shift+I` | Auto-format Scala code | +| **Symbol Search** | `Ctrl+T` | `Cmd+T` | Search symbols project-wide | -### ๐Ÿ“ Configuration Files +## ๐Ÿ› ๏ธ Available Development Tasks -- **`settings.json`** - IDE settings optimized for Scala/OBP-API development -- **`tasks.json`** - Predefined tasks for building, running, and testing the project +Access via Command Palette (`Ctrl+Shift+P` on Linux, `Cmd+Shift+P` on macOS/Windows) โ†’ `"task: spawn"` (Linux) or `"Tasks: Spawn"` (macOS/Windows): -### โš™๏ธ Key Settings +### Core Development Tasks -- **Format on save: DISABLED** - Preserves your code formatting choices -- **Scala LSP (Metals) configuration** - Optimized for Maven-based Scala projects -- **UI preferences** - Consistent theme, font sizes, and panel layout -- **Semantic highlighting** - Enhanced code readability +| Task | Purpose | Duration | When to Use | +| ---------------------------- | ------------------------ | --------- | ------------------------------------ | +| **Quick Build Dependencies** | Build only dependencies | 1-3 min | First step, after dependency changes | +| **[1] Run OBP-API Server** | Start development server | 3-5 min | Daily development | +| **๐Ÿ”จ Build OBP-API** | Full project build | 2-5 min | After code changes | +| **Run Tests** | Execute test suite | 5-15 min | Before commits | +| **[3] Compile Only** | Quick syntax check | 30s-1 min | During development | -## Available Tasks +### Utility Tasks -Access tasks in Zed with `Cmd/Ctrl + Shift + P` โ†’ "task: spawn" +| Task | Purpose | +| --------------------------------- | ------------------------- | +| **[4] Clean Target Folders** | Remove build artifacts | +| **๐Ÿ”„ Continuous Compile (Scala)** | Auto-recompile on changes | +| **[2] Test API Root Endpoint** | Verify server status | +| **๐Ÿ”ง Kill Server on Port 8080** | Stop stuck processes | +| **๐Ÿ” Check Dependencies** | Verify Maven dependencies | -### ๐Ÿš€ Development Tasks +## ๐Ÿ—๏ธ Development Workflow -| Task | Command | Description | -|------|---------|-------------| -| **[1] Run OBP-API Server** | `mvn jetty:run -pl obp-api` | Starts the OBP-API server on port 8080 | -| **[2] Test API Root Endpoint** | `curl http://localhost:8080/obp/v5.1.0/root` | Quick API health check | -| **[3] Compile Only** | `mvn compile -pl obp-api` | Compiles the project without running tests | +### Daily Development -### ๐Ÿ”จ Build Tasks +1. **Start Development Session** + - Linux: `Ctrl+Shift+P` โ†’ `"task: spawn"` โ†’ `"Quick Build Dependencies"` + - macOS: `Cmd+Shift+P` โ†’ `"Tasks: Spawn"` โ†’ `"Quick Build Dependencies"` -| Task | Command | Description | -|------|---------|-------------| -| **[4] Build OBP-API** | `mvn install -pl .,obp-commons -am -DskipTests` | Full build excluding tests | -| **[5] Clean Target Folders** | `mvn clean` | Removes all compiled artifacts | +2. **Start API Server** + - Use task `"[1] Run OBP-API Server"` + - Server runs on: `http://localhost:8080` + - Test endpoint: `http://localhost:8080/obp/v5.1.0/root` -### ๐Ÿงช Testing & Validation +3. **Code Development** + - Edit Scala files in `obp-api/src/main/scala/` + - Use `F12` for Go to Definition + - Auto-completion with `Ctrl+Space` + - Real-time error highlighting + - Format code with `Ctrl+Shift+I` -| Task | Command | Description | -|------|---------|-------------| -| **[7] Run Tests** | `mvn test -pl obp-api` | Executes the project test suite | -| **[8] Maven Validate** | `mvn validate` | Validates project structure and dependencies | -| **[9] Check Dependencies** | `mvn dependency:resolve` | Downloads and verifies all dependencies | +4. **Testing & Validation** + - Quick compile: `"[3] Compile Only"` task + - Run tests: `"Run Tests"` task + - API testing: `"[2] Test API Root Endpoint"` task -### ๐Ÿ› ๏ธ Utility Tasks +## ๐Ÿ”ง Configuration Details -| Task | Command | Description | -|------|---------|-------------| -| **[6] Kill OBP-API Server** | `lsof -ti:8080 \| xargs kill -9` | Terminates any process running on port 8080 | +### ZED IDE Settings (`settings.json`) -## Typical Development Workflow +- **Format on Save**: DISABLED (manual formatting only - use `Ctrl+Shift+I`) +- **Scala LSP**: Optimized Metals configuration +- **Maven Integration**: Proper MAVEN_OPTS for Java 17+ +- **UI Preferences**: One Dark theme, consistent layout +- **Inlay Hints**: Enabled for better code understanding -1. **Initial Setup**: `[4] Build OBP-API` - Build the project -2. **Development**: `[3] Compile Only` - Quick compilation during development -3. **Testing**: `[1] Run OBP-API Server` โ†’ `[2] Test API Root Endpoint` -4. **Cleanup**: `[6] Kill OBP-API Server` when done +### Build Tasks (`tasks.json`) -## Maven Configuration +All tasks include proper environment variables: -All Maven tasks use optimized JVM settings: -``` +```bash MAVEN_OPTS="-Xss128m --add-opens=java.base/java.util.jar=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED" ``` -These settings resolve Java module system compatibility issues with newer JDK versions. +### Metals LSP (`.metals-config.json`) -## Customization +- **Build Tool**: Maven +- **Bloop Integration**: Dynamic configuration generation +- **Scala Version**: 2.12.20 +- **Java Target**: Java 11 (compatible with Java 17) -The `.zed` folder is in `.gitignore`, so you can: +## ๐Ÿšจ Troubleshooting -- Modify settings without affecting other developers -- Add personal tasks or shortcuts -- Adjust themes, fonts, and UI preferences -- Configure additional language servers +### Common Issues -### Example Customizations +| Problem | Symptom | Solution | +| ------------------------------- | ------------------------------------ | ------------------------------------------------ | +| **Language Server Not Working** | No go-to-definition, no autocomplete | Restart ZED, wait for Metals initialization | +| **Compilation Errors** | Red squiggly lines, build failures | Check Problems panel, run "Clean Target Folders" | +| **Server Won't Start** | Port 8080 busy | Run "Kill Server on Port 8080" task | +| **Out of Memory** | Build fails with heap space error | Already configured in tasks | +| **Missing Dependencies** | Import errors | Run "Check Dependencies" task | -**Add a custom task** (in `.zed/tasks.json`): -```json -{ - "label": "My Custom Task", - "command": "echo", - "args": ["Hello World"], - "use_new_terminal": false -} +### Recovery Procedures + +1. **Full Reset**: + + ```bash + ./zed/setup-zed-ide.sh # Re-run complete setup + ``` + +2. **Regenerate Bloop Configurations**: + + ```bash + ./zed/generate-bloop-config.sh # Regenerate configs + ``` + +3. **Clean Restart**: + - Clean build with "Clean Target Folders" task + - Restart ZED IDE + - Wait for Metals to reinitialize (2-3 minutes) + +### Platform-Specific Notes + +#### Linux Users + +- Use `"task: spawn"` in command palette (not `"Tasks: Spawn"`) +- Ensure proper Java permissions for Maven + +#### macOS/Windows Users + +- Use `"Tasks: Spawn"` in command palette +- Windows users can also use `setup-zed.bat` + +## ๐ŸŒ API Development + +### Project Structure + +``` +OBP-API/ +โ”œโ”€โ”€ obp-api/ # Main API application +โ”‚ โ””โ”€โ”€ src/main/scala/ # Scala source code +โ”‚ โ””โ”€โ”€ code/api/ # API endpoint definitions +โ”‚ โ”œโ”€โ”€ v5_1_0/ # Latest API version +โ”‚ โ”œโ”€โ”€ v4_0_0/ # Previous versions +โ”‚ โ””โ”€โ”€ util/ # Utility functions +โ”œโ”€โ”€ obp-commons/ # Shared utilities and models +โ”‚ โ””โ”€โ”€ src/main/scala/ # Common Scala code +โ””โ”€โ”€ .zed/ # ZED IDE configuration (generated) ``` -**Change theme** (in `.zed/settings.json`): -```json -{ - "theme": "Ayu Dark" -} -``` +### Adding New API Endpoints -## Troubleshooting +1. Navigate to `obp-api/src/main/scala/code/api/v5_1_0/` +2. Find appropriate API trait (e.g., `OBPAPI5_1_0.scala`) +3. Follow existing endpoint patterns +4. Use `F12` to navigate to helper functions +5. Test with API test task + +### Testing Endpoints -### Port 8080 Already in Use ```bash -# Use task [6] or run manually: -lsof -ti:8080 | xargs kill -9 +# Root API information +curl http://localhost:8080/obp/v5.1.0/root + +# Health check +curl http://localhost:8080/obp/v5.1.0/config + +# Banks list (requires proper setup) +curl http://localhost:8080/obp/v5.1.0/banks ``` -### Metals LSP Issues -1. Restart Zed IDE -2. Run `[8] Maven Validate` to ensure project structure is correct -3. Check that Java 11+ is installed and configured +## ๐ŸŽฏ Pro Tips -### Build Failures -1. Run `[5] Clean Target Folders` -2. Run `[9] Check Dependencies` -3. Run `[4] Build OBP-API` +### Code Navigation -## Support +- **Quick file access**: `Ctrl+P` then type filename +- **Symbol search**: `Ctrl+T` then type function/class name +- **Project-wide text search**: `Ctrl+Shift+F` -For Zed IDE-specific issues, consult the [Zed documentation](https://zed.dev/docs). -For OBP-API project issues, refer to the main project README. \ No newline at end of file +### Efficiency Shortcuts + +- `Ctrl+/` - Toggle line comment +- `Ctrl+D` - Select next occurrence +- `Ctrl+Shift+L` - Select all occurrences +- `F2` - Rename symbol +- `Alt+โ†/โ†’` - Navigate back/forward + +### Performance Optimization + +- Close unused files to reduce memory usage +- Use "Continuous Compile" for faster feedback +- Limit test runs to specific modules during development + +## ๐Ÿ“š Additional Resources + +### Documentation + +- **OBP-API Project**: https://github.com/OpenBankProject/OBP-API +- **API Documentation**: https://apiexplorer.openbankproject.com +- **Community Forums**: https://openbankproject.com + +### Learning Resources + +- **Scala**: https://docs.scala-lang.org/ +- **Lift Framework**: https://liftweb.net/ +- **Maven**: https://maven.apache.org/guides/ +- **ZED IDE**: https://zed.dev/docs + +## ๐Ÿ†˜ Getting Help + +### Diagnostic Commands + +```bash +# Check Java version +java -version + +# Check Maven +mvn -version + +# Check Bloop status +bloop projects + +# Test compilation +bloop compile obp-commons obp-api + +# Check ZED configuration +ls -la .zed/ +``` + +### Common Error Messages + +| Error | Cause | Solution | +| --------------------------- | ----------------------------- | ----------------------------- | +| "Java module system" errors | Java 17+ module restrictions | Already handled in MAVEN_OPTS | +| "Port 8080 already in use" | Previous server still running | Use "Kill Server" task | +| "Metals not responding" | Language server crashed | Restart ZED IDE | +| "Compilation failed" | Dependency issues | Run "Check Dependencies" | + +--- + +## ๐ŸŽ‰ Getting Started Checklist + +- [ ] Install Java 17+, Maven 3.6+, ZED IDE +- [ ] Clone OBP-API repository +- [ ] Run `./zed/setup-zed-ide.sh` (single setup script) +- [ ] Open project in ZED IDE +- [ ] Wait for Metals initialization (2-3 minutes) +- [ ] Run "Quick Build Dependencies" task +- [ ] Start server with "[1] Run OBP-API Server" task +- [ ] Test API at http://localhost:8080/obp/v5.1.0/root +- [ ] Try "Go to Definition" (F12) on Scala symbol +- [ ] Format code manually with `Ctrl+Shift+I` (auto-format disabled) +- [ ] Make a small code change and test compilation + +**Welcome to productive OBP-API development with ZED IDE! ๐Ÿš€** + +--- + +_This setup provides a complete, optimized development environment for the Open Bank Project API using ZED IDE with full Scala language server support._ diff --git a/zed/generate-bloop-config.sh b/zed/generate-bloop-config.sh new file mode 100755 index 000000000..698e7d6ae --- /dev/null +++ b/zed/generate-bloop-config.sh @@ -0,0 +1,263 @@ +#!/bin/bash + +# Generate portable Bloop configuration files for OBP-API +# This script creates Bloop JSON configurations with proper paths for any system + +set -e + +echo "๐Ÿ”ง Generating Bloop configuration files..." + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Get the project root directory (parent of zed folder) +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +echo "๐Ÿ“ Project root: $PROJECT_ROOT" + +# Check if we're in the zed directory and project structure exists +if [[ ! -f "$PROJECT_ROOT/pom.xml" ]] || [[ ! -d "$PROJECT_ROOT/obp-api" ]] || [[ ! -d "$PROJECT_ROOT/obp-commons" ]]; then + echo -e "${RED}โŒ Error: Could not find OBP-API project structure${NC}" + echo "Make sure you're running this from the zed/ folder of the OBP-API project" + exit 1 +fi + +# Change to project root for Maven operations +cd "$PROJECT_ROOT" + +# Detect Java home +if [[ -z "$JAVA_HOME" ]]; then + JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) + echo -e "${YELLOW}โš ๏ธ JAVA_HOME not set, detected: $JAVA_HOME${NC}" +else + echo -e "${GREEN}โœ… JAVA_HOME: $JAVA_HOME${NC}" +fi + +# Get Maven local repository +M2_REPO=$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout 2>/dev/null || echo "$HOME/.m2/repository") +echo "๐Ÿ“ฆ Maven repository: $M2_REPO" + +# Ensure .bloop directory exists in project root +mkdir -p "$PROJECT_ROOT/.bloop" + +# Generate obp-commons.json +echo "๐Ÿ”จ Generating obp-commons configuration..." +cat > "$PROJECT_ROOT/.bloop/obp-commons.json" << EOF +{ + "version": "1.5.5", + "project": { + "name": "obp-commons", + "directory": "${PROJECT_ROOT}/obp-commons", + "workspaceDir": "${PROJECT_ROOT}", + "sources": [ + "${PROJECT_ROOT}/obp-commons/src/main/scala", + "${PROJECT_ROOT}/obp-commons/src/main/java" + ], + "dependencies": [], + "classpath": [ + "${PROJECT_ROOT}/obp-commons/target/classes", + "${M2_REPO}/net/liftweb/lift-common_2.12/3.5.0/lift-common_2.12-3.5.0.jar", + "${M2_REPO}/org/scala-lang/scala-library/2.12.12/scala-library-2.12.12.jar", + "${M2_REPO}/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar", + "${M2_REPO}/org/scala-lang/modules/scala-xml_2.12/1.3.0/scala-xml_2.12-1.3.0.jar", + "${M2_REPO}/org/scala-lang/modules/scala-parser-combinators_2.12/1.1.2/scala-parser-combinators_2.12-1.1.2.jar", + "${M2_REPO}/net/liftweb/lift-util_2.12/3.5.0/lift-util_2.12-3.5.0.jar", + "${M2_REPO}/org/scala-lang/scala-compiler/2.12.12/scala-compiler-2.12.12.jar", + "${M2_REPO}/net/liftweb/lift-actor_2.12/3.5.0/lift-actor_2.12-3.5.0.jar", + "${M2_REPO}/net/liftweb/lift-markdown_2.12/3.5.0/lift-markdown_2.12-3.5.0.jar", + "${M2_REPO}/joda-time/joda-time/2.10/joda-time-2.10.jar", + "${M2_REPO}/org/joda/joda-convert/2.1/joda-convert-2.1.jar", + "${M2_REPO}/commons-codec/commons-codec/1.11/commons-codec-1.11.jar", + "${M2_REPO}/nu/validator/htmlparser/1.4.12/htmlparser-1.4.12.jar", + "${M2_REPO}/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0.jar", + "${M2_REPO}/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar", + "${M2_REPO}/org/mindrot/jbcrypt/0.4/jbcrypt-0.4.jar", + "${M2_REPO}/net/liftweb/lift-mapper_2.12/3.5.0/lift-mapper_2.12-3.5.0.jar", + "${M2_REPO}/net/liftweb/lift-db_2.12/3.5.0/lift-db_2.12-3.5.0.jar", + "${M2_REPO}/net/liftweb/lift-webkit_2.12/3.5.0/lift-webkit_2.12-3.5.0.jar", + "${M2_REPO}/commons-fileupload/commons-fileupload/1.3.3/commons-fileupload-1.3.3.jar", + "${M2_REPO}/commons-io/commons-io/2.2/commons-io-2.2.jar", + "${M2_REPO}/org/mozilla/rhino/1.7.10/rhino-1.7.10.jar", + "${M2_REPO}/net/liftweb/lift-proto_2.12/3.5.0/lift-proto_2.12-3.5.0.jar", + "${M2_REPO}/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar", + "${M2_REPO}/org/scalatest/scalatest_2.12/3.0.8/scalatest_2.12-3.0.8.jar", + "${M2_REPO}/org/scalactic/scalactic_2.12/3.0.8/scalactic_2.12-3.0.8.jar", + "${M2_REPO}/net/liftweb/lift-json_2.12/3.5.0/lift-json_2.12-3.5.0.jar", + "${M2_REPO}/org/scala-lang/scalap/2.12.12/scalap-2.12.12.jar", + "${M2_REPO}/com/thoughtworks/paranamer/paranamer/2.8/paranamer-2.8.jar", + "${M2_REPO}/com/alibaba/transmittable-thread-local/2.11.5/transmittable-thread-local-2.11.5.jar", + "${M2_REPO}/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar", + "${M2_REPO}/org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar", + "${M2_REPO}/com/google/guava/guava/32.0.0-jre/guava-32.0.0-jre.jar", + "${M2_REPO}/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "${M2_REPO}/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "${M2_REPO}/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", + "${M2_REPO}/org/checkerframework/checker-qual/3.33.0/checker-qual-3.33.0.jar", + "${M2_REPO}/com/google/errorprone/error_prone_annotations/2.18.0/error_prone_annotations-2.18.0.jar", + "${M2_REPO}/com/google/j2objc/j2objc-annotations/2.8/j2objc-annotations-2.8.jar" + ], + "out": "${PROJECT_ROOT}/obp-commons/target/classes", + "classesDir": "${PROJECT_ROOT}/obp-commons/target/classes", + "resources": [ + "${PROJECT_ROOT}/obp-commons/src/main/resources" + ], + "scala": { + "organization": "org.scala-lang", + "name": "scala-compiler", + "version": "2.12.20", + "options": [ + "-unchecked", + "-explaintypes", + "-encoding", + "UTF-8", + "-feature" + ], + "jars": [ + "${M2_REPO}/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20.jar", + "${M2_REPO}/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20.jar", + "${M2_REPO}/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar" + ], + "analysis": "${PROJECT_ROOT}/obp-commons/target/bloop-bsp-clients-classes/classes-Metals-", + "setup": { + "order": "mixed", + "addLibraryToBootClasspath": true, + "addCompilerToClasspath": false, + "addExtraJarsToClasspath": false, + "manageBootClasspath": true, + "filterLibraryFromClasspath": true + } + }, + "java": { + "options": ["-source", "11", "-target", "11"] + }, + "platform": { + "name": "jvm", + "config": { + "home": "${JAVA_HOME}", + "options": [] + }, + "mainClass": [] + }, + "resolution": { + "modules": [] + }, + "tags": ["library"] + } +} +EOF + +# Generate obp-api.json +echo "๐Ÿ”จ Generating obp-api configuration..." +cat > "$PROJECT_ROOT/.bloop/obp-api.json" << EOF +{ + "version": "1.5.5", + "project": { + "name": "obp-api", + "directory": "${PROJECT_ROOT}/obp-api", + "workspaceDir": "${PROJECT_ROOT}", + "sources": [ + "${PROJECT_ROOT}/obp-api/src/main/scala", + "${PROJECT_ROOT}/obp-api/src/main/java" + ], + "dependencies": ["obp-commons"], + "classpath": [ + "${PROJECT_ROOT}/obp-api/target/classes", + "${PROJECT_ROOT}/obp-commons/target/classes", + "${M2_REPO}/com/tesobe/obp-commons/1.10.1/obp-commons-1.10.1.jar", + "${M2_REPO}/net/liftweb/lift-common_2.12/3.5.0/lift-common_2.12-3.5.0.jar", + "${M2_REPO}/org/scala-lang/scala-library/2.12.12/scala-library-2.12.12.jar", + "${M2_REPO}/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar", + "${M2_REPO}/org/scala-lang/modules/scala-xml_2.12/1.3.0/scala-xml_2.12-1.3.0.jar", + "${M2_REPO}/net/liftweb/lift-util_2.12/3.5.0/lift-util_2.12-3.5.0.jar", + "${M2_REPO}/org/scala-lang/scala-compiler/2.12.12/scala-compiler-2.12.12.jar", + "${M2_REPO}/net/liftweb/lift-mapper_2.12/3.5.0/lift-mapper_2.12-3.5.0.jar", + "${M2_REPO}/net/liftweb/lift-json_2.12/3.5.0/lift-json_2.12-3.5.0.jar", + "${M2_REPO}/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar", + "${M2_REPO}/net/databinder/dispatch/dispatch-lift-json_2.12/0.13.1/dispatch-lift-json_2.12-0.13.1.jar", + "${M2_REPO}/ch/qos/logback/logback-classic/1.2.13/logback-classic-1.2.13.jar", + "${M2_REPO}/org/slf4j/log4j-over-slf4j/1.7.26/log4j-over-slf4j-1.7.26.jar", + "${M2_REPO}/org/slf4j/slf4j-ext/1.7.26/slf4j-ext-1.7.26.jar", + "${M2_REPO}/org/bouncycastle/bcpg-jdk15on/1.70/bcpg-jdk15on-1.70.jar", + "${M2_REPO}/org/bouncycastle/bcpkix-jdk15on/1.70/bcpkix-jdk15on-1.70.jar", + "${M2_REPO}/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar", + "${M2_REPO}/org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar", + "${M2_REPO}/com/github/everit-org/json-schema/org.everit.json.schema/1.6.1/org.everit.json.schema-1.6.1.jar" + ], + "out": "${PROJECT_ROOT}/obp-api/target/classes", + "classesDir": "${PROJECT_ROOT}/obp-api/target/classes", + "resources": [ + "${PROJECT_ROOT}/obp-api/src/main/resources" + ], + "scala": { + "organization": "org.scala-lang", + "name": "scala-compiler", + "version": "2.12.20", + "options": [ + "-unchecked", + "-explaintypes", + "-encoding", + "UTF-8", + "-feature" + ], + "jars": [ + "${M2_REPO}/org/scala-lang/scala-library/2.12.20/scala-library-2.12.20.jar", + "${M2_REPO}/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20.jar", + "${M2_REPO}/org/scala-lang/scala-reflect/2.12.20/scala-reflect-2.12.20.jar" + ], + "analysis": "${PROJECT_ROOT}/obp-api/target/bloop-bsp-clients-classes/classes-Metals-", + "setup": { + "order": "mixed", + "addLibraryToBootClasspath": true, + "addCompilerToClasspath": false, + "addExtraJarsToClasspath": false, + "manageBootClasspath": true, + "filterLibraryFromClasspath": true + } + }, + "java": { + "options": ["-source", "11", "-target", "11"] + }, + "platform": { + "name": "jvm", + "config": { + "home": "${JAVA_HOME}", + "options": [] + }, + "mainClass": [] + }, + "resolution": { + "modules": [] + }, + "tags": ["application"] + } +} +EOF + +echo -e "${GREEN}โœ… Generated $PROJECT_ROOT/.bloop/obp-commons.json${NC}" +echo -e "${GREEN}โœ… Generated $PROJECT_ROOT/.bloop/obp-api.json${NC}" + +# Verify the configurations +echo "๐Ÿ” Verifying generated configurations..." +if command -v bloop &> /dev/null; then + if bloop projects | grep -q "obp-api\|obp-commons"; then + echo -e "${GREEN}โœ… Bloop can detect the projects${NC}" + else + echo -e "${YELLOW}โš ๏ธ Bloop server may need to be restarted to detect new configurations${NC}" + echo "Run: pkill -f bloop && bloop server &" + fi +else + echo -e "${YELLOW}โš ๏ธ Bloop not found, skipping verification${NC}" +fi + +echo "" +echo -e "${GREEN}๐ŸŽ‰ Bloop configuration generation complete!${NC}" +echo "" +echo "๐Ÿ“‹ Next steps:" +echo "1. Restart Bloop server if needed: pkill -f bloop && bloop server &" +echo "2. Verify projects are detected: bloop projects" +echo "3. Test compilation: bloop compile obp-commons obp-api" +echo "4. Open project in Zed IDE for full language server support" +echo "" +echo -e "${GREEN}Happy coding! ๐Ÿš€${NC}" diff --git a/zed/settings.json b/zed/settings.json index bc099bd3a..afafc18d5 100644 --- a/zed/settings.json +++ b/zed/settings.json @@ -61,8 +61,7 @@ "metals.sbtScript": "", "metals.scalafmtConfigPath": ".scalafmt.conf", "metals.enableSemanticHighlighting": true, - "metals.allowMultilineStringFormatting": false, - "metals.formattingProvider": "none", + "metals.allowMultilineStringFormatting": true, "metals.inlayHints.enabled": true, "metals.inlayHints.hintsInPatternMatch.enabled": true, "metals.inlayHints.implicitArguments.enabled": true, diff --git a/zed/setup-zed-ide.sh b/zed/setup-zed-ide.sh new file mode 100755 index 000000000..870345bc2 --- /dev/null +++ b/zed/setup-zed-ide.sh @@ -0,0 +1,221 @@ +#!/bin/bash + +# ZED IDE Complete Setup Script for OBP-API +# This script provides a unified setup for ZED IDE with full Scala language server support + +set -e + +echo "๐Ÿš€ Setting up ZED IDE for OBP-API Scala development..." + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Get the project root directory (parent of zed folder) +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +echo "๐Ÿ“ Project root: $PROJECT_ROOT" + +# Check if we're in the zed directory and project structure exists +if [[ ! -f "$PROJECT_ROOT/pom.xml" ]] || [[ ! -d "$PROJECT_ROOT/obp-api" ]] || [[ ! -d "$PROJECT_ROOT/obp-commons" ]]; then + echo -e "${RED}โŒ Error: Could not find OBP-API project structure${NC}" + echo "Make sure you're running this from the zed/ folder of the OBP-API project" + exit 1 +fi + +# Change to project root for Maven operations +cd "$PROJECT_ROOT" + +echo "๐Ÿ“ Working directory: $(pwd)" + +# Check prerequisites +echo "๐Ÿ” Checking prerequisites..." + +# Check Java +if ! command -v java &> /dev/null; then + echo -e "${RED}โŒ Java not found. Please install Java 11 or 17${NC}" + exit 1 +fi + +JAVA_VERSION=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | cut -d'.' -f1-2) +echo -e "${GREEN}โœ… Java found: ${JAVA_VERSION}${NC}" + +# Check Maven +if ! command -v mvn &> /dev/null; then + echo -e "${RED}โŒ Maven not found. Please install Maven${NC}" + exit 1 +fi + +MVN_VERSION=$(mvn -version 2>&1 | head -1 | cut -d' ' -f3) +echo -e "${GREEN}โœ… Maven found: ${MVN_VERSION}${NC}" + +# Check Coursier +if ! command -v cs &> /dev/null; then + echo -e "${YELLOW}โš ๏ธ Coursier not found. Installing...${NC}" + curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs + chmod +x cs + sudo mv cs /usr/local/bin/ + echo -e "${GREEN}โœ… Coursier installed${NC}" +else + echo -e "${GREEN}โœ… Coursier found${NC}" +fi + +# Check/Install Bloop +if ! command -v bloop &> /dev/null; then + echo -e "${YELLOW}โš ๏ธ Bloop not found. Installing...${NC}" + cs install bloop + echo -e "${GREEN}โœ… Bloop installed${NC}" +else + echo -e "${GREEN}โœ… Bloop found: $(bloop about | head -1)${NC}" +fi + +# Start Bloop server if not running +if ! pgrep -f "bloop.*server" > /dev/null; then + echo "๐Ÿ”ง Starting Bloop server..." + bloop server & + sleep 3 + echo -e "${GREEN}โœ… Bloop server started${NC}" +else + echo -e "${GREEN}โœ… Bloop server already running${NC}" +fi + +# Compile the project to ensure dependencies are resolved +echo "๐Ÿ”จ Compiling Maven project (this may take a few minutes)..." +if mvn compile -q; then + echo -e "${GREEN}โœ… Maven compilation successful${NC}" +else + echo -e "${RED}โŒ Maven compilation failed. Please fix compilation errors first.${NC}" + exit 1 +fi + +# Copy ZED configuration files to project root +echo "๐Ÿ“‹ Setting up ZED IDE configuration..." +ZED_DIR="$PROJECT_ROOT/.zed" +ZED_SRC_DIR="$PROJECT_ROOT/zed" + +# Create .zed directory if it doesn't exist +if [ ! -d "$ZED_DIR" ]; then + echo "๐Ÿ“ Creating .zed directory..." + mkdir -p "$ZED_DIR" +else + echo "๐Ÿ“ .zed directory already exists" +fi + +# Copy settings.json +if [ -f "$ZED_SRC_DIR/settings.json" ]; then + echo "โš™๏ธ Copying settings.json..." + cp "$ZED_SRC_DIR/settings.json" "$ZED_DIR/settings.json" + echo -e "${GREEN}โœ… settings.json copied successfully${NC}" +else + echo -e "${RED}โŒ Error: settings.json not found in zed folder${NC}" + exit 1 +fi + +# Copy tasks.json +if [ -f "$ZED_SRC_DIR/tasks.json" ]; then + echo "๐Ÿ“‹ Copying tasks.json..." + cp "$ZED_SRC_DIR/tasks.json" "$ZED_DIR/tasks.json" + echo -e "${GREEN}โœ… tasks.json copied successfully${NC}" +else + echo -e "${RED}โŒ Error: tasks.json not found in zed folder${NC}" + exit 1 +fi + +# Copy .metals-config.json if it exists +if [[ -f "$ZED_SRC_DIR/.metals-config.json" ]]; then + echo "๐Ÿ”ง Copying Metals configuration..." + cp "$ZED_SRC_DIR/.metals-config.json" "$PROJECT_ROOT/.metals-config.json" + echo -e "${GREEN}โœ… Metals configuration copied${NC}" +fi + +echo -e "${GREEN}โœ… ZED configuration files copied to .zed/ folder${NC}" + +# Generate Bloop configuration files dynamically +echo "๐Ÿ”ง Generating Bloop configuration files..." +if [[ -f "$ZED_SRC_DIR/generate-bloop-config.sh" ]]; then + chmod +x "$ZED_SRC_DIR/generate-bloop-config.sh" + "$ZED_SRC_DIR/generate-bloop-config.sh" + echo -e "${GREEN}โœ… Bloop configuration files generated${NC}" +else + # Fallback: Check if existing configurations are present + if [[ -f "$PROJECT_ROOT/.bloop/obp-commons.json" && -f "$PROJECT_ROOT/.bloop/obp-api.json" ]]; then + echo -e "${GREEN}โœ… Bloop configuration files already exist${NC}" + else + echo -e "${RED}โŒ Bloop configuration files missing and generator not found.${NC}" + echo "Please ensure .bloop/*.json files exist or run zed/generate-bloop-config.sh manually" + exit 1 + fi +fi + +# Restart Bloop server to pick up new configurations +echo "๐Ÿ”„ Restarting Bloop server to detect new configurations..." +pkill -f bloop 2>/dev/null || true +sleep 1 +bloop server & +sleep 2 + +# Verify Bloop can see projects +echo "๐Ÿ” Verifying Bloop projects..." +BLOOP_PROJECTS=$(bloop projects 2>/dev/null || echo "") +if [[ "$BLOOP_PROJECTS" == *"obp-api"* && "$BLOOP_PROJECTS" == *"obp-commons"* ]]; then + echo -e "${GREEN}โœ… Bloop projects detected:${NC}" + echo "$BLOOP_PROJECTS" | sed 's/^/ /' +else + echo -e "${YELLOW}โš ๏ธ Bloop projects not immediately detected. This is normal for fresh setups.${NC}" + echo "The configuration should work when you open ZED IDE." +fi + +# Test Bloop compilation +echo "๐Ÿงช Testing Bloop compilation..." +if bloop compile obp-commons > /dev/null 2>&1; then + echo -e "${GREEN}โœ… Bloop compilation test successful${NC}" +else + echo -e "${YELLOW}โš ๏ธ Bloop compilation test failed, but setup is complete. Try restarting ZED IDE.${NC}" +fi + +# Check ZED configuration +if [[ -f "$PROJECT_ROOT/.zed/settings.json" ]]; then + echo -e "${GREEN}โœ… ZED configuration found${NC}" +else + echo -e "${YELLOW}โš ๏ธ ZED configuration not found in .zed/settings.json${NC}" +fi + +echo "" +echo -e "${GREEN}๐ŸŽ‰ ZED IDE setup completed successfully!${NC}" +echo "" +echo "Your ZED configuration includes:" +echo " โ€ข Format on save: DISABLED (manual formatting only - use Ctrl+Shift+I)" +echo " โ€ข Scala/Metals LSP configuration optimized for OBP-API" +echo " โ€ข Pre-configured build and run tasks" +echo " โ€ข Dynamic Bloop configuration for language server support" +echo "" +echo "๐Ÿ“‹ Next steps:" +echo "1. Open ZED IDE" +echo "2. Open the OBP-API project directory in ZED" +echo "3. Wait for Metals to initialize (may take a few minutes)" +echo "4. Try 'Go to Definition' on a Scala symbol (F12 or Cmd+Click)" +echo "" +echo "๐Ÿ› ๏ธ Available tasks (access with Cmd/Ctrl + Shift + P โ†’ 'task: spawn'):" +echo " โ€ข [1] Run OBP-API Server - Start development server" +echo " โ€ข [2] Test API Root Endpoint - Quick health check" +echo " โ€ข [3] Compile Only - Fast syntax check" +echo " โ€ข [4] Clean Target Folders - Remove build artifacts" +echo " โ€ข Quick Build Dependencies - Build deps only (for onboarding)" +echo " โ€ข Run Tests - Execute full test suite" +echo "" +echo "๐Ÿ’ก Troubleshooting:" +echo "โ€ข If 'Go to Definition' doesn't work immediately, restart ZED IDE" +echo "โ€ข Use 'ZED: Reload Window' from the command palette if needed" +echo "โ€ข Check zed/README.md for comprehensive documentation" +echo "โ€ข Run './zed/generate-bloop-config.sh' to regenerate configurations if needed" +echo "" +echo "๐Ÿ”— Resources:" +echo "โ€ข Complete ZED setup guide: zed/README.md" +echo "โ€ข Bloop projects: bloop projects" +echo "โ€ข Bloop compilation: bloop compile obp-commons obp-api" +echo "" +echo "Note: The .zed folder is in .gitignore, so you can customize settings" +echo " without affecting other developers." +echo "" +echo -e "${GREEN}Happy coding! ๐Ÿš€${NC}" diff --git a/zed/setup-zed.sh b/zed/setup-zed.sh deleted file mode 100755 index e5d66601e..000000000 --- a/zed/setup-zed.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -# Zed IDE Setup Script for OBP-API -# This script copies the recommended Zed configuration to your local .zed folder - -set -e - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" -ZED_DIR="$PROJECT_ROOT/.zed" - -echo "๐Ÿ”ง Setting up Zed IDE configuration for OBP-API..." - -# Create .zed directory if it doesn't exist -if [ ! -d "$ZED_DIR" ]; then - echo "๐Ÿ“ Creating .zed directory..." - mkdir -p "$ZED_DIR" -else - echo "๐Ÿ“ .zed directory already exists" -fi - -# Copy settings.json -if [ -f "$SCRIPT_DIR/settings.json" ]; then - echo "โš™๏ธ Copying settings.json..." - cp "$SCRIPT_DIR/settings.json" "$ZED_DIR/settings.json" - echo "โœ… settings.json copied successfully" -else - echo "โŒ Error: settings.json not found in zed folder" - exit 1 -fi - -# Copy tasks.json -if [ -f "$SCRIPT_DIR/tasks.json" ]; then - echo "๐Ÿ“‹ Copying tasks.json..." - cp "$SCRIPT_DIR/tasks.json" "$ZED_DIR/tasks.json" - echo "โœ… tasks.json copied successfully" -else - echo "โŒ Error: tasks.json not found in zed folder" - exit 1 -fi - -echo "" -echo "๐ŸŽ‰ Zed IDE setup completed successfully!" -echo "" -echo "Your Zed configuration includes:" -echo " โ€ข Format on save: DISABLED (preserves your code formatting)" -echo " โ€ข Scala/Metals LSP configuration optimized for OBP-API" -echo " โ€ข 9 predefined tasks for building, running, and testing" -echo "" -echo "To see available tasks in Zed, use: Cmd/Ctrl + Shift + P โ†’ 'task: spawn'" -echo "" -echo "Note: The .zed folder is in .gitignore, so you can customize settings" -echo " without affecting other developers." \ No newline at end of file