Skip to content

Add OsFamily enum to io.spine.os - #957

Open
alexander-yevsyukov wants to merge 6 commits into
masterfrom
os-family-enum
Open

Add OsFamily enum to io.spine.os#957
alexander-yevsyukov wants to merge 6 commits into
masterfrom
os-family-enum

Conversation

@alexander-yevsyukov

Copy link
Copy Markdown
Contributor

Brings the OsFamily enum, previously available from ToolBase, into base
under the new io.spine.os package, so that detecting the host operating
system no longer requires a dependency on ToolBase.

OsFamily

The enum is a port of org.apache.tools.ant.taskdefs.condition.Os, keeping
the 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 macOS and Unix — which the constant docs now state explicitly.

Detection is split into two methods:

  • isCurrent() — the public API, applied to the current os.name and
    path.separator.
  • matches(osName, pathSeparator) — a package-private, @VisibleForTesting
    seam holding the actual rules.

The split exists because os.name is read into a static final field at class
initialization. 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.
OsFamilySpec now drives all three families through a table of real os.name
values (Windows, Mac OS X, Darwin, Linux, HP-UX, SunOS, OpenVMS), and one test
ties the seam back to isCurrent() on the host.

config

Updated to 9c37ceb4, which brings a reworked generatePom implementation
(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.md gained entries for older transitive versions
(kotlin-stdlib-jdk7/8 1.8.20, kotlinx-coroutines 1.7.3) pulled in by the
updated local Spine snapshots — worth a glance, but not a change in what the
published POM declares; pom.xml differs only by the version.

Pre-PR

./gradlew clean build dokkaGenerate passes.

Note for anyone building this branch incrementally: the config bump moves the
Compiler versions, which invalidates previously generated Protobuf sources
without triggering regeneration. A plain ./gradlew build over a warm tree
fails in :base:compileTestKotlin with unresolved references to generated test
types; clean resolves it. CI starts cold and is unaffected.

alexander-yevsyukov and others added 6 commits August 12, 2026 17:16
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>
Copilot AI lite review requested due to automatic review settings August 18, 2026 22:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.OsFamily with isCurrent() 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.

Comment on lines +71 to +75
var notMac = !macOS.matches(osName, pathSeparator)
|| osName.endsWith("x")
|| osName.contains(DARWIN);
var notVms = !osName.contains("openvms");
return separatorMatches && notVms && notMac;
Comment on lines +91 to +92
/** The lower-cased name of the OS family. */
private final String signature;
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.00%. Comparing base (51cb428) to head (8abcd67).
⚠️ Report is 1 commits behind head on master.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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