Skip to content

feat: add Java framework support#948

Draft
sarahxsanders wants to merge 1 commit into
mainfrom
posthog-code/java-framework-support
Draft

feat: add Java framework support#948
sarahxsanders wants to merge 1 commit into
mainfrom
posthog-code/java-framework-support

Conversation

@sarahxsanders

@sarahxsanders sarahxsanders commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Related PRs:

Adds Java (server) as a supported framework. Java is the one language here whose manifest collides with existing frameworks — Android and KMP both claim gradle projects — so detection is deliberately conservative:

  • Integration.java enum entry ordered after kmp/swift/android (they claim gradle projects first, enforced by a new enum-order test) and before the language fallbacks
  • JAVA_AGENT_CONFIG in src/frameworks/java/ — claims pom.xml unconditionally (Maven is unambiguously a JVM backend); claims root gradle files only when they carry no Android/KMP plugin markers and no AndroidManifest.xml exists anywhere in the tree (mirroring the Android detector's own strategies, so a direct detect() call can never claim their projects); Flutter's pubspec.yaml guard included
  • gatherContext records the build tool (maven | gradle) for analytics tags and the agent prompt
  • detectJavaPackageManagers — a real detector (Maven via pom.xml, otherwise the existing gradlePackageManager); install guidance is manual-edit-then-resolve since neither tool has a single add verb, pinning com.posthog:posthog-server from Maven Central
  • Prompt context warns the agent that posthog-android is a different library, and covers the client lifecycle (close() on shutdown, flush() in serverless)
  • No bash-fence changes: mvn/mvnw and gradle/gradlew grammars already exist from Android/KMP
  • Pins framework: java on a new integration-java entry in the variant-resolution contract test, matching the context-mill PR above

Why: the wizard docs page lists Java as "Coming soon"; instead of removing the label (posthog.com#18797), we're making the wizard actually support it.

Verification: pnpm build ✅, pnpm test ✅ (1560 tests, incl. 7 new java detect cases + enum-order + package-manager detection tests), pnpm fix


Created with PostHog Code

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@sarahxsanders
sarahxsanders force-pushed the posthog-code/rust-framework-support branch from 700cbba to 6cad9a7 Compare July 22, 2026 20:41
@sarahxsanders
sarahxsanders force-pushed the posthog-code/java-framework-support branch from ffc03e7 to de69e22 Compare July 22, 2026 20:41
@sarahxsanders
sarahxsanders changed the base branch from posthog-code/rust-framework-support to main July 22, 2026 20:42
Adds Java (server) as a supported framework, stacked on the Rust framework PR:

- Integration.java enum entry ordered after kmp/swift/android — those claim gradle projects first — and before the language fallbacks
- JAVA_AGENT_CONFIG in src/frameworks/java/ — claims pom.xml unconditionally (Maven is unambiguously JVM backend) and root gradle files only when they carry no Android/KMP plugin markers and no AndroidManifest.xml subtree exists; gathers buildTool (maven | gradle) as agent context; installs by editing the build file with com.posthog:posthog-server then resolving with mvn install / gradle build
- detectJavaPackageManagers detector (Maven via pom.xml, Gradle fallback reusing gradlePackageManager) + FRAMEWORK_REGISTRY entry
- No bash-fence changes needed: mvn/mvnw and gradle/gradlew grammars already exist from Android/KMP
- Pins framework: java on a new integration-java entry in the variant-resolution contract test, matching context-mill PR #270 which must release before this merges
- Marks pom.xml as a real framework target in the agentic manifest comment, leaving .NET as the only manifest without a target

Generated-By: PostHog Code
Task-Id: 9c949855-7611-48f2-b8b5-7aa4112543e5
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.

1 participant