Skip to content

Add Gradle plugin#187

Merged
alexander-yevsyukov merged 18 commits intomasterfrom
add-gradle-plugin
Mar 27, 2026
Merged

Add Gradle plugin#187
alexander-yevsyukov merged 18 commits intomasterfrom
add-gradle-plugin

Conversation

@alexander-yevsyukov
Copy link
Copy Markdown
Contributor

@alexander-yevsyukov alexander-yevsyukov commented Mar 26, 2026

This PR extends the Time library with an ability to add the artifacts of the library via io.spine.time Gradle plugin.

Later this plugin will allow to add code generation for the (when) validation option.

Other notable chages

  • The Time TestLib arifact no longer has the spine- prefix in the name. So, the coordinate for the test library is io.spine.tools:time-testlib:$version.
  • Latest config was applied.

- Add TimeGradlePlugin applying plugin ID 'io.spine.time'
- Add TimeGradleExtension with useJavaExtensions / useKotlinExtensions properties
- Add TimeLibrary with runtime, javaExtensions, kotlinExtensions artifacts
- Add Meta backed by LazyMeta for version resolution at runtime
- Configure artifactMeta with spine-time, spine-time-java, spine-time-kotlin
- Set up custom publishing under io.spine.tools:time-gradle-plugin
- Add jvmToolPlugins to buildscript classpath for io.spine.artifact-meta
- Include gradle-plugin in settings and exclude it from standard publishing
... so that the `publishing` block is available.
- Add `TimeLibrary.testLib` for `io.spine:spine-time-testlib`
- Add `useTestLib: Property<Boolean>` to `TimeGradleExtension`
- When `true`, add `spine-time-testlib` to `testImplementation`
- Tailor the missing-configuration error for `testImplementation`
- Cover `useTestLib` with `TimeGradlePluginSpec`
- Replace `Plugin<Project>` with `LibraryPlugin<TimeGradleExtension>`,
  passing `DslSpec(TimeGradleExtension.NAME, TimeGradleExtension::class)`
  to the constructor.
- Extension is now nested under `RootExtension` (i.e. `spine.time { ... }`);
  creation is delegated to `LibraryPlugin`.
- Extract plugin logic into a private `Project.configureTime()` function
  and a private `Project.timeExtension` property backed by
  `spineExtension<TimeGradleExtension>()`.
- Add `ToolBase.gradlePluginApi` dependency to the compile classpath,
  where `LibraryPlugin`, `DslSpec`, and `spineExtension` reside.
- Declare `spine-time-testlib` in `addDependencies` so that
  `LazyMeta.dependency()` can resolve it at runtime.
- Update `TimeGradlePluginSpec` to obtain the extension via
  `project.spineExtension<TimeGradleExtension>()`.
... because there's no such a module any more.
- Replace plain `object Time` with `object Time : Dependency()`.
- Override `group`, `version`, and `modules` to satisfy the abstract contract.
- Add `lib(version)`, `javaExtensions(version)`, `kotlinExtensions(version)`,
  and `testLib(version)` functions for explicit-version overloads, following
  the same pattern as `Compiler`.
- Keep `val lib`, `val javaExtensions`, `val kotlinExtensions`, and `val testLib`
  as computed properties backed by `version`, preserving all existing call sites.
- Make `infix` private — it is only used internally.
- `modules` strips the version suffix from each coordinate (same pattern as
  `Compiler`), including `testLib` which lives under `io.spine.tools`.
- Update `@Suppress` annotations to match the standard set used on `Compiler`.
- Rename the artifact from `spine-time-testlib` to `time-testlib`
  in all references — `Time.testLib`, `TimeLibrary.testLib`,
  `artifactMeta.addDependencies`, and KDoc — to follow the
  `io.spine.tools` group convention of not using the prefix.
- Override the publication `artifactId` in `time-testlib/build.gradle.kts`
  so that `spinePublishing`'s default `spine-` prefix is not applied
  when the module is published.
- Replace hard-coded coordinate strings in `gradle-plugin/build.gradle.kts`
  with `Time.lib()`, `Time.javaExtensions()`, `Time.kotlinExtensions()`,
  and `Time.testLib()` calls.
- Merge `hasImplDep` / `hasTestImplDep` in `TimeGradlePluginSpec`
  into a single `hasDependency(artifact, configuration)` helper.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0b7429f01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +88 to +90
named<MavenPublication>("pluginMaven") {
artifactId = moduleArtifactId
addSourceAndDocJars(project)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reset marker publication coordinates for plugin DSL resolution

This block restores coordinates only for pluginMaven, but the module is also routed through custom Spine publishing (modulesWithCustomPublishing), which rewrites all Maven publications via copyProjectAttributes() (prefixing artifactId and forcing groupId). As a result, the generated marker publication (spineTimePluginMarkerMaven) keeps incorrect coordinates, so consumers using plugins { id("io.spine.time") version "..." } cannot resolve the plugin from your Maven repositories because Gradle looks for the unmodified marker coordinates.

Useful? React with 👍 / 👎.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 83.78378% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.75%. Comparing base (b24a928) to head (5b0ed73).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #187      +/-   ##
============================================
- Coverage     93.21%   92.75%   -0.46%     
- Complexity      294      304      +10     
============================================
  Files            53       57       +4     
  Lines           943      980      +37     
  Branches         26       31       +5     
============================================
+ Hits            879      909      +30     
- Misses           56       61       +5     
- Partials          8       10       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexander-yevsyukov alexander-yevsyukov merged commit 3da3ad4 into master Mar 27, 2026
7 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the add-gradle-plugin branch March 27, 2026 10:35
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