Skip to content

Conversation

@yevheniisemenov
Copy link

@yevheniisemenov yevheniisemenov commented Nov 11, 2025

Introduces a generic StrategyLookup utility and makes DocumentationSource configurable via the spring.modulith.documentation-source property, following the same pattern as ApplicationModuleDetectionStrategy.

Key changes:

  • Create generic StrategyLookup utility in spring-modulith-core for reusable configuration-based strategy lookups
  • Refactor ApplicationModuleDetectionStrategyLookup to use the generic StrategyLookup utility, reducing code duplication
  • Add DocumentationSourceLookup with support for predefined strategies and custom implementations via property configuration
  • Add NoOpDocumentationSource as fallback implementation
  • Update Asciidoctor to use DocumentationSourceLookup instead of hardcoded static field
  • Make DocumentationSource interface public (was package-private) and add getDocumentation(JavaPackage) method for package-level docs
  • Add spring-configuration-metadata.json for IDE autocomplete support
  • Add comprehensive test coverage with DocumentationSourceLookupTests

Introduces a generic StrategyLookup utility and makes DocumentationSource
configurable via the spring.modulith.documentation-source property,
following the same pattern as ApplicationModuleDetectionStrategy.

Key changes:
- Create generic StrategyLookup<T> utility in spring-modulith-core for
  reusable configuration-based strategy lookups
- Refactor ApplicationModuleDetectionStrategyLookup to use the generic
  StrategyLookup utility, reducing code duplication
- Add DocumentationSourceLookup with support for predefined strategies
  and custom implementations via property configuration
- Add NoOpDocumentationSource as fallback implementation
- Update Asciidoctor to use DocumentationSourceLookup instead of
  hardcoded static field
- Make DocumentationSource interface public (was package-private) and
  add getDocumentation(JavaPackage) method for package-level docs
- Add spring-configuration-metadata.json for IDE autocomplete support
- Add comprehensive test coverage with DocumentationSourceLookupTests

The implementation supports:
- Predefined strategy: 'spring-modulith' (uses SpringModulithDocumentationSource)
- Custom implementations via fully qualified class name
- SpringFactoriesLoader fallback with deprecation warning (for compatibility)
- IDE autocomplete via configuration metadata

Signed-off-by: Yevhenii Semenov <zhe.semenov@gmail.com>
@odrotbohm
Copy link
Member

Can we change this to not affect spring-modulith-core?

@yevheniisemenov
Copy link
Author

Yes, we can, but that would result in essentially duplicating the ApplicationModuleDetectionStrategyLookup code in the docs module. Would this approach be acceptable?

@odrotbohm
Copy link
Member

That's fine for now. I'd like to see how that looks before prematurely introducing an abstraction over an abstraction.

Reverts the generic StrategyLookup<T> utility and restores the original
ApplicationModuleDetectionStrategyLookup implementation in the core module.
The DocumentationSourceLookup now contains an inline implementation of the
lookup pattern, removing the dependency on the core module's generic utility.

Key changes:
- Restore ApplicationModuleDetectionStrategyLookup to original implementation
  with static initializer, Logger field, and switch statement
- Delete generic StrategyLookup<T> utility class from core/config package
- Duplicate lookup pattern inline in DocumentationSourceLookup with private
  helper method for SpringFactoriesLoader fallback

This approach favors module independence over code reuse, keeping the core
module unchanged while maintaining all documentation source functionality.

All tests pass: 84 tests in core module, 15 tests in docs module.

Signed-off-by: Yevhenii Semenov <zhe.semenov@gmail.com>
@yevheniisemenov
Copy link
Author

Done. The core module is now unaffected by changes. Please let me know if any other changes are needed.

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.

2 participants