Skip to content

chore(spin-common): unify source-path detection behind SourcePathKind - #170

Merged
deer merged 1 commit into
mainfrom
detect_source_again
Jul 31, 2026
Merged

chore(spin-common): unify source-path detection behind SourcePathKind#170
deer merged 1 commit into
mainfrom
detect_source_again

Conversation

@deer

@deer deer commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Every plugin that needed to know where source lived -- Java25CompilerPlugin, Java8CompilerPlugin, Java25JUnitPlugin, Java8JUnitPlugin, CheckstylePlugin, MavenPlugin -- carried its own near-duplicate DetectSourceFiles/DetectSourcePaths/DetectGeneratedSourcePaths/DetectExternalGeneratedSourcePaths/DetectAllSourcePaths task interfaces and abstract base classes, six of which did nothing but repeat the same directory-walking logic under a different name.

This collapses all of that into a single SourcePathKind enum (MAIN, TEST, GENERATED, EXTERNAL_GENERATED) in spin-common, plus one DetectSourcePaths task interface whose detect() now returns Map<SourcePathKind, PathSet>. Each plugin's AbstractDetectSourcePaths subclass only declares which kinds it's responsible for; consumers pull out just the kinds they need via the new DetectSourcePaths.filesOf/pathsOf static helpers. The interface is tagged @Category("source-paths") and @Merge, so a @From(DetectSourcePaths.class) Map<SourcePathKind, PathSet> parameter automatically receives the combined result of every implementor in the project rather than requiring callers to know which concrete plugin classes exist.

This also fixes a real gap in CheckstylePlugin: previously, honoring a project's <includeTestSourceDirectory> setting required a private helper that duplicated AbstractDetectSourceFiles's walk logic and hardcoded the src/test/java convention rather than going through the same TEST-kind detection JUnitPlugin uses. It now asks for SourcePathKind.MAIN/TEST from the merged map like everything else, and AbstractResourcePlugin.DetectResourcePaths was decoupled from DetectSourcePaths entirely, since resource directories were never actually "source paths" and would no longer type-check against the new Map-returning interface.

@deer
deer merged commit 17c7189 into main Jul 31, 2026
1 check passed
@deer
deer deleted the detect_source_again branch July 31, 2026 08:29
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