Skip to content

Suppress Java codegen warnings via Gradle DSL; fix duplicate and false-positive warnings#309

Open
alexander-yevsyukov wants to merge 65 commits into
masterfrom
address-issues
Open

Suppress Java codegen warnings via Gradle DSL; fix duplicate and false-positive warnings#309
alexander-yevsyukov wants to merge 65 commits into
masterfrom
address-issues

Conversation

@alexander-yevsyukov
Copy link
Copy Markdown
Collaborator

@alexander-yevsyukov alexander-yevsyukov commented May 21, 2026

Three related fixes around Validation Compiler warnings, plus the
documentation that exposes the new configuration knob.

1. Suppress unsigned-integer warning via Gradle DSL

Users can now silence the "unsigned integer types are not supported in
Java"
warning emitted for uint32 / uint64 fields with (range),
(min), or (max):

spine {
    validation {
        java {
            warnings {
                unsignedFields.set(false)
            }
        }
    }
}

Implementation:

  • New top-level :java-settings proto-only module hosting
    spine.validation.java.ValidationWarnings.
  • ValidationExtension gains nested java { warnings { ... } } blocks
    (both abstract @Inject classes inside the extension, per the
    Spine nested-DSL convention). Positive polarity throughout — true
    means emit.
  • ValidationGradlePlugin always writes the typed ValidationWarnings
    in Format.ProtoBinary to the Spine Compiler settings directory for
    the consumer JavaValidationRenderer. The renderer reads it via
    LoadsSettings and injects the flag into UnsignedIntegerWarnings.
  • Default behavior is unchanged when no configuration is provided.

2. Deduplicate unsigned-integer warning reporting

BoundedFieldGenerator previously had the warning call commented out
(see issue #227). Re-enabled it and routed it through
UnsignedIntegerWarnings, which now dedupes per (file, span) and is
cleared at the start of each render. Suppression state is also cleared
before each compilation.

3. Fix false-positive (required) warning for primitive assumed IDs

RequiredGenerator no longer emits the "field assumed required"
warning when the assumed-required field is a primitive type (e.g.
int64 id = 1 as the first field of an entity). Regression coverage
in AssumedRequiredIdSpec and AssumedRequiredITest.

4. New "Validation Gradle plugin" docs section

docs/content/docs/validation/user/06-gradle-plugin/_index.md documents
the plugin and every property of ValidationExtension (enabled,
warnings.unsignedFields), with a forward link from
Adding to build. Sidenav updated.

Copilot AI and others added 20 commits May 13, 2026 18:17
Agent-Logs-Url: https://github.com/SpineEventEngine/validation/sessions/68b0cb8a-7b52-4402-9110-5252ffe52f56

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SpineEventEngine/validation/sessions/e964dc0d-3376-4fb4-bdb2-ae3dce54cab8

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SpineEventEngine/validation/sessions/35bfa4c1-1992-4221-b4ab-a9c658269d4c

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SpineEventEngine/validation/sessions/35bfa4c1-1992-4221-b4ab-a9c658269d4c

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SpineEventEngine/validation/sessions/f90f333f-cd83-44ed-9a22-42cbbad478ae

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
…d-error-placeholders' into copilot/fix-duplicated-warning-message

# Conflicts:
#	java/src/main/kotlin/io/spine/tools/validation/java/generate/option/bound/BoundedFieldGenerator.kt
#	version.gradle.kts

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SpineEventEngine/validation/sessions/f7e81e60-437d-4fd5-a6c4-7549d5cd987a

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
…ns/b81d4af0-e5e0-46d0-adb7-40a8f1c67aa7

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SpineEventEngine/validation/sessions/c0c59d00-5e83-41d0-8488-c2618a6ea31a

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
…o copilot/fix-false-warning-for-required-id

# Conflicts:
#	java/src/main/kotlin/io/spine/tools/validation/java/generate/option/RequiredGenerator.kt

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
…opilot/fix-duplicated-warning-message

# Conflicts:
#	java/src/main/kotlin/io/spine/tools/validation/java/generate/option/RequiredGenerator.kt

Co-authored-by: alexander-yevsyukov <3116444+alexander-yevsyukov@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 21, 2026 15:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the Validation project version/dependency reports and adjusts (required) validation generation so that primitive-typed “assumed required” entity IDs (e.g. int32 id) are not treated as required, with accompanying test coverage. It also tightens repository AI-agent operational rules (no history-writing without explicit authorization) and enhances the version-bumped gate to auto-discover the publishing version key.

Changes:

  • Bump Validation version to 2.0.0-SNAPSHOT.434 and refresh dependency versions/reports (Base/Jackson/SnakeYAML, etc.).
  • Prevent (required) codegen for unsupported primitive field types by filtering required fields via RequiredFieldSupport.isSupported().
  • Add test fixtures and specs covering entity IDs with primitive types and update Claude/agent safety and tooling hooks.

Reviewed changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
version.gradle.kts Bumps published Validation version to 2.0.0-SNAPSHOT.434.
tests/validating/src/testFixtures/proto/spine/test/tools/validate/entity.proto Updates header and adds NumberStats entity with primitive int32 id.
tests/validating/src/test/kotlin/io/spine/test/options/AssumedRequiredITest.kt Adds integration test asserting primitive entity IDs aren’t required.
java/src/main/kotlin/io/spine/tools/validation/java/generate/option/RequiredGenerator.kt Filters required-field codegen to supported field types only.
docs/dependencies/pom.xml Updates generated dependency POM snapshot versions.
docs/dependencies/dependencies.md Updates generated dependency/license report content and timestamps.
context-tests/src/testFixtures/proto/spine/validation/assumed_required_id_spec.proto Adds proto stub for entity with int32 id for compiler/context testing.
context-tests/src/test/kotlin/io/spine/tools/validation/AssumedRequiredIdSpec.kt Adds spec ensuring no warnings are emitted for int32 ID assumed-required handling.
CLAUDE.md Adds explicit rule prohibiting commits/pushes/tags without current authorization.
buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt Updates referenced Validation SDK version constants.
buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt Bumps spine-base version to 2.0.0-SNAPSHOT.390 and updates header year.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt Bumps Jackson BOM/runtime versions (2.21.3) and annotations version (2.21).
build.gradle.kts Removes forced pin to spine-validation-java-runtime:2.0.0-SNAPSHOT.360.
.claude/settings.json Adds post-tool hook to run update-copyright.sh.
.agents/tasks/prohibit-automatic-commits.md Adds task doc describing the “no history writes without authorization” goal/plan.
.agents/skills/version-bumped/scripts/version-bumped.sh Adds publishing-version-key auto-discovery and more flexible parsing.
.agents/skills/dependency-audit/SKILL.md Updates audit procedure guidance and batching recommendations.
.agents/skills/bump-version/SKILL.md Adds explicit ## Commit authorization constraints for the skill.
.agents/skills/bump-gradle/SKILL.md Adds explicit ## Commit authorization constraints for the skill.
.agents/scripts/update-copyright.sh Introduces post-tool hook script to refresh copyright years.
.agents/safety-rules.md Adds “Commits and history-writing” safety policy.
.agents/quick-reference-card.md Adds quick reminder linking to the new history-writing safety rule.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .agents/scripts/update-copyright.sh Outdated
…essage' into address-issues

# Conflicts:
#	docs/content/docs/validation/developer/build-and-release.md
#	docs/content/docs/validation/user/01-getting-started/adding-to-build.md
#	docs/dependencies/dependencies.md
#	docs/dependencies/pom.xml
#	java/src/main/kotlin/io/spine/tools/validation/java/generate/option/RequiredGenerator.kt
#	java/src/main/kotlin/io/spine/tools/validation/java/generate/option/bound/BoundedFieldGenerator.kt
#	version.gradle.kts
Copilot AI review requested due to automatic review settings May 21, 2026 19:48
@alexander-yevsyukov alexander-yevsyukov changed the title Address issues Suppress Java codegen warnings via Gradle DSL; fix duplicate and false-positive warnings May 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 46 out of 48 changed files in this pull request and generated 2 comments.

Comment thread settings.gradle.kts
Comment thread .agents/scripts/update-copyright.sh
@alexander-yevsyukov alexander-yevsyukov marked this pull request as ready for review May 21, 2026 19:56
Copilot AI review requested due to automatic review settings May 21, 2026 19:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 46 out of 48 changed files in this pull request and generated 4 comments.

Comment thread docs/content/docs/validation/user/06-gradle-plugin/_index.md
Comment thread docs/content/docs/validation/user/06-gradle-plugin/_index.md
Comment thread java-settings/build.gradle.kts Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 20:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 44 out of 46 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

gradle-plugin/src/main/kotlin/io/spine/tools/validation/gradle/ValidationExtension.kt:153

  • warnings is created with project.objects.newInstance(Warnings::class.java), but Warnings also has an @Inject constructor that requires a Project parameter. This is the same instantiation mismatch as with Java and can cause extension creation to fail. Prefer injecting ObjectFactory into Warnings, or pass project into newInstance(...).

Comment thread java-settings/src/main/proto/spine/validation/java/validation_warnings.proto Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 20:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 44 out of 46 changed files in this pull request and generated 1 comment.

Comment on lines +27 to +29
import io.spine.dependency.local.Base
import io.spine.dependency.local.Spine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

3 participants