Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixes

- Java packages named `build` under standard main and test source roots are now indexed without pulling Gradle or Maven build output into the graph. (#1642)


## [1.6.0] - 2026-08-26

Expand Down
33 changes: 33 additions & 0 deletions __tests__/extraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7637,6 +7637,39 @@ describe('Nested non-submodule git repos', () => {
expect(ig.ignores('dist/')).toBe(true); // valid rule survives
expect(ig.ignores('src/app.ts')).toBe(false);
});

it('keeps Java packages named build while excluding build output (#1642)', () => {
const sourceFile = 'module/src/main/java/com/acme/build/RealtimePlusService.java';
const testFile = 'module/src/test/java/com/acme/build/RealtimePlusServiceTest.java';
const outputFile = 'module/build/generated/Generated.java';

for (const rel of [sourceFile, testFile, outputFile]) {
const abs = path.join(tempDir, rel);
fs.mkdirSync(path.dirname(abs), { recursive: true });
fs.writeFileSync(abs, 'class Example {}\n');
}

const scope = buildScopeIgnore(tempDir);
expect(scope.ignores(sourceFile)).toBe(false);
expect(scope.ignores(testFile)).toBe(false);
expect(scope.ignores(outputFile)).toBe(true);

const files = scanDirectory(tempDir);
expect(files).toContain(sourceFile);
expect(files).toContain(testFile);
expect(files).not.toContain(outputFile);
});

it('lets an explicit .gitignore exclude a Java package named build (#1642)', () => {
const sourceFile = 'src/main/java/com/acme/build/Hidden.java';
const abs = path.join(tempDir, sourceFile);
fs.mkdirSync(path.dirname(abs), { recursive: true });
fs.writeFileSync(abs, 'class Hidden {}\n');
fs.writeFileSync(path.join(tempDir, '.gitignore'), 'src/main/java/**/build/\n');

expect(buildScopeIgnore(tempDir).ignores(sourceFile)).toBe(true);
expect(scanDirectory(tempDir)).not.toContain(sourceFile);
});
});

// =============================================================================
Expand Down
6 changes: 6 additions & 0 deletions src/extraction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ const DEFAULT_IGNORE_PATTERNS: string[] = [
'bazel-*/', // Bazel output symlink trees
// Android resource dirs at any depth, with their qualifier variants (#1047).
...ANDROID_RES_TYPES.map((t) => `**/res/${t}*/`),
// `build` is also a legal Java package segment. Keep it under conventional
// Java source roots while continuing to exclude module/build output (#1642).
'!**/src/main/java/**/build/',
'!**/src/main/java/**/build/**',
'!**/src/test/java/**/build/',
'!**/src/test/java/**/build/**',
];

/** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */
Expand Down