Class CompareMojo

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

    @Mojo(name="compare",
          threadSafe=true)
    public class CompareMojo
    extends AbstractBuildinfoMojo
    Compare current build output (from package) against reference either previously install-ed or downloaded from a remote repository: comparison results go to .buildcompare file.
    Since:
    3.2.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean aggregateOnly
      Compare aggregate only (ie wait for the last module) or also compare on each module.
      private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory  
      private org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout artifactRepositoryLayout  
      private boolean fail
      Fail the build if differences are found against reference build.
      private java.lang.String referenceRepo
      Repository for reference build, containing either reference buildinfo file or reference artifacts.
      Format: id or url or id::url id The repository id url The url of the repository
      private java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepos
      The project's remote repositories to use for the resolution.
      private org.eclipse.aether.RepositorySystemSession repoSession
      The current repository/network configuration of Maven.
      private org.eclipse.aether.RepositorySystem repoSystem
      The entry point to Maven Artifact Resolver, i.e.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      CompareMojo()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkAgainstReference​(java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts, boolean mono)
      Check current build result with reference.
      private java.lang.String[] checkArtifact​(org.apache.maven.artifact.Artifact artifact, java.lang.String prefix, java.util.Properties reference, java.util.Properties actual, java.io.File referenceDir)  
      private void compareWithReference​(java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts, java.io.File referenceBuildinfo)  
      private static org.eclipse.aether.repository.RemoteRepository createDeploymentArtifactRepository​(java.lang.String id, java.lang.String url)  
      private org.eclipse.aether.repository.RemoteRepository createReferenceRepo()  
      private java.lang.String diffoscope​(org.apache.maven.artifact.Artifact a, java.io.File referenceDir)  
      private java.io.File downloadOrCreateReferenceBuildinfo​(boolean mono, java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts, java.io.File referenceDir)  
      void execute​(java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts)
      Execute after buildinfo has been generated for current build (eventually aggregated).
      private static java.lang.String findPrefix​(java.util.Properties reference, java.lang.String actualGroupId, java.lang.String actualFilename)  
      private java.lang.String getRepositoryFilename​(org.apache.maven.artifact.Artifact a)  
      private java.lang.String relative​(java.io.File file)  
      protected void skip​(org.apache.maven.project.MavenProject last)  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • referenceRepo

        @Parameter(property="reference.repo",
                   defaultValue="central")
        private java.lang.String referenceRepo
        Repository for reference build, containing either reference buildinfo file or reference artifacts.
        Format: id or url or id::url
        id
        The repository id
        url
        The url of the repository
        See Also:
        repository definition
      • aggregateOnly

        @Parameter(property="compare.aggregate.only",
                   defaultValue="false")
        private boolean aggregateOnly
        Compare aggregate only (ie wait for the last module) or also compare on each module.
        Since:
        3.2.0
      • artifactFactory

        @Component
        private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
      • repoSystem

        @Component
        private org.eclipse.aether.RepositorySystem repoSystem
        The entry point to Maven Artifact Resolver, i.e. the component doing all the work.
      • repoSession

        @Parameter(defaultValue="${repositorySystemSession}",
                   readonly=true)
        private org.eclipse.aether.RepositorySystemSession repoSession
        The current repository/network configuration of Maven.
      • remoteRepos

        @Parameter(defaultValue="${project.remoteProjectRepositories}",
                   readonly=true)
        private java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepos
        The project's remote repositories to use for the resolution.
      • fail

        @Parameter(property="compare.fail",
                   defaultValue="true")
        private boolean fail
        Fail the build if differences are found against reference build.
        Since:
        3.5.0
      • artifactRepositoryLayout

        @Component
        private org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout artifactRepositoryLayout
    • Constructor Detail

      • CompareMojo

        public CompareMojo()
    • Method Detail

      • execute

        public void execute​(java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts)
                     throws org.apache.maven.plugin.MojoExecutionException
        Description copied from class: AbstractBuildinfoMojo
        Execute after buildinfo has been generated for current build (eventually aggregated).
        Specified by:
        execute in class AbstractBuildinfoMojo
        Parameters:
        artifacts - a Map of artifacts added to the build info with their associated property key prefix (outputs.[#module.].#artifact)
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • skip

        protected void skip​(org.apache.maven.project.MavenProject last)
                     throws org.apache.maven.plugin.MojoExecutionException
        Overrides:
        skip in class AbstractBuildinfoMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • checkAgainstReference

        private void checkAgainstReference​(java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts,
                                           boolean mono)
                                    throws org.apache.maven.plugin.MojoExecutionException
        Check current build result with reference.
        Parameters:
        artifacts - a Map of artifacts added to the build info with their associated property key prefix (outputs.[#module.].#artifact)
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if anything goes wrong
      • downloadOrCreateReferenceBuildinfo

        private java.io.File downloadOrCreateReferenceBuildinfo​(boolean mono,
                                                                java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts,
                                                                java.io.File referenceDir)
                                                         throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • compareWithReference

        private void compareWithReference​(java.util.Map<org.apache.maven.artifact.Artifact,​java.lang.String> artifacts,
                                          java.io.File referenceBuildinfo)
                                   throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • checkArtifact

        private java.lang.String[] checkArtifact​(org.apache.maven.artifact.Artifact artifact,
                                                 java.lang.String prefix,
                                                 java.util.Properties reference,
                                                 java.util.Properties actual,
                                                 java.io.File referenceDir)
      • diffoscope

        private java.lang.String diffoscope​(org.apache.maven.artifact.Artifact a,
                                            java.io.File referenceDir)
      • getRepositoryFilename

        private java.lang.String getRepositoryFilename​(org.apache.maven.artifact.Artifact a)
      • relative

        private java.lang.String relative​(java.io.File file)
      • findPrefix

        private static java.lang.String findPrefix​(java.util.Properties reference,
                                                   java.lang.String actualGroupId,
                                                   java.lang.String actualFilename)
      • createReferenceRepo

        private org.eclipse.aether.repository.RemoteRepository createReferenceRepo()
                                                                            throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • createDeploymentArtifactRepository

        private static org.eclipse.aether.repository.RemoteRepository createDeploymentArtifactRepository​(java.lang.String id,
                                                                                                         java.lang.String url)