Skip to content

chore(spin-common): centralize source/output path literals in SourcePathKind - #176

Merged
deer merged 1 commit into
mainfrom
sourcekind_uptake
Aug 3, 2026
Merged

chore(spin-common): centralize source/output path literals in SourcePathKind#176
deer merged 1 commit into
mainfrom
sourcekind_uptake

Conversation

@deer

@deer deer commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

SourcePathKind previously exposed only a source-root string usable for detecting declared source directories, so every plugin that needed to place build output under main/ or test/, or needed the src/main//src/test/ prefix for other purposes, hardcoded the literal separately across the java, junit, and maven modules.

This adds a proper outputPrefix() alongside the renamed sourceRoot() accessor on SourcePathKind, both returning Optional<String>, and replaces every hardcoded "src/main/", "main/", "src/test/", "test/", and duplicated "module-info.java" literal in BuildOutputLocations, AbstractCompile, AbstractJavaDoc, AbstractJavaLinker, AbstractJavaPlugin, Java25CompilerPlugin, Java8CompilerPlugin, ResourcePlugin, AbstractJUnitPlugin, AbstractTest, Java25JUnitPlugin, Java8JUnitPlugin, and MavenPlugin with calls through SourcePathKind. AbstractJUnitPlugin's override of getSourceRootPath() is removed entirely since AbstractJavaPlugin now derives the root from the injected sourceScope() (MAIN or TEST) instead of a fixed src/main/ literal, and AbstractTest's module-info existence checks now reuse JDKModuleDescriptor.SOURCE_FILENAME instead of repeating the "module-info.java" string.

Call sites that reference the same prefix more than once within a class (Java25CompilerPlugin.Compile, Java8CompilerPlugin.Compile, Java25JUnitPlugin.Compile, Java8JUnitPlugin.Compile, MavenPlugin, AbstractCompile) hoist it into a private static final String constant rather than calling outputPrefix().orElseThrow() inline at each use, matching the pattern AbstractJavaDoc already used for its javadoc output path.

@deer
deer merged commit 0ae9280 into main Aug 3, 2026
1 check passed
@deer
deer deleted the sourcekind_uptake branch August 3, 2026 14:19
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