feat(bundle-jvm): Automatically collect JVM source files with respecting excludes and gitignore #3260
Merged
feat(bundle-jvm): Automatically collect JVM source files with respecting excludes and gitignore #3260
Conversation
Filter collected sources by JVM file extensions (java, kt, scala, groovy, kts) and exclude common build output directories by default (build, .gradle, .cxx, node_modules). Also respect .gitignore rules as an additional layer of defense. Users can provide extra --exclude glob patterns on top of the defaults. This enables invoking bundle-jvm directly on a project root without needing to pre-copy sources into a separate directory. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add .clj and .cljc to JVM extensions. Expand default excludes to cover Maven (target, .mvn), IDE (.idea, .vscode, .eclipse, .settings, .fleet), and common output dirs (bin, out, .kotlin). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Include Scala (.scala, .sc), Groovy (.groovy, .gvy, .gy, .gsh), Gradle (.gradle), Clojure (.clj, .cljs, .cljc, .edn), JRuby (.rb), and Jython (.py). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
szokeasaurusrex
approved these changes
Apr 13, 2026
Member
szokeasaurusrex
left a comment
There was a problem hiding this comment.
Some small suggestions
Sort DEFAULT_EXCLUDES alphabetically. Avoid allocating intermediate vectors by using Cow and iterator chaining for excludes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Split default excludes into two categories: - Safe excludes (dot-prefixed dirs, node_modules) applied globally via walker overrides since they can never be valid JVM package names - Ambiguous excludes (build, target, bin, out) applied via post-filter only when they appear outside of src/ directories This prevents false exclusion of legitimate packages like com.example.build while still excluding build output directories like app/build/generated/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix is_in_ambiguous_build_dir to check for src only in ancestors *above* the ambiguous directory. Previously, build/src/main/java/Foo.java would not be excluded because src appeared in the full path, even though build is the outermost (non-src) directory. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix is_in_ambiguous_build_dir to check *all* ambiguous directories in the path, not just the first one found. Previously, build/src/main/java/com/example/target/Foo.java would be kept because the inner `target` has `src` above it, even though the outer `build` does not. Now any ambiguous dir without a src ancestor triggers exclusion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Store SAFE_EXCLUDES as plain names (consistent with AMBIGUOUS_EXCLUDES), prepend ! at the call site for all excludes uniformly - Remove Cow import and ceremony — no longer needed - Merge filter + map into filter_map to avoid redundant strip_prefix - Move source.path and source.contents instead of cloning (owned via into_iter) - Trim redundant doc comments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
szokeasaurusrex
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
java,kt,scala,groovy) instead of collecting all filesbuild,.gradle,.cxx,node_modules).gitignore/.ignorerules as an additional layer of defense--excludeCLI arg for user-provided glob patterns on top of defaultsThis enables invoking
bundle-jvmdirectly on a project root without needing to pre-copy sources into a separate directory (e.g. from the Android Gradle plugin'sCollectSourcesTask).This also does not break the existing plugins' workflows, only in subtle cases where a non-JVM file has been included into the
src/main/javasource set, but this is likely not supported on the product side either.Test plan
bundle-jvmon an Android project root and verify only.java/.ktfiles are collectedbuild/directory contents are excluded.gitignored paths are respected--excludewith custom glob patternsReleaseFileSearchare unaffected (defaultrespect_ignores: false)🤖 Generated with Claude Code