Skip to content

fix: detect fresh Java projects via pom.xml/build.gradle#39

Closed
mashraf-222 wants to merge 1 commit intomainfrom
fix/java-detection-fresh-projects
Closed

fix: detect fresh Java projects via pom.xml/build.gradle#39
mashraf-222 wants to merge 1 commit intomainfrom
fix/java-detection-fresh-projects

Conversation

@mashraf-222
Copy link
Copy Markdown
Contributor

Problem

The hook only checked for codeflash.toml to identify Java projects. Fresh projects with only pom.xml or build.gradle were invisible — the hook silently exited when .java files were committed.

Fix

  • Add pom.xml/build.gradle/build.gradle.kts detection in detect_project()
  • Add HAS_JAVA_CHANGES guard to match existing Python/JS guards
  • Remove broken "not configured" block (CLI auto-configures via --subagent)
  • Add 6 Java bats tests + helpers

Test plan

  • 31/31 bats tests pass (25 existing + 6 new Java)
  • Manual simulation: fresh Maven project → hook triggers correctly
  • Manual simulation: .py-only commit in Java project → Java path skipped
  • Manual simulation: JS and Python projects → unchanged behavior

The hook's detect_project() only checked for codeflash.toml to identify
Java projects. Fresh projects with only pom.xml or build.gradle were
invisible — the hook silently did nothing when .java files were committed.

On the current codeflash main branch, the CLI auto-detects and
auto-configures Java from build files via handle_first_run(), so no
pre-configuration step is needed in the hook.

Changes:
- Add pom.xml/build.gradle/build.gradle.kts detection in detect_project()
- Add HAS_JAVA_CHANGES guard (matching existing Python/JS guards)
- Remove broken "not configured" block that called interactive codeflash init
- Add 6 Java bats tests + test helpers (add_java_commit, create_pom_xml, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mashraf-222 mashraf-222 requested a review from aseembits93 March 26, 2026 01:44
@mashraf-222
Copy link
Copy Markdown
Contributor Author

Closing in favor of PR #34 which takes a unified approach (language-agnostic hook that delegates to CLI). Java build file detection has been added to #34's detect_any_config() function, covering the same gap this PR addressed.

@aseembits93 aseembits93 deleted the fix/java-detection-fresh-projects branch April 9, 2026 00:15
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