Add OsFamily enum to io.spine.os - #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.
| var notMac = !macOS.matches(osName, pathSeparator) | ||
| || osName.endsWith("x") | ||
| || osName.contains(DARWIN); | ||
| var notVms = !osName.contains("openvms"); | ||
| return separatorMatches && notVms && notMac; |
| /** The lower-cased name of the OS family. */ | ||
| private final String signature; |
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:
|
Brings the
OsFamilyenum, previously available from ToolBase, intobaseunder the new
io.spine.ospackage, so that detecting the host operatingsystem no longer requires a dependency on ToolBase.
OsFamilyThe enum is a port of
org.apache.tools.ant.taskdefs.condition.Os, keepingthe detection rules of the original, including the OpenJDK quirk of reporting
Mac OS X as
Darwin.The families are deliberately not mutually exclusive — a macOS host belongs
to both
macOSandUnix— which the constant docs now state explicitly.Detection is split into two methods:
isCurrent()— the public API, applied to the currentos.nameandpath.separator.matches(osName, pathSeparator)— a package-private,@VisibleForTestingseam holding the actual rules.
The split exists because
os.nameis read into astatic finalfield at classinitialization. Without the seam, a test can only observe the family of the host
it happens to run on, which is what the first version of the spec did — on a
Linux runner it verified nothing beyond
Windows.isCurrent() == false.OsFamilySpecnow drives all three families through a table of realos.namevalues (Windows, Mac OS X, Darwin, Linux, HP-UX, SunOS, OpenVMS), and one test
ties the seam back to
isCurrent()on the host.configUpdated to
9c37ceb4, which brings a reworkedgeneratePomimplementation(lock-safe and deterministic) along with bumps of the local Spine SDK
dependencies.
The regenerated dependency reports are committed separately. Besides the
version line,
dependencies.mdgained entries for older transitive versions(
kotlin-stdlib-jdk7/81.8.20,kotlinx-coroutines1.7.3) pulled in by theupdated local Spine snapshots — worth a glance, but not a change in what the
published POM declares;
pom.xmldiffers only by the version.Pre-PR
./gradlew clean build dokkaGeneratepasses.Note for anyone building this branch incrementally: the
configbump moves theCompiler versions, which invalidates previously generated Protobuf sources
without triggering regeneration. A plain
./gradlew buildover a warm treefails in
:base:compileTestKotlinwith unresolved references to generated testtypes;
cleanresolves it. CI starts cold and is unaffected.