adityamparikh opened a new pull request, #297:
URL: https://github.com/apache/solr-mcp/pull/297
## Summary
Adds a test that enforces the server's package boundaries, so neither
contributors nor AI coding agents can erode them without noticing.
`ModularityTests` runs Spring Modulith's
`ApplicationModules.of(Main.class).verify()`:
```text
org.apache.solr.mcp.server # each direct sub-package is a module
├── collection/ config/ schema/ search/ security/ util/
└── indexing/
└── documentcreator/ # internal to `indexing`; other modules
may not use it
```
`verify()` fails on (a) dependency cycles between modules and (b) any module
using another module's internal sub-package types. The code already follows
this layout: every package has a `package-info.java`, and there are no
cross-module sub-package imports and no cycles. **No production code changes.**
This PR turns an existing convention into a build check.
```diff
gradle/libs.versions.toml
+ spring-modulith = "2.1.3" # line built against Boot
4.1
+ spring-modulith-starter-test -> `test` bundle
build.gradle.kts dependencyManagement.imports
+ mavenBom("org.springframework.modulith:spring-modulith-bom:…")
src/test/java/org/apache/solr/mcp/server/
+ ModularityTests.java # verify() + PlantUML diagrams to
build/spring-modulith-docs (not committed)
AGENTS.md (CLAUDE.md symlink)
+ "Module boundaries": if it fails, fix the design rather than the test;
+ expose internal packages only explicitly in package-info.java
```
Why now: more of this code is written with coding agents, which readily take
the shortest path, for example importing `indexing.documentcreator.*` from
`search`. Review catches some of that. A failing test catches all of it, and
its message tells the author (human or agent) exactly which dependency to fix.
**Test scope only.** Modulith is not on `productionRuntimeClasspath`, so the
bootJar, the CycloneDX SBOM, the generated binary LICENSE/NOTICE and the native
image are unchanged. The test is `@DisabledInNativeImage`, because ArchUnit
classpath scanning can't run in the `nativeTest` binary, the same treatment as
the Mockito-based tests. It starts no Spring context and needs no Solr, so it
runs in the plain `unitTest` task too. Spring Modulith is Apache-2.0.
## Evidence
- **Before:** nothing stops a cross-module reach into an internal package. A
throwaway `search/BoundaryProbe.java` taking a `JsonDocumentCreator` parameter
compiles and builds green on `main`.
**After:** the same probe fails the build:
```text
ModularityTests > verifiesModuleStructure() FAILED
org.springframework.modulith.core.Violations:
- Module 'search' depends on non-exposed type
org.apache.solr.mcp.server.indexing.documentcreator.JsonDocumentCreator
within module 'indexing'!
```
- Without the probe: `./gradlew build` passes, 459 tests, 0 failures
(`ModularityTests`: 2 tests, 0 skipped). Spotless, RAT and the binary-licence
completeness gate all pass.
- `./gradlew dependencies --configuration productionRuntimeClasspath | grep
-c modulith` → `0`.
- Checked against the currently open PRs: none add a sub-package import
across modules. #210's `indexing.documentcreator` import is from inside
`indexing`. A new top-level package (e.g. `cluster/` in #295) just becomes a
new module.
## Merge Danger
**Door:** two-way
Revert the commit to remove it: one test class, one BOM line, one catalog
entry, one doc section.
**Blast Radius:** test-classpath
The only new effect is on future PRs: one that adds a cycle or an internal
cross-module dependency now fails `test` and must restructure or expose the
package deliberately via `@NamedInterface` in `package-info.java`. The test
classpath gains `spring-modulith-core`/`-test`/`-docs` (with ArchUnit and
jMolecules), plus `spring-data-commons` and `spring-tx` transitively.
`spring-modulith-test` registers one `ContextCustomizerFactory`, and it only
acts on `@ApplicationModuleTest` classes, of which there are none. The full
suite passes unchanged.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]