Skip to content

Conversation

@rshade
Copy link
Contributor

@rshade rshade commented Oct 16, 2025

Add comprehensive Java/Maven support to the Pulumi Provider Testing Library (pulumitest), enabling developers to test Java Pulumi programs with local SDK builds and custom Maven configurations.

Features Implemented

  • JavaMavenDependency(): Add or update local Maven dependencies in pom.xml with system scope for local JAR files
  • JavaMavenProfile(): Activate Maven profiles via MAVEN_ACTIVE_PROFILES environment variable
  • JavaTargetVersion(): Set Java compiler source and target versions in pom.xml properties
  • JavaMavenSettings(): Pass custom Maven settings.xml file via environment variable

Implementation Details

New Files

  • pulumitest/pomxml.go: XML manipulation utilities for pom.xml handling using proper XML unmarshaling with attribute capture
  • pulumitest/pomxml_test.go: Comprehensive unit tests for XML operations
  • pulumitest/testdata/java_simple/: Test data with sample Pulumi Java program using Random provider

Modified Files

  • pulumitest/opttest/opttest.go: Added Java options, MavenDependency type, and option functions
  • pulumitest/newStack.go: Integrated Java/Maven configuration handling during stack creation
  • pulumitest/pulumiTest_test.go: Added integration tests for Java options

Architecture

  • Uses generic XML node structure that preserves all pom.xml content including attributes
  • Proper error handling for missing pom.xml files
  • Follows established patterns from GoModReplacement and YarnLink implementations
  • Environment variables passed to Maven commands for profile and settings configuration

Testing

  • Unit tests for pomxml utilities (XML parsing, dependency management, version setting)
  • Integration tests verifying all Java options are properly applied to PulumiTest
  • Uses Pulumi Random provider for lightweight testing without cloud credentials

All new tests pass successfully.

Fixes #149

Add comprehensive Java/Maven support to the Pulumi Provider Testing Library (pulumitest),
enabling developers to test Java Pulumi programs with local SDK builds and custom Maven configurations.

- **JavaMavenDependency()**: Add or update local Maven dependencies in pom.xml with system scope for local JAR files
- **JavaMavenProfile()**: Activate Maven profiles via MAVEN_ACTIVE_PROFILES environment variable
- **JavaTargetVersion()**: Set Java compiler source and target versions in pom.xml properties
- **JavaMavenSettings()**: Pass custom Maven settings.xml file via environment variable

- `pulumitest/pomxml.go`: XML manipulation utilities for pom.xml handling using proper XML unmarshaling with attribute capture
- `pulumitest/pomxml_test.go`: Comprehensive unit tests for XML operations
- `pulumitest/testdata/java_simple/`: Test data with sample Pulumi Java program using Random provider

- `pulumitest/opttest/opttest.go`: Added Java options, MavenDependency type, and option functions
- `pulumitest/newStack.go`: Integrated Java/Maven configuration handling during stack creation
- `pulumitest/pulumiTest_test.go`: Added integration tests for Java options

- Uses generic XML node structure that preserves all pom.xml content including attributes
- Proper error handling for missing pom.xml files
- Follows established patterns from GoModReplacement and YarnLink implementations
- Environment variables passed to Maven commands for profile and settings configuration

- Unit tests for pomxml utilities (XML parsing, dependency management, version setting)
- Integration tests verifying all Java options are properly applied to PulumiTest
- Uses Pulumi Random provider for lightweight testing without cloud credentials

All new tests pass successfully.

Fixes #149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Java/Maven support to pulumitest

1 participant