Class HashVerifyMojo

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

    @Mojo(name="verify-hashes",
          defaultPhase=TEST,
          requiresProject=true)
    public class HashVerifyMojo
    extends org.apache.maven.plugin.AbstractMojo
    Verifies that AI instruction resource files have not been modified since their hashes were generated.

    This mojo finds all companion hash sidecar files under the base directory using NIO Files.walkFileTree, recomputes the hash of the corresponding source file, and compares the two. If any mismatch is detected, the build fails with a MojoExecutionException.

    Security rationale: AI agent instructions must not change once a build has begun or after the artifact is shipped. This verification step ensures that no instruction file has been tampered with between the generate phase and the verification phase.

    Performance: Uses Files.walkFileTree for a single-pass directory traversal with directory pruning. Handles both single-module projects and large multi-module projects efficiently.

    • Constructor Detail

      • HashVerifyMojo

        public HashVerifyMojo()
    • Method Detail

      • execute

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