Repository navigation
Fix OsFamily detection and make it testable - #957
Conversation
Extract the detection rules into a package-private `matches(osName, pathSeparator)` seam so that they can be verified for any operating system, not only for the one running the build. `isCurrent()` applies the seam to the current `os.name` and `path.separator`. Cover all three families with a table of real `os.name` values, and document the constants, including the fact that a macOS host belongs to the `Unix` family too. Read the system properties with defaults to avoid an `ExceptionInInitializerError` if a property is absent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new io.spine.os package with an OsFamily enum (ported from Ant) to detect the host OS without requiring a ToolBase dependency, and updates version/dependency-report artifacts accordingly. The PR also includes a substantial generatePom rework (via config/built tooling updates) with additional tests.
Changes:
- Introduce
io.spine.os.OsFamilywithisCurrent()and a test seam (matches(...)) plus unit tests covering multiple OS name variants. - Bump published snapshot version and regenerate dependency reports/POM to match.
- Update build tooling around
generatePom(lock-safe/deterministic behavior) and add Gradle TestKit coverage.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| version.gradle.kts | Bumps versionToPublish snapshot. |
| docs/dependencies/pom.xml | Updates generated POM version to match snapshot. |
| docs/dependencies/dependencies.md | Regenerates dependency license report content and timestamps. |
| buildSrc/build.gradle.kts | Configures TestKit + passes buildSrc classpath to functional tests. |
| buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt | Refactors dependency version sourcing to use collected resolved versions. |
| buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomGenerator.kt | Makes generatePom depend on per-project resolved-version collectors. |
| buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt | Threads resolved-version source into XML generation. |
| buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ResolvedVersions.kt | Adds per-project collector task + resolution graph extraction. |
| buildSrc/src/test/kotlin/io/spine/gradle/report/pom/DependencyWriterSpec.kt | Updates/extends unit coverage around resolved versions behavior. |
| buildSrc/src/test/kotlin/io/spine/gradle/report/pom/PomGeneratorIgTest.kt | Adds TestKit integration test for generatePom determinism and conflict handling. |
| buildSrc/src/main/kotlin/io/spine/dependency/local/*.kt | Bumps local Spine SDK dependency versions. |
| buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt | Minor refactor/clarification of Jackson module coordinates/docs. |
| buildSrc/src/main/kotlin/io/spine/dependency/lib/JacksonV2.kt | Clarifies Jackson JSTEP-1 reference. |
| base/src/main/java/io/spine/os/package-info.java | Introduces io.spine.os package with nullness/return-value annotations. |
| base/src/main/java/io/spine/os/OsFamily.java | Adds OS-family detection API and matching rules. |
| base/src/test/kotlin/io/spine/os/OsFamilySpec.kt | Adds parameterized tests for Windows/macOS/Unix matching and host-property consistency. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #957 +/- ##
==========================================
- Coverage 94.01% 94.00% -0.02%
==========================================
Files 194 195 +1
Lines 4177 4201 +24
Branches 345 351 +6
==========================================
+ Hits 3927 3949 +22
Misses 149 149
- Partials 101 103 +2 🚀 New features to boost your workflow:
|
# Conflicts: # buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt # buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt # buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt # buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt # buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt # buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt # buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ResolvedVersions.kt # buildSrc/src/test/kotlin/io/spine/gradle/report/pom/PomGeneratorIgTest.kt # config # docs/dependencies/dependencies.md # docs/dependencies/pom.xml # version.gradle.kts
Rename `notMac` to `notClassicMac` in `Unix.matches()`, since the condition admits macOS and excludes only the classic (pre-OS X) Mac OS. Correct the `signature` Javadoc, which did not account for `macOS` passing its own value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the header used across the rest of the code after the merge of `master`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The `OsFamily` enum ported from ToolBase into `io.spine.os` duplicated the existing `io.spine.environment.OsFamily`. Move it over the older enum and drop the `io.spine.os` package. The replacement follows Ant's rules: the families overlap, so a macOS host is also a Unix, and Unix systems whose names do not end with `x`, such as SunOS, are now detected. `detect()` is kept and returns the most specific family; it gains the same `@VisibleForTesting` seam as `isCurrent()`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OsFamily enum to io.spine.osenvironment.OsFamily with the ToolBase version
environment.OsFamily with the ToolBase versionOsFamily detection and make it testable
Reworks
io.spine.environment.OsFamilyso that it follows the detection rules oforg.apache.tools.ant.taskdefs.condition.Os, which it is based on, and so thatthe rules can be tested regardless of the host the tests run on.
Detection
The previous implementation deviated from Ant in how it told a Unix:
Unix.isCurrent()on macOSfalse— the families were mutually exclusivetrue— a macOS host belongs to bothmacOSandUnixxUnix, sodetect()threwUnixos.nameorpath.separatorpropertyIllegalStateExceptionUnixis told by the:path separator, minus the two systems that use itwithout being a Unix: OpenVMS and classic (pre-OS X) Mac OS.
As the families now overlap, code that relied on them being mutually exclusive
should use
detect(). It returns the most specific family —macOSrather thanUnixon a Mac — relying on the more specific families being declared first.When the OS belongs to none of the families, its exception now names the
os.namevalue.Testability
The public methods keep their signatures:
isCurrent()anddetect(). The rulesmove into two package-private,
@VisibleForTestingmethods,matches(osName, pathSeparator)anddetect(osName, pathSeparator), which thepublic ones apply to the current system properties.
The properties are read into
static finalfields at class initialization, sobefore this change a test could only observe the family of the host it ran on.
OsFamilySpecnow drives each family anddetect()through a table of realos.namevalues (Windows, Mac OS X, Darwin, classic Mac OS, Linux, HP-UX,SunOS, OpenVMS), covers the failure of
detect(), and ties the seams back tothe public methods on the host.
OsFamilyis fully covered.Documentation
Each constant is now documented, and the docs of the enum and
detect()statethe overlap of the families and the exception
detect()throws.Housekeeping
configmoves to94a9e08b, which addsSpineEventEngine/config#780
and SpineEventEngine/config#781
to the ref on
master. The bump changes no file of this repository by itself.2.0.0-SNAPSHOT.445, with the dependency reports regeneratedto match.
Verification
./gradlew :base:build :environment:build :base:dokkaGenerate :environment:dokkaGeneratepasses on the head of the branch.
🤖 Generated with Claude Code