From 8d9acdbb7c0d7205b433114f6aac212e48e5ea22 Mon Sep 17 00:00:00 2001 From: Shawn Hurley Date: Thu, 26 Mar 2026 15:39:35 -0400 Subject: [PATCH 1/2] docs: comprehensive update of integration test documentation Audit all test documentation against actual code and fix numerous stale references accumulated as tests were added without doc updates. Key corrections: - Unit test count: 48 -> 76 (add 5 undocumented test classes) - Integration sub-test count: 43 -> 47 (account for table-driven tests) - Query count: 40+ -> 47 (precise count from code) - PackageDeclarationSearch queries: 2 -> 8 - test-project file count: 6-8 -> 19 (full listing) - JDT.LS version: fix stale 1.35.0/1.38.0 refs to 1.51.0 - Fix useUIHarness: true -> false (match actual pom.xml) - Fix nonexistent doc path: integration/README.md -> docs/integration-tests.md - Fix go.mod dependency version: v0.4.0-alpha.1 -> v0.8.0 Clarify two-Dockerfile setup: - CI uses default Dockerfile (self-contained, builds JAR from source) - Local dev uses Dockerfile.test (requires pre-built JAR, pre-installs Go) - Add mvn install prerequisite to all local container build instructions - Remove unnecessary runtime golang install from Dockerfile.test commands Other fixes: - Replace stale Phase 1/2/3 planning sections with completed milestones - Fix test assertions API (referenced nonexistent test_utils.go) - Replace fake expected output with actual Go test framework format - Clean up stale 1.18.0 comment in target platform file Signed-off-by: Shawn Hurley --- java-analyzer-bundle.test/README.md | 27 +- java-analyzer-bundle.test/docs/README.md | 17 +- .../docs/integration-tests.md | 232 ++++++++---------- .../docs/query-reference.md | 33 ++- .../docs/quick-reference.md | 48 +++- .../docs/test-projects.md | 91 +++---- .../java-analyzer-bundle.target | 14 +- 7 files changed, 248 insertions(+), 214 deletions(-) diff --git a/java-analyzer-bundle.test/README.md b/java-analyzer-bundle.test/README.md index e5f76c8c..34e11e1a 100644 --- a/java-analyzer-bundle.test/README.md +++ b/java-analyzer-bundle.test/README.md @@ -16,7 +16,7 @@ make phase2 # Integration tests only ### Run Specific Tests ```bash -# Maven unit tests (48 tests) +# Maven unit tests (76 tests) mvn clean integration-test # Go integration tests (specific test) @@ -31,12 +31,17 @@ This module contains two phases of testing: ### Phase 1: Unit Tests (Maven/JUnit) **Location**: `src/main/java/` **Technology**: JUnit-Plugin (runs in Eclipse environment) -**Count**: 48 tests +**Count**: 76 tests -Tests command handling, parameter parsing, and error cases: +Tests command handling, parameter parsing, AST visitors, symbol providers, and error cases: - `RuleEntryParamsTest` (14 tests) - `AnnotationQueryTest` (18 tests) - `SampleDelegateCommandHandlerTest` (16 tests) +- `CustomASTVisitorTest` (16 tests) +- `MethodDeclarationSymbolProviderTest` (8 tests) +- `CommandHandlerTest` (2 tests) +- `JavaAnnotationTest` (1 test) +- `PomDependencyTest` (1 test) **Run**: `mvn clean integration-test` @@ -132,7 +137,7 @@ Real-world Spring MVC application: - **Java 17** - Target platform and tests - **Eclipse Tycho 3.0.1** - Build system -- **JDT.LS 1.35.0** - Language server +- **JDT.LS 1.51.0** - Language server - **Go 1.21+** - Integration test framework - **Podman/Docker** - Container runtime for CI/CD - **JUnit 4** - Unit test framework @@ -179,7 +184,7 @@ java-analyzer-bundle.test/ org.eclipse.tycho tycho-surefire-plugin - true + false false @@ -193,7 +198,12 @@ java-analyzer-bundle.test/ **Two-Phase Execution**: 1. **Phase 1**: Maven unit tests (`mvn clean integration-test`) -2. **Phase 2**: Build container β†’ Go integration tests +2. **Phase 2**: Build self-contained container (default `Dockerfile`) β†’ Go integration tests + +**Container Images**: +- **CI** uses the default `Dockerfile` which builds the plugin JAR from source inside the container +- **Local** (`make phase2`) uses `Dockerfile.test` which expects a pre-built JAR on the host +- Both produce equivalent images with JDT.LS + the analyzer plugin **Triggers**: - Push to `main` or `maven-index` branches @@ -242,8 +252,9 @@ go test -v -run TestSpecificTest ### Build Test Container ```bash -# From repository root -podman build -t jdtls-analyzer:test . +# From repository root (requires pre-built JAR via mvn install) +mvn clean install -DskipTests +podman build -t jdtls-analyzer:test -f Dockerfile.test . ``` --- diff --git a/java-analyzer-bundle.test/docs/README.md b/java-analyzer-bundle.test/docs/README.md index 73961819..5a71b5db 100644 --- a/java-analyzer-bundle.test/docs/README.md +++ b/java-analyzer-bundle.test/docs/README.md @@ -125,15 +125,20 @@ Detailed overview of the Java test projects: ## πŸ§ͺ Test Structure -### Phase 1: Maven Unit Tests (48 tests) +### Phase 1: Maven Unit Tests (76 tests) **Location**: `../src/main/java/` **Framework**: JUnit-Plugin -**Coverage**: Command handling, parameter parsing, error cases +**Coverage**: Command handling, parameter parsing, AST visitors, symbol providers, error cases **Tests**: - `RuleEntryParamsTest` (14 tests) - `AnnotationQueryTest` (18 tests) - `SampleDelegateCommandHandlerTest` (16 tests) +- `CustomASTVisitorTest` (16 tests) +- `MethodDeclarationSymbolProviderTest` (8 tests) +- `CommandHandlerTest` (2 tests) +- `JavaAnnotationTest` (1 test) +- `PomDependencyTest` (1 test) **Run**: `mvn clean integration-test` @@ -171,8 +176,8 @@ Detailed overview of the Java test projects: ## πŸ—οΈ Test Projects ### test-project -**Purpose**: Systematic coverage of all location types -**Files**: 8 Java files covering all 15 location types +**Purpose**: Systematic coverage of all location types + advanced features +**Files**: 19 Java files covering all 15 location types **Key**: `SampleApplication.java` - main test file with comprehensive patterns ### customers-tomcat-legacy @@ -200,8 +205,8 @@ make phase2 cd ../integration go test -v -run TestInheritanceSearch -# Build test container -podman build -t jdtls-analyzer:test .. +# Build test container (run from repository root, requires pre-built JAR via mvn install) +cd ../.. && podman build -t jdtls-analyzer:test -f Dockerfile.test . # Run tests in container cd ../integration diff --git a/java-analyzer-bundle.test/docs/integration-tests.md b/java-analyzer-bundle.test/docs/integration-tests.md index f1fc3bf8..8c259cd5 100644 --- a/java-analyzer-bundle.test/docs/integration-tests.md +++ b/java-analyzer-bundle.test/docs/integration-tests.md @@ -21,7 +21,7 @@ Unlike Phase 1 unit tests that only verify commands execute without errors, Phas β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Podman Container β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ -β”‚ β”‚ β”‚ JDT.LS Server (1.38.0) β”‚ β”‚ β”‚ +β”‚ β”‚ β”‚ JDT.LS Server (1.51.0) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ + Java Analyzer Bundle Plugin β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ ↕️ LSP over stdio β”‚ β”‚ @@ -55,7 +55,8 @@ Go LSP client that communicates with JDT.LS via JSON-RPC 2.0 over stdio using th - `Initialize()` - Initialize LSP connection and workspace - `ExecuteCommand()` - Execute workspace commands - `SearchSymbols()` - Execute analyzer searches via `io.konveyor.tackle.ruleEntry` -- `Shutdown()` - Gracefully shutdown server +- `SearchSymbolsWithAnnotation()` - Execute searches with annotation element matching +- `Shutdown()` / `Close()` - Gracefully shutdown server **Protocol**: LSP (Language Server Protocol) over stdin/stdout using `jsonrpc2.Connection` @@ -143,9 +144,12 @@ cd java-analyzer-bundle.test/integration Or manually with **Podman** (preferred): ```bash +# First, build the plugin JAR (required by Dockerfile.test) +mvn clean install -DskipTests + # Build the container image from repository root cd /path/to/java-analyzer-bundle -podman build -t jdtls-analyzer:test . +podman build -t jdtls-analyzer:test -f Dockerfile.test . # Run integration tests with go test podman run --rm \ @@ -155,14 +159,17 @@ podman run --rm \ --workdir /tests/integration \ --entrypoint /bin/sh \ jdtls-analyzer:test \ - -c "microdnf install -y golang && go mod download && go test -v" + -c "go mod download && go test -v" ``` Or with **Docker**: ```bash +# First, build the plugin JAR (required by Dockerfile.test) +mvn clean install -DskipTests + # Build the Docker image -docker build -t jdtls-analyzer:test . +docker build -t jdtls-analyzer:test -f Dockerfile.test . # Run integration tests with go test docker run --rm \ @@ -172,10 +179,12 @@ docker run --rm \ --workdir /tests/integration \ --entrypoint /bin/sh \ jdtls-analyzer:test \ - -c "microdnf install -y golang && go mod download && go test -v" + -c "go mod download && go test -v" ``` -**Note**: Podman uses `:Z` suffix on volumes for SELinux relabeling. Docker doesn't require this. +**Notes**: +- Podman uses `:Z` suffix on volumes for SELinux relabeling. Docker doesn't require this. +- `Dockerfile.test` requires the plugin JAR to be pre-built on the host (via `mvn install`). It pre-installs golang in the image. ### Via GitHub Actions @@ -187,12 +196,14 @@ Workflow: `.github/workflows/integration-tests.yml` The workflow: 1. Runs Phase 1 unit tests with Maven -2. Builds the JDT.LS container image with Podman -3. Runs `go test -v` inside the container +2. Builds a self-contained container image using the default `Dockerfile` (which builds the plugin JAR from source inside the container) +3. Installs golang at runtime and runs `go test -v` inside the container + +**Note**: CI uses the default `Dockerfile` (self-contained, builds JAR from source). Local development uses `Dockerfile.test` (lighter, expects pre-built JAR). Both produce equivalent images with JDT.LS + the analyzer plugin. ### Manually (without containers) -Requires JDT.LS 1.38.0 and Go 1.21+ installed locally: +Requires JDT.LS 1.51.0+ and Go 1.21+ installed locally: ```bash cd java-analyzer-bundle.test/integration @@ -218,17 +229,17 @@ go test -v -run "TestMethod.*" ### Default Search (Location 0) ```go -// Search for all List usage across all location types +// Search for File usage across all location types symbols, err := c.SearchSymbols( "test-project", - "java.util.List", + "java.io.File", 0, // location type: default (all locations) "source-only", nil, ) // Expected Results: -// βœ“ Finds List in imports, fields, variables, type references, etc. +// βœ“ Finds File in imports, constructors, type references, fields, variables, etc. ``` ### Inheritance (Location 1) @@ -422,7 +433,7 @@ symbols, err := c.SearchSymbols( "java.sql.PreparedStatement", 8, // location type: import "source-only", - &includedPaths, + includedPaths, ) // Expected Results: @@ -432,118 +443,71 @@ symbols, err := c.SearchSymbols( ## Test Assertions -Tests verify using helper functions from `tests/test_utils.go`: +Tests verify using helper functions from `test_helpers.go`: -1. **Symbol Existence**: +1. **Symbol Existence** (check name, optionally kind): ```go - if VerifySymbolInResults(symbols, "SampleApplication") { - results.AddPass("Test passed") - } else { - results.AddFail("Test failed", "SampleApplication not found") + if !verifySymbolInResults(symbols, "SampleApplication") { + t.Errorf("SampleApplication not found in results") } ``` -2. **Symbol Kind**: +2. **Symbol Location** (check name appears in expected file): ```go - if VerifySymbolInResults(symbols, "Customer", protocol.Class) { - results.AddPass("Test passed") + if !verifySymbolLocationContains(symbols, "processData", "SampleApplication") { + t.Errorf("processData not found in SampleApplication") } ``` -3. **Symbol Location**: +3. **Result Count** (verify non-empty results): ```go - if VerifySymbolLocationContains(symbols, "Customer", "Customer.java") { - results.AddPass("Test passed") + if len(symbols) == 0 { + t.Errorf("Expected symbols but got 0 results") } ``` -4. **Result Count**: +4. **Container Matching** (check annotation on specific class): ```go - if count := CountSymbols(symbols); count > 0 { - results.AddPass(fmt.Sprintf("Found %d results", count)) + for _, symbol := range symbols { + if symbol.Name == "Entity" && symbol.ContainerName == "Customer" { + found = true + } } ``` ## Expected Output -``` -============================================================ -Phase 2 Integration Tests - JDT.LS Search Verification -============================================================ - -JDT.LS Path: /jdtls -Workspace: /tests/projects - -Initializing JDT.LS client... -Started JDT.LS server with PID 1234 -JDT.LS initialized successfully -JDT.LS ready for testing - ---- Testing Default Searches (Location 0) --- -βœ“ PASS: Default: Find all List usage across all location types - ---- Testing Inheritance Searches (Location 1) --- -βœ“ PASS: Inheritance: Find SampleApplication extends BaseService -βœ“ PASS: Inheritance: Find DataService extends BaseService -βœ“ PASS: Inheritance: Find CustomException extends Exception - ---- Testing Method Call Searches (Location 2) --- -βœ“ PASS: Method Call: Find println calls (8 found) -βœ“ PASS: Method Call: Find List.add in SampleApplication - ---- Testing Constructor Call Searches (Location 3) --- -βœ“ PASS: Constructor: Find ArrayList instantiations (3 found) -βœ“ PASS: Constructor: Find File instantiations (5 found) - ---- Testing Annotation Searches (Location 4) --- -βœ“ PASS: Annotation: Find @CustomAnnotation on SampleApplication - ---- Testing Implements Type Searches (Location 5) --- -βœ“ PASS: Implements: Find BaseService implements Serializable - ---- Testing Enum Constant Searches (Location 6) --- -βœ“ PASS: Enum Constant: Find ACTIVE enum constant references +The tests use Go's standard `testing` framework and produce output like: ---- Testing Return Type Searches (Location 7) --- -βœ“ PASS: Return Type: Find methods returning String - ---- Testing Import Searches (Location 8) --- -βœ“ PASS: Import: Find java.io.* imports (2 found) - ---- Testing Variable Declaration Searches (Location 9) --- -βœ“ PASS: Variable Declaration: Find String variable declarations - ---- Testing Type Searches (Location 10) --- -βœ“ PASS: Type: Find String type references (15 found) - ---- Testing Package Declaration Searches (Location 11) --- -βœ“ PASS: Package Declaration: Find io.konveyor.demo package - ---- Testing Field Declaration Searches (Location 12) --- -βœ“ PASS: Field Declaration: Find String fields +``` +=== RUN TestDefaultSearch +=== RUN TestDefaultSearch/Find_BaseService_across_all_locations +=== RUN TestDefaultSearch/Find_println_across_all_locations +=== RUN TestDefaultSearch/Find_File_across_all_locations +--- PASS: TestDefaultSearch (0.15s) ---- Testing Method Declaration Searches (Location 13) --- -βœ“ PASS: Method Declaration: Find getter methods with wildcard +=== RUN TestInheritanceSearch +=== RUN TestInheritanceSearch/Find_SampleApplication_extends_BaseService +=== RUN TestInheritanceSearch/Find_DataService_extends_BaseService +=== RUN TestInheritanceSearch/Find_CustomException_extends_Exception +--- PASS: TestInheritanceSearch (0.12s) ---- Testing Class Declaration Searches (Location 14) --- -βœ“ PASS: Class Declaration: Find SampleApplication class +... ---- Testing customers-tomcat-legacy Project --- -βœ“ PASS: Legacy Project: Find @Entity on Customer -βœ“ PASS: Legacy Project: Find @Service on CustomerService -βœ“ PASS: Legacy Project: Find javax.persistence imports (9 found) +=== RUN TestAnnotatedElementMatching +=== RUN TestAnnotatedElementMatching/Find_@ActivationConfigProperty_with_propertyName=destinationLookup +=== RUN TestAnnotatedElementMatching/Find_@DataSourceDefinition_with_className=org.postgresql.Driver +=== RUN TestAnnotatedElementMatching/Find_@DataSourceDefinition_with_className=com.mysql.jdbc.Driver +=== RUN TestAnnotatedElementMatching/Find_@Column_with_nullable=false +--- PASS: TestAnnotatedElementMatching (0.16s) ---- Testing Priority 1 Advanced Features --- -βœ“ PASS: Annotated Element Matching: Find @ActivationConfigProperty with propertyName=destinationLookup -βœ“ PASS: Annotated Element Matching: Find @DataSourceDefinition with PostgreSQL driver -βœ“ PASS: Annotated Element Matching: Find @DataSourceDefinition with MySQL driver -βœ“ PASS: Annotated Element Matching: Find @Column with nullable=false -βœ“ PASS: File Path Filtering: Find PreparedStatement imports in persistence package -βœ“ PASS: File Path Filtering: Verify filtering excludes other packages +=== RUN TestFilePathFiltering +=== RUN TestFilePathFiltering/Find_PreparedStatement_imports_with_package-level_filtering +=== RUN TestFilePathFiltering/Verify_file_path_filtering_excludes_other_packages +--- PASS: TestFilePathFiltering (0.08s) -============================================================ -Test Results: 18/18 passed (100%) -============================================================ +PASS +ok github.com/konveyor/java-analyzer-bundle/integration 5.234s ``` ## Troubleshooting @@ -772,15 +736,18 @@ public class SampleApplication extends BaseService { } #### βœ… Location 0: Default **Java Features**: Default search behavior (all locations) -**Test**: `TestDefaultSearch` +**Test**: `TestDefaultSearch` (3 sub-tests) **Queries**: -- `java.util.List` β†’ finds all List usage across all location types +- `io.konveyor.demo.inheritance.BaseService` β†’ finds BaseService across all locations +- `println` β†’ finds println across all locations +- `java.io.File` β†’ finds File in imports, constructors, type references, fields, variables **Java Code Pattern**: ```java // Matches in multiple contexts: imports, fields, variables, types, etc. -import java.util.List; -private List items; +import java.io.File; +private File configFile; +File tempFile = new File("/tmp/data.txt"); ``` **Symbol Results**: All occurrences across all location types @@ -813,19 +780,24 @@ EnumExample status = EnumExample.ACTIVE; #### βœ… Location 7: Return Types **Java Features**: Method return type declarations -**Test**: `TestReturnTypeSearch` +**Test**: `TestReturnTypeSearch` (3 sub-tests) **Queries**: - `java.lang.String` β†’ finds all methods returning String -- `java.util.List` β†’ finds all methods returning List +- `int` β†’ finds `add` method in Calculator +- `io.konveyor.demo.EnumExample` β†’ finds `getStatus` method in Calculator -**Java Code Pattern** (test-project/SampleApplication.java): +**Java Code Pattern**: ```java -public String getName() { // String return type +public String getName() { // String return type (SampleApplication) return applicationName; } -public List getItems() { // List return type - return items; +public int add(int a, int b) { // int return type (Calculator) + return a + b; +} + +public EnumExample getStatus() { // Custom return type (Calculator) + return status; } ``` @@ -854,19 +826,27 @@ public void processData() { --- #### βœ… Location 11: Package Declarations -**Java Features**: Package statements at top of Java files -**Test**: `TestPackageDeclarationSearch` +**Java Features**: Package usage via imports and references (not literal package statements) +**Test**: `TestPackageDeclarationSearch` (8 sub-tests) **Queries**: -- `io.konveyor.demo` β†’ finds all classes in this package -- `io.konveyor.demo.*` β†’ finds all classes in this package and subpackages +- `io.konveyor.demo` β†’ may return 0 results (base package never referenced directly) +- `io.konveyor.demo.inheritance` β†’ finds classes referencing this sub-package +- `io.konveyor.d*` β†’ wildcard matching across demo sub-packages +- `java.util` β†’ finds SampleApplication.java (uses java.util imports) +- `java.sql` β†’ finds persistence package files (uses java.sql imports) +- `jakarta.*` β†’ finds ServletExample.java (uses jakarta imports) +- `javax.persistence` β†’ finds entity/Product.java and persistence files +- `java.io` β†’ finds ServletExample.java (uses java.io imports) + +**Note**: PACKAGE search with REFERENCES finds where packages are used in imports/FQNs, not literal `package` statements. **Java Code Pattern** (all test files): ```java -package io.konveyor.demo; -package io.konveyor.demo.ordermanagement.model; +import java.util.List; // java.util package reference +import javax.persistence.Entity; // javax.persistence package reference ``` -**Symbol Results**: Package declaration locations +**Symbol Results**: Package reference locations in import statements and FQNs --- @@ -891,17 +871,19 @@ private static final int MAX_RETRIES = 3; // static final field #### βœ… Location 13: Method Declarations **Java Features**: Method signature declarations -**Test**: `TestMethodDeclarationSearch` +**Test**: `TestMethodDeclarationSearch` (4 sub-tests) **Queries**: -- `processData` β†’ finds processData method declarations -- `get*` β†’ finds all getter methods (wildcard) -- `print*` β†’ finds all methods starting with print +- `processData` β†’ finds processData method declaration +- `getName` β†’ finds getName method declaration +- `add` β†’ finds add method in Calculator +- `initialize` β†’ finds initialize method declaration -**Java Code Pattern** (test-project/SampleApplication.java): +**Java Code Pattern** (test-project/SampleApplication.java, Calculator.java): ```java public void processData() { } // processData method public String getName() { } // getName method -public static void printVersion() { } // static method +public int add(int a, int b) { } // add method (Calculator) +public void initialize() { } // initialize method ``` **Symbol Results**: Method declaration locations @@ -993,7 +975,7 @@ The integration tests use the following Go packages: ```go require ( - github.com/konveyor/analyzer-lsp v0.4.0-alpha.1 + github.com/konveyor/analyzer-lsp v0.8.0 github.com/sirupsen/logrus v1.9.3 ) ``` diff --git a/java-analyzer-bundle.test/docs/query-reference.md b/java-analyzer-bundle.test/docs/query-reference.md index e8d1df4a..cf84668d 100644 --- a/java-analyzer-bundle.test/docs/query-reference.md +++ b/java-analyzer-bundle.test/docs/query-reference.md @@ -433,15 +433,15 @@ Some location types accept simple names: | `TestImportSearch` | 8 | 1 | Verify import statements | | `TestVariableDeclarationSearch` | 9 | 3 | Verify local variable declarations | | `TestTypeSearch` | 10 | 1 | Verify type reference count | -| `TestPackageDeclarationSearch` | 11 | 2 | Verify package declarations | +| `TestPackageDeclarationSearch` | 11 | 8 | Verify package references in imports/FQNs | | `TestFieldDeclarationSearch` | 12 | 3 | Verify field declarations | | `TestMethodDeclarationSearch` | 13 | 4 | Verify method declarations | | `TestClassDeclarationSearch` | 14 | 1 | Verify class declaration | | `TestCustomersTomcatLegacy` | 4, 8 | 3 | Migration pattern verification | | `TestAnnotatedElementMatching` | 4 | 4 | Annotation attributes matching | -| `TestFilePathFiltering` | 9 | 2 | File path filtering with includedPaths | +| `TestFilePathFiltering` | 8 | 2 | File path filtering with includedPaths | -**Total Query Executions**: 40+ unique search queries across 18 test functions covering all 15 location types +**Total Query Executions**: 47 search queries across 18 test functions covering all 15 location types --- @@ -451,15 +451,28 @@ Some location types accept simple names: **Purpose**: Systematic coverage of all location types -**Key Files**: +**Key Files** (19 Java files): - `SampleApplication.java` - Main test file with method calls, constructors, fields, variables -- `BaseService.java` - Inheritance base class, implements Serializable -- `DataService.java` - Another BaseService subclass -- `CustomException.java` - Exception inheritance -- `CustomAnnotation.java` - Custom annotation definition +- `Calculator.java` - Return type examples (int, EnumExample) - `EnumExample.java` - Enum with constants (location 6) - -**Coverage**: Designed to test all 15 location types systematically +- `PackageUsageExample.java` - Package reference patterns +- `ServletExample.java` - Jakarta servlet example +- `annotations/CustomAnnotation.java` - Custom annotation definition +- `annotations/DeprecatedApi.java` - Deprecated API annotation +- `inheritance/BaseService.java` - Abstract base class, implements Serializable +- `inheritance/DataService.java` - Another BaseService subclass +- `inheritance/CustomException.java` - Exception inheritance +- `jms/MessageProcessor.java` - @MessageDriven with @ActivationConfigProperty +- `jms/TopicMessageProcessor.java` - Additional JMS example +- `config/DataSourceConfig.java` - @DataSourceDefinition (PostgreSQL) +- `config/MySQLDataSourceConfig.java` - @DataSourceDefinition (MySQL) +- `entity/Product.java` - @Entity, @Column with attributes +- `persistence/ServiceWithEntityManager.java` - Mixed JPA/JDBC +- `persistence/JdbcOnlyService.java` - Pure JDBC with PreparedStatement +- `persistence/AnotherMixedService.java` - Additional mixed pattern +- `persistence/PureJpaService.java` - Pure JPA (no JDBC) + +**Coverage**: Designed to test all 15 location types + advanced features systematically --- diff --git a/java-analyzer-bundle.test/docs/quick-reference.md b/java-analyzer-bundle.test/docs/quick-reference.md index f8c2f6c1..a3cb74c1 100644 --- a/java-analyzer-bundle.test/docs/quick-reference.md +++ b/java-analyzer-bundle.test/docs/quick-reference.md @@ -6,9 +6,9 @@ Quick reference for what's tested and what's not in the Java Analyzer Bundle int ``` Location Types: 15/15 tested (100%) βœ… -Test Functions: 18 +Test Functions: 18 (47 sub-tests total) Advanced Features: 2/2 tested (Priority 1) -Query Patterns: 40+ unique queries +Query Patterns: 47 unique queries Test Projects: 2 (systematic + real-world) ``` @@ -31,7 +31,7 @@ Test Projects: 2 (systematic + real-world) | **8** | Imports | `java.io.File`, `javax.persistence.Entity` | both | | **9** | Variable Decls | `java.lang.String`, `java.io.File` | test-project | | **10** | Type Refs | `java.util.ArrayList` | test-project | -| **11** | Package Decls | `io.konveyor.demo` | test-project | +| **11** | Package Decls | `io.konveyor.demo.*`, `java.util`, `jakarta.*`, etc. | test-project | | **12** | Field Decls | `java.util.List`, `java.io.File` | test-project | | **13** | Method Decls | `processData`, `getName`, `add` | test-project | | **14** | Class Decls | `SampleApplication` | test-project | @@ -52,17 +52,35 @@ integration/ ### Java Test Projects ``` projects/ -β”œβ”€β”€ test-project/ # Systematic pattern coverage +β”œβ”€β”€ test-project/ # Systematic pattern coverage (19 Java files) β”‚ └── src/main/java/io/konveyor/demo/ -β”‚ β”œβ”€β”€ SampleApplication.java # Main test file -β”‚ β”œβ”€β”€ inheritance/BaseService.java +β”‚ β”œβ”€β”€ SampleApplication.java # Main test file +β”‚ β”œβ”€β”€ Calculator.java # Return type examples +β”‚ β”œβ”€β”€ EnumExample.java # Enum constant examples +β”‚ β”œβ”€β”€ PackageUsageExample.java # Package reference examples +β”‚ β”œβ”€β”€ ServletExample.java # Jakarta servlet example β”‚ β”œβ”€β”€ annotations/CustomAnnotation.java -β”‚ └── EnumExample.java +β”‚ β”œβ”€β”€ annotations/DeprecatedApi.java +β”‚ β”œβ”€β”€ inheritance/BaseService.java +β”‚ β”œβ”€β”€ inheritance/DataService.java +β”‚ β”œβ”€β”€ inheritance/CustomException.java +β”‚ β”œβ”€β”€ jms/MessageProcessor.java # JMS/EJB annotations +β”‚ β”œβ”€β”€ jms/TopicMessageProcessor.java +β”‚ β”œβ”€β”€ config/DataSourceConfig.java # PostgreSQL @DataSourceDefinition +β”‚ β”œβ”€β”€ config/MySQLDataSourceConfig.java # MySQL @DataSourceDefinition +β”‚ β”œβ”€β”€ entity/Product.java # JPA @Entity, @Column +β”‚ β”œβ”€β”€ persistence/ServiceWithEntityManager.java +β”‚ β”œβ”€β”€ persistence/JdbcOnlyService.java +β”‚ β”œβ”€β”€ persistence/AnotherMixedService.java +β”‚ └── persistence/PureJpaService.java β”‚ -└── customers-tomcat-legacy/ # Real-world migration +└── customers-tomcat-legacy/ # Real-world migration (10 Java files) └── src/main/java/io/konveyor/demo/ordermanagement/ β”œβ”€β”€ model/Customer.java # JPA entity - └── service/CustomerService.java # Spring service + β”œβ”€β”€ service/CustomerService.java # Spring service + β”œβ”€β”€ controller/CustomerController.java + β”œβ”€β”€ repository/CustomerRepository.java + └── config/PersistenceConfig.java ``` ## Test Functions @@ -82,7 +100,7 @@ projects/ | `TestImportSearch` | 8 | 1 | Verify import statements | | `TestVariableDeclarationSearch` | 9 | 3 | Verify local variable declarations | | `TestTypeSearch` | 10 | 1 | Verify type references | -| `TestPackageDeclarationSearch` | 11 | 2 | Verify package declarations | +| `TestPackageDeclarationSearch` | 11 | 8 | Verify package references in imports/FQNs | | `TestFieldDeclarationSearch` | 12 | 3 | Verify field declarations | | `TestMethodDeclarationSearch` | 13 | 4 | Verify method declarations | | `TestClassDeclarationSearch` | 14 | 1 | Verify class declaration | @@ -180,8 +198,9 @@ make phase2 # Just integration tests ### Manual Container Run ```bash -# Build image -podman build -t jdtls-analyzer:test . +# Build plugin JAR first, then build image (from repository root) +mvn clean install -DskipTests +podman build -t jdtls-analyzer:test -f Dockerfile.test . # Run tests podman run --rm \ @@ -191,9 +210,12 @@ podman run --rm \ --workdir /tests/integration \ --entrypoint /bin/sh \ jdtls-analyzer:test \ - -c "microdnf install -y golang && go mod download && go test -v" + -c "go mod download && go test -v" ``` +**Note**: `Dockerfile.test` requires a pre-built JAR and pre-installs golang. CI uses the +default `Dockerfile` which builds the JAR from source and installs golang at runtime. + ### Run Specific Test ```bash go test -v -run TestInheritanceSearch diff --git a/java-analyzer-bundle.test/docs/test-projects.md b/java-analyzer-bundle.test/docs/test-projects.md index 180c92b6..4515820f 100644 --- a/java-analyzer-bundle.test/docs/test-projects.md +++ b/java-analyzer-bundle.test/docs/test-projects.md @@ -12,16 +12,39 @@ A comprehensive test project designed to cover all search location types (0-14) **Technologies**: - Java 17 - Jakarta Servlet API 5.0 +- javax.persistence-api 2.2 (JPA annotations) +- javax.ejb-api 3.2.2 (EJB/JMS annotations) +- javax.jms-api 2.0.1 (JMS API) +- javax.annotation-api 1.3.2 (@DataSourceDefinition) -**Package Structure**: +**Package Structure** (19 Java files): ``` io.konveyor.demo/ -β”œβ”€β”€ annotations/ - Custom annotations -β”œβ”€β”€ inheritance/ - Inheritance and interface examples -β”œβ”€β”€ SampleApplication.java - Main test class with various patterns -β”œβ”€β”€ Calculator.java - Return type examples -β”œβ”€β”€ EnumExample.java - Enum constant examples -└── ServletExample.java - Jakarta EE servlet example +β”œβ”€β”€ SampleApplication.java - Main test class with various patterns +β”œβ”€β”€ Calculator.java - Return type examples (int, EnumExample) +β”œβ”€β”€ EnumExample.java - Enum constant examples +β”œβ”€β”€ PackageUsageExample.java - Package reference patterns +β”œβ”€β”€ ServletExample.java - Jakarta EE servlet example +β”œβ”€β”€ annotations/ +β”‚ β”œβ”€β”€ CustomAnnotation.java - Custom annotation definition +β”‚ └── DeprecatedApi.java - Deprecated API annotation +β”œβ”€β”€ inheritance/ +β”‚ β”œβ”€β”€ BaseService.java - Abstract base class (Serializable) +β”‚ β”œβ”€β”€ DataService.java - Extends BaseService +β”‚ └── CustomException.java - Extends Exception +β”œβ”€β”€ jms/ +β”‚ β”œβ”€β”€ MessageProcessor.java - @MessageDriven with @ActivationConfigProperty +β”‚ └── TopicMessageProcessor.java - Additional JMS example +β”œβ”€β”€ config/ +β”‚ β”œβ”€β”€ DataSourceConfig.java - @DataSourceDefinition (PostgreSQL) +β”‚ └── MySQLDataSourceConfig.java - @DataSourceDefinition (MySQL) +β”œβ”€β”€ entity/ +β”‚ └── Product.java - @Entity, @Column with attributes +└── persistence/ + β”œβ”€β”€ ServiceWithEntityManager.java - Mixed JPA/JDBC + β”œβ”€β”€ JdbcOnlyService.java - Pure JDBC with PreparedStatement + β”œβ”€β”€ AnotherMixedService.java - Additional mixed pattern + └── PureJpaService.java - Pure JPA (no JDBC) ``` **Covered Location Types**: @@ -197,33 +220,18 @@ expectedResults: CustomerRepository.java --- -## Integration Test Strategy - -### Phase 1: Basic Verification Tests (Current) -- βœ… Verify commands execute without exceptions -- βœ… Verify parameter parsing -- βœ… Verify non-null results - -### Phase 2: Search Result Verification (Next) -1. **Load test projects into Eclipse workspace** -2. **Verify search result counts**: - ```java - assertEquals(expectedCount, results.size()); - ``` -3. **Verify symbol information**: - ```java - assertEquals("Customer", symbol.getName()); - assertEquals(SymbolKind.Class, symbol.getKind()); - assertTrue(symbol.getLocation().getUri().contains("Customer.java")); - ``` - -### Phase 3: Migration Pattern Testing -Test common migration scenarios: -- **javax β†’ jakarta** namespace migration -- **Oracle β†’ PostgreSQL** driver migration -- **JBoss β†’ SLF4J** logging migration -- **Spring Framework** version upgrades -- **Legacy servlet β†’ Spring Boot** migration +## Integration Test Status + +All planned testing phases are complete: + +- βœ… Commands execute without exceptions +- βœ… Parameter parsing and validation +- βœ… Real JDT.LS server with analyzer plugin loaded +- βœ… Search result verification (symbol names, kinds, locations) +- βœ… Migration pattern testing (javaxβ†’jakarta, Spring, JMS) +- βœ… Advanced features: annotated element matching, file path filtering + +**18 test functions, 47 sub-tests, 100% pass rate.** --- @@ -278,11 +286,12 @@ When adding new test projects: --- -## Next Steps +## Completed Milestones -1. **βœ… Create test project structures** -2. **βœ… Add sample code covering all location types** -3. **⏳ Create workspace initialization in tests** -4. **⏳ Add result verification tests** -5. **⏳ Create migration scenario tests** -6. **⏳ Add test documentation for each scenario** +1. βœ… Create test project structures +2. βœ… Add sample code covering all location types +3. βœ… Create workspace initialization in tests (Go LSP client) +4. βœ… Add result verification tests (18 functions, 47 sub-tests) +5. βœ… Create migration scenario tests (javaxβ†’jakarta, JMS, database drivers) +6. βœ… Add annotated element matching tests (4 sub-tests) +7. βœ… Add file path filtering tests (2 sub-tests) diff --git a/java-analyzer-bundle.tp/java-analyzer-bundle.target b/java-analyzer-bundle.tp/java-analyzer-bundle.target index b20db484..6e2ddada 100644 --- a/java-analyzer-bundle.tp/java-analyzer-bundle.target +++ b/java-analyzer-bundle.tp/java-analyzer-bundle.target @@ -11,18 +11,10 @@ - - - - From 57cfb9ae747cc51d58a8678e6afa5ebdd50f3c47 Mon Sep 17 00:00:00 2001 From: Shawn Hurley Date: Thu, 26 Mar 2026 21:31:44 -0400 Subject: [PATCH 2/2] Adding real versions to the artifact during build in the workflows This should enable Tag v0.9.2 -> 1.0.1 release of the artifact. Because we already have 1.0.0 release downstream, this was the best that I could think of to try and map downstream build to the released build downstream using the actual artifact. Signed-off-by: Shawn Hurley --- .github/workflows/image-build.yaml | 56 ++++++++- .github/workflows/post-release-bump.yaml | 116 ++++++++++++++++++ Dockerfile | 16 ++- Dockerfile.test | 3 +- Makefile | 31 ++++- .../META-INF/MANIFEST.MF | 2 +- java-analyzer-bundle.core/pom.xml | 2 +- java-analyzer-bundle.site/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 4 +- java-analyzer-bundle.test/README.md | 6 +- .../docs/integration-tests.md | 2 +- .../integration/client/jdtls_client.go | 17 ++- java-analyzer-bundle.test/pom.xml | 2 +- java-analyzer-bundle.tp/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 236 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/post-release-bump.yaml diff --git a/.github/workflows/image-build.yaml b/.github/workflows/image-build.yaml index b075b2cb..9bb1fafc 100644 --- a/.github/workflows/image-build.yaml +++ b/.github/workflows/image-build.yaml @@ -18,13 +18,63 @@ concurrency: cancel-in-progress: true jobs: + determine-version: + name: Determine Bundle Version + runs-on: ubuntu-latest + outputs: + bundle_version: ${{ steps.version.outputs.bundle_version }} + is_release: ${{ steps.version.outputs.is_release }} + steps: + - name: Determine version from git ref + id: version + run: | + # Translate upstream 0.x tags to downstream 1.x artifact versions. + # Anchor: v0.9.1 == 1.0.0 + # 0.9.P (P>=1) -> 1.0.(P-1) + # 0.M.P (M>=10) -> 1.(M-9).P + # 1.x.y+ -> pass-through + translate_version() { + local raw="$1" base suffix="" + # Separate pre-release suffix (e.g., -rc.1, -alpha.2) + if [[ "$raw" == *-* ]]; then + suffix="-${raw#*-}" + base="${raw%%-*}" + else + base="$raw" + fi + IFS='.' read -r major minor patch <<< "$base" + if [[ "$major" -ge 1 ]]; then + echo "${base}${suffix}" + elif [[ "$minor" -ge 10 ]]; then + echo "1.$((minor - 9)).${patch}${suffix}" + elif [[ "$minor" -eq 9 && "$patch" -ge 1 ]]; then + echo "1.0.$((patch - 1))${suffix}" + else + echo "${base}${suffix}" + fi + } + + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + RAW_VERSION="${GITHUB_REF#refs/tags/v}" + VERSION=$(translate_version "$RAW_VERSION") + echo "bundle_version=${VERSION}" >> $GITHUB_OUTPUT + echo "is_release=true" >> $GITHUB_OUTPUT + echo "Tag: v${RAW_VERSION} -> artifact version: ${VERSION}" + else + echo "bundle_version=1.1.0-SNAPSHOT" >> $GITHUB_OUTPUT + echo "is_release=false" >> $GITHUB_OUTPUT + echo "Building SNAPSHOT version: 1.1.0-SNAPSHOT" + fi + image-build: + needs: determine-version uses: konveyor/release-tools/.github/workflows/build-push-images.yaml@main with: registry: "quay.io/konveyor" image_name: "jdtls-server-base" containerfile: "./Dockerfile" architectures: '[ "amd64", "arm64" ]' + extra-args: "--build-arg BUNDLE_VERSION=${{ needs.determine-version.outputs.bundle_version }}" publish: ${{ github.event_name == 'pull_request' && 'false' || 'true' }} secrets: registry_username: ${{ secrets.QUAY_PUBLISH_ROBOT }} @@ -33,7 +83,7 @@ jobs: build_image_analyzer: name: trigger java provider rebuild runs-on: ubuntu-latest - needs: image-build + needs: [determine-version, image-build] if: github.event_name == 'push' steps: - name: Get Token @@ -43,10 +93,10 @@ jobs: application_id: ${{ vars.KONVEYOR_BOT_ID }} application_private_key: ${{ secrets.KONVEYOR_BOT_KEY }} - # Tell the analyzer to re-build it's images to get the update image. + # Tell the analyzer to re-build its images to get the updated image. - uses: peter-evans/repository-dispatch@v4 with: token: ${{ steps.get_workflow_token.outputs.token }} repository: "konveyor/analyzer-lsp" event-type: rebuild-java-provider - client-payload: '{"ref": "${{ github.ref}}", "ref_name": "${{ github.ref_name }}"}' + client-payload: '{"ref": "${{ github.ref }}", "ref_name": "${{ github.ref_name }}", "bundle_version": "${{ needs.determine-version.outputs.bundle_version }}"}' diff --git a/.github/workflows/post-release-bump.yaml b/.github/workflows/post-release-bump.yaml new file mode 100644 index 00000000..cbb176b2 --- /dev/null +++ b/.github/workflows/post-release-bump.yaml @@ -0,0 +1,116 @@ +name: Post-Release Version Bump + +on: + push: + tags: + - 'v*' + +jobs: + bump-version: + name: Bump to next SNAPSHOT version + runs-on: ubuntu-latest + # Only bump for final releases (skip pre-releases like v0.9.2-rc.1) + if: ${{ !contains(github.ref_name, '-') }} + + steps: + - name: Get Token + id: get_workflow_token + uses: peter-murray/workflow-application-token-action@v3 + with: + application_id: ${{ vars.KONVEYOR_BOT_ID }} + application_private_key: ${{ secrets.KONVEYOR_BOT_KEY }} + + - uses: actions/checkout@v4 + with: + ref: main + token: ${{ steps.get_workflow_token.outputs.token }} + + - name: Set up JDK 21 + uses: actions/setup-java@v5 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + + - name: Calculate next version + id: next_version + run: | + # Same translation logic as image-build.yaml + # Anchor: v0.9.1 == 1.0.0 + translate_version() { + local raw="$1" base + IFS='.' read -r major minor patch <<< "$raw" + if [[ "$major" -ge 1 ]]; then + echo "${raw}" + elif [[ "$minor" -ge 10 ]]; then + echo "1.$((minor - 9)).${patch}" + elif [[ "$minor" -eq 9 && "$patch" -ge 1 ]]; then + echo "1.0.$((patch - 1))" + else + echo "${raw}" + fi + } + + RAW_VERSION="${GITHUB_REF_NAME#v}" + RELEASE_VERSION=$(translate_version "$RAW_VERSION") + IFS='.' read -r MAJOR MINOR PATCH <<< "$RELEASE_VERSION" + NEXT_VERSION="${MAJOR}.$((MINOR + 1)).0-SNAPSHOT" + + echo "raw_version=${RAW_VERSION}" >> $GITHUB_OUTPUT + echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT + echo "next_version=${NEXT_VERSION}" >> $GITHUB_OUTPUT + echo "Tag: v${RAW_VERSION} -> released: ${RELEASE_VERSION} -> next dev: ${NEXT_VERSION}" + + - name: Set next SNAPSHOT version in POMs and MANIFESTs + run: | + mvn -B org.eclipse.tycho:tycho-versions-plugin:4.0.7:set-version \ + -DnewVersion=${{ steps.next_version.outputs.next_version }} + + - name: Update Dockerfile ARG defaults + run: | + NEXT="${{ steps.next_version.outputs.next_version }}" + sed -i "s/^ARG BUNDLE_VERSION=.*/ARG BUNDLE_VERSION=${NEXT}/" Dockerfile Dockerfile.test + + - name: Configure git + run: | + git config user.name "konveyor-bot[bot]" + git config user.email "konveyor-bot[bot]@users.noreply.github.com" + + - name: Create branch and commit + run: | + NEXT="${{ steps.next_version.outputs.next_version }}" + BRANCH="chore/bump-version-${NEXT}" + git checkout -b "$BRANCH" + git add -A + git commit --signoff \ + -m "chore: bump version to ${NEXT} after ${{ github.ref_name }} release" + git push origin "$BRANCH" + + - name: Create Pull Request + env: + GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }} + run: | + RAW="${{ steps.next_version.outputs.raw_version }}" + RELEASE="${{ steps.next_version.outputs.release_version }}" + NEXT="${{ steps.next_version.outputs.next_version }}" + gh pr create \ + --title "chore: bump version to ${NEXT}" \ + --body "$(cat < in pom.xml. +RUN case "$BUNDLE_VERSION" in \ + *-SNAPSHOT) echo "SNAPSHOT build: $BUNDLE_VERSION" ;; \ + *) echo "Setting release version: $BUNDLE_VERSION"; \ + /usr/local/apache-maven-3.9.14/bin/mvn -B org.eclipse.tycho:tycho-versions-plugin:4.0.7:set-version \ + -DnewVersion=$BUNDLE_VERSION ;; \ + esac +RUN /usr/local/apache-maven-3.9.14/bin/mvn -B clean install -DskipTests=true # Download maven index data WORKDIR /maven-index-data RUN set -e; \ @@ -56,8 +65,9 @@ COPY hack/maven.default.index /usr/local/etc/maven.default.index COPY --from=jdtls-download /jdtls /jdtls/ COPY --from=addon-build /usr/local/apache-maven-3.9.14/ /usr/local/apache-maven-3.9.14/ RUN ln -s /usr/local/apache-maven-3.9.14/bin/mvn /usr/bin/mvn -COPY --from=addon-build /root/.m2/repository/io/konveyor/tackle/java-analyzer-bundle.core/1.0.0-SNAPSHOT/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar /jdtls/plugins/ -COPY --from=addon-build /root/.m2/repository/io/konveyor/tackle/java-analyzer-bundle.core/1.0.0-SNAPSHOT/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar /jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar +ARG BUNDLE_VERSION=1.1.0-SNAPSHOT +COPY --from=addon-build /root/.m2/repository/io/konveyor/tackle/java-analyzer-bundle.core/${BUNDLE_VERSION}/java-analyzer-bundle.core-${BUNDLE_VERSION}.jar /jdtls/plugins/ +COPY --from=addon-build /root/.m2/repository/io/konveyor/tackle/java-analyzer-bundle.core/${BUNDLE_VERSION}/java-analyzer-bundle.core-${BUNDLE_VERSION}.jar /jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/java-analyzer-bundle.core-${BUNDLE_VERSION}.jar COPY --from=fernflower /output/fernflower.jar /bin/fernflower.jar COPY --from=addon-build /maven-index-data/central.archive-metadata.txt /usr/local/etc/maven-index.txt diff --git a/Dockerfile.test b/Dockerfile.test index 4e5ccaf5..5a5a0f2c 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -49,5 +49,6 @@ COPY --from=index-download /maven-index-data/central.archive-metadata.idx /usr/l RUN microdnf install -y golang RUN ln -sf /root/.m2 /.m2 && chgrp -R 0 /root && chmod -R g=u /root -COPY java-analyzer-bundle.core/target/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar /jdtls/plugins/ +ARG BUNDLE_VERSION=1.1.0-SNAPSHOT +COPY java-analyzer-bundle.core/target/java-analyzer-bundle.core-${BUNDLE_VERSION}.jar /jdtls/plugins/ CMD [ "/jdtls/bin/jdtls" ] diff --git a/Makefile b/Makefile index 861f808e..66d7c566 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Makefile for Java Analyzer Bundle # Replicates GitHub Actions CI/CD pipeline for local verification -.PHONY: help all ci clean clean-containers clean-go phase1 phase2 unit-tests build-container run-integration-tests +.PHONY: help all ci clean clean-containers clean-go phase1 phase2 unit-tests build-container run-integration-tests set-version # Detect container runtime (prefer Podman, fallback to Docker) CONTAINER_RUNTIME := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null) @@ -20,6 +20,8 @@ endif IMAGE_NAME := jdtls-analyzer:test REPO_ROOT := $(shell pwd) GO_MODULE := java-analyzer-bundle.test/integration +BUNDLE_VERSION ?= 1.1.0-SNAPSHOT +TYCHO_VERSION := 4.0.7 # Default target help: @@ -40,11 +42,19 @@ help: @echo " make build-container - Build JDT.LS container image" @echo " make run-integration-tests - Run integration tests in container" @echo "" + @echo "Version targets:" + @echo " make set-version - Set bundle version (uses BUNDLE_VERSION)" + @echo "" @echo "Utility targets:" @echo " make clean - Clean all build artifacts" @echo " make clean-containers - Remove container images" @echo " make clean-go - Clean Go build artifacts" @echo "" + @echo "Variables:" + @echo " BUNDLE_VERSION - Bundle version (default: 1.1.0-SNAPSHOT)" + @echo " Set to release version for non-SNAPSHOT builds" + @echo " Example: make ci BUNDLE_VERSION=1.2.0" + @echo "" @echo "Container runtime: $(CONTAINER_RUNTIME)" @echo "======================================================================" @@ -72,10 +82,21 @@ phase2: build-container run-integration-tests @echo "βœ“ Phase 2 Complete: Integration tests passed" @echo "======================================================================" +# Version management +set-version: +ifeq ($(findstring -SNAPSHOT,$(BUNDLE_VERSION)),) + @echo "======================================================================" + @echo "Setting release version: $(BUNDLE_VERSION)" + @echo "======================================================================" + mvn -B org.eclipse.tycho:tycho-versions-plugin:$(TYCHO_VERSION):set-version -DnewVersion=$(BUNDLE_VERSION) +else + @echo "Using SNAPSHOT version: $(BUNDLE_VERSION)" +endif + # Phase 1 Targets -unit-tests: +unit-tests: set-version @echo "======================================================================" - @echo "Phase 1: Running Unit Tests" + @echo "Phase 1: Running Unit Tests (version: $(BUNDLE_VERSION))" @echo "======================================================================" @echo "" mvn clean integration-test @@ -84,12 +105,12 @@ unit-tests: build-container: @echo "" @echo "======================================================================" - @echo "Phase 2: Building JDT.LS Container Image" + @echo "Phase 2: Building JDT.LS Container Image (version: $(BUNDLE_VERSION))" @echo "======================================================================" @echo "" @echo "Using container runtime: $(CONTAINER_RUNTIME)" @echo "" - $(CONTAINER_RUNTIME) build -t $(IMAGE_NAME) -f Dockerfile.test . + $(CONTAINER_RUNTIME) build -t $(IMAGE_NAME) -f Dockerfile.test --build-arg BUNDLE_VERSION=$(BUNDLE_VERSION) . @echo "" @echo "βœ“ Container image built: $(IMAGE_NAME)" diff --git a/java-analyzer-bundle.core/META-INF/MANIFEST.MF b/java-analyzer-bundle.core/META-INF/MANIFEST.MF index 80f8fe29..0ae07b39 100644 --- a/java-analyzer-bundle.core/META-INF/MANIFEST.MF +++ b/java-analyzer-bundle.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: java-analyzer-bundle Core Extension Bundle-SymbolicName: java-analyzer-bundle.core;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Activator: io.konveyor.tackle.core.internal.ExtensionActivator Require-Bundle: org.eclipse.core.runtime, org.eclipse.jdt.ls.core, diff --git a/java-analyzer-bundle.core/pom.xml b/java-analyzer-bundle.core/pom.xml index 9433dc16..02506e0e 100644 --- a/java-analyzer-bundle.core/pom.xml +++ b/java-analyzer-bundle.core/pom.xml @@ -3,7 +3,7 @@ java-analyzer-bundle io.konveyor.tackle - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT 4.0.0 java-analyzer-bundle.core diff --git a/java-analyzer-bundle.site/pom.xml b/java-analyzer-bundle.site/pom.xml index 21416ce7..e42c23e1 100644 --- a/java-analyzer-bundle.site/pom.xml +++ b/java-analyzer-bundle.site/pom.xml @@ -4,7 +4,7 @@ java-analyzer-bundle io.konveyor.tackle - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT java-analyzer-bundle.site eclipse-repository diff --git a/java-analyzer-bundle.test/META-INF/MANIFEST.MF b/java-analyzer-bundle.test/META-INF/MANIFEST.MF index 6b98ffca..917d1d63 100644 --- a/java-analyzer-bundle.test/META-INF/MANIFEST.MF +++ b/java-analyzer-bundle.test/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: java-analyzer-bundle Test Fragment Bundle-SymbolicName: java-analyzer-bundle.test -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Fragment-Host: java-analyzer-bundle.core;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-21 Require-Bundle: org.eclipse.jdt.junit4.runtime;bundle-version="1.1.0", @@ -10,4 +10,4 @@ Require-Bundle: org.eclipse.jdt.junit4.runtime;bundle-version="1.1.0", org.apache.commons.lang3, org.junit;bundle-version="4.12", org.eclipse.m2e.core, - org.eclipse.buildship.core \ No newline at end of file + org.eclipse.buildship.core diff --git a/java-analyzer-bundle.test/README.md b/java-analyzer-bundle.test/README.md index 34e11e1a..e4254745 100644 --- a/java-analyzer-bundle.test/README.md +++ b/java-analyzer-bundle.test/README.md @@ -135,10 +135,10 @@ Real-world Spring MVC application: ## Key Technologies -- **Java 17** - Target platform and tests -- **Eclipse Tycho 3.0.1** - Build system +- **Java 21** - Target platform and tests +- **Eclipse Tycho 4.0.7** - Build system - **JDT.LS 1.51.0** - Language server -- **Go 1.21+** - Integration test framework +- **Go 1.23+** - Integration test framework - **Podman/Docker** - Container runtime for CI/CD - **JUnit 4** - Unit test framework diff --git a/java-analyzer-bundle.test/docs/integration-tests.md b/java-analyzer-bundle.test/docs/integration-tests.md index 8c259cd5..f506b55a 100644 --- a/java-analyzer-bundle.test/docs/integration-tests.md +++ b/java-analyzer-bundle.test/docs/integration-tests.md @@ -203,7 +203,7 @@ The workflow: ### Manually (without containers) -Requires JDT.LS 1.51.0+ and Go 1.21+ installed locally: +Requires JDT.LS 1.51.0+ and Go 1.23+ installed locally: ```bash cd java-analyzer-bundle.test/integration diff --git a/java-analyzer-bundle.test/integration/client/jdtls_client.go b/java-analyzer-bundle.test/integration/client/jdtls_client.go index 15d69769..fe2c2b05 100644 --- a/java-analyzer-bundle.test/integration/client/jdtls_client.go +++ b/java-analyzer-bundle.test/integration/client/jdtls_client.go @@ -189,9 +189,7 @@ func (c *JDTLSClient) Initialize() (*protocol.InitializeResult, error) { }, }, InitializationOptions: map[string]any{ - "bundles": []string{ - "/jdtls/plugins/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar", - }, + "bundles": findAnalyzerBundles("/jdtls/plugins"), "workspaceFolders": []string{string(workspaceURI)}, }, } @@ -376,3 +374,16 @@ func (c *JDTLSClient) Shutdown() error { func (c *JDTLSClient) Close() error { return c.Shutdown() } + +// findAnalyzerBundles discovers java-analyzer-bundle JARs in the given directory. +// This avoids hardcoding the version in the bundle path. +func findAnalyzerBundles(pluginsDir string) []string { + pattern := filepath.Join(pluginsDir, "java-analyzer-bundle.core-*.jar") + matches, err := filepath.Glob(pattern) + if err != nil || len(matches) == 0 { + // Fallback: let JDT.LS fail with a clear error rather than silently + logrus.Warnf("No analyzer bundle found matching %s", pattern) + return []string{} + } + return matches +} diff --git a/java-analyzer-bundle.test/pom.xml b/java-analyzer-bundle.test/pom.xml index 9b39d86a..c3d67c85 100644 --- a/java-analyzer-bundle.test/pom.xml +++ b/java-analyzer-bundle.test/pom.xml @@ -3,7 +3,7 @@ java-analyzer-bundle io.konveyor.tackle - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT 4.0.0 java-analyzer-bundle.test diff --git a/java-analyzer-bundle.tp/pom.xml b/java-analyzer-bundle.tp/pom.xml index 98946f8c..879e0e91 100644 --- a/java-analyzer-bundle.tp/pom.xml +++ b/java-analyzer-bundle.tp/pom.xml @@ -3,7 +3,7 @@ java-analyzer-bundle io.konveyor.tackle - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT java-analyzer-bundle.tp java-analyzer-bundle :: Target Platform diff --git a/pom.xml b/pom.xml index 52bbb413..c93ac92a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.konveyor.tackle java-analyzer-bundle - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT pom java-analyzer-bundle :: parent java-analyzer-bundle parent