Class HashGeneratorMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="generate-hashes",
          defaultPhase=VALIDATE,
          requiresProject=true)
    public class HashGeneratorMojo
    extends org.apache.maven.plugin.AbstractMojo
    Generates companion hash files for AI instruction resources (e.g. AGENTS.md, SKILL.md).

    This mojo walks a base directory using NIO Files.walkFileTree, finds files matching the configured include globs, and writes a companion hash sidecar file alongside each matched file. The hash captures the file content at build time so that the verify mojo can later detect any unauthorized modifications.

    Security rationale: AI agent instructions must not change after the build begins or after the artifact is shipped. Generating hashes at build time creates a tamper-evident seal on all instruction files.

    Performance: Uses Files.walkFileTree for a single-pass directory traversal with directory pruning, a 64 KiB streaming hash buffer, and a lookup-table hex encoder. Handles both single-module projects and large multi-module projects efficiently.

    • Constructor Detail

      • HashGeneratorMojo

        public HashGeneratorMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException