Class MavenArchiver


  • public class MavenArchiver
    extends java.lang.Object

    MavenArchiver class.

    Version:
    $Id: $Id
    Author:
    Emmanuel Venisse, kama
    • Constructor Summary

      Constructors 
      Constructor Description
      MavenArchiver()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.util.Date configureReproducible​(java.lang.String outputTimestamp)
      Deprecated.
      void configureReproducibleBuild​(java.lang.String outputTimestamp)
      Configure Reproducible Builds archive creation if a timestamp is provided.
      void createArchive​(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, MavenArchiveConfiguration archiveConfiguration)
      createArchive.
      org.codehaus.plexus.archiver.jar.JarArchiver getArchiver()
      Getter for the field archiver.
      org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.project.MavenProject project, ManifestConfiguration config)
      getManifest.
      protected org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, ManifestConfiguration config, java.util.Map<java.lang.String,​java.lang.String> entries)
      getManifest.
      org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, MavenArchiveConfiguration config)
      getManifest.
      org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.project.MavenProject project, ManifestConfiguration config)
      Return a pre-configured manifest.
      static java.util.Optional<java.time.Instant> parseBuildOutputTimestamp​(java.lang.String outputTimestamp)
      Parse output timestamp configured for Reproducible Builds' archive entries.
      java.util.Date parseOutputTimestamp​(java.lang.String outputTimestamp)
      Deprecated.
      void setArchiver​(org.codehaus.plexus.archiver.jar.JarArchiver archiver)
      Setter for the field archiver.
      void setBuildJdkSpecDefaultEntry​(boolean buildJdkSpecDefaultEntry)
      Add "Build-Jdk-Spec" entry as part of default manifest entries (true by default).
      void setCreatedBy​(java.lang.String description, java.lang.String groupId, java.lang.String artifactId)
      Define a value for "Created By" entry.
      void setOutputFile​(java.io.File outputFile)
      setOutputFile.
      • Methods inherited from class java.lang.Object

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

      • SIMPLE_LAYOUT

        public static final java.lang.String SIMPLE_LAYOUT
        The simply layout.
        See Also:
        Constant Field Values
      • REPOSITORY_LAYOUT

        public static final java.lang.String REPOSITORY_LAYOUT
        Repository layout.
        See Also:
        Constant Field Values
      • SIMPLE_LAYOUT_NONUNIQUE

        public static final java.lang.String SIMPLE_LAYOUT_NONUNIQUE
        simple layout non unique.
        See Also:
        Constant Field Values
      • REPOSITORY_LAYOUT_NONUNIQUE

        public static final java.lang.String REPOSITORY_LAYOUT_NONUNIQUE
        Repository layout non unique.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MavenArchiver

        public MavenArchiver()
    • Method Detail

      • getManifest

        public org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.execution.MavenSession session,
                                                                     org.apache.maven.project.MavenProject project,
                                                                     MavenArchiveConfiguration config)
                                                              throws org.codehaus.plexus.archiver.jar.ManifestException,
                                                                     org.apache.maven.artifact.DependencyResolutionRequiredException

        getManifest.

        Parameters:
        session - the Maven Session
        project - the Maven Project
        config - the MavenArchiveConfiguration
        Returns:
        the Manifest
        Throws:
        org.codehaus.plexus.archiver.jar.ManifestException - in case of a failure
        org.apache.maven.artifact.DependencyResolutionRequiredException - resolution failure
      • getManifest

        public org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.project.MavenProject project,
                                                                     ManifestConfiguration config)
                                                              throws org.codehaus.plexus.archiver.jar.ManifestException,
                                                                     org.apache.maven.artifact.DependencyResolutionRequiredException
        Return a pre-configured manifest.
        Parameters:
        project - MavenProject
        config - ManifestConfiguration
        Returns:
        Manifest
        Throws:
        org.codehaus.plexus.archiver.jar.ManifestException - Manifest exception.
        org.apache.maven.artifact.DependencyResolutionRequiredException - Dependency resolution exception.
      • getManifest

        public org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.execution.MavenSession mavenSession,
                                                                     org.apache.maven.project.MavenProject project,
                                                                     ManifestConfiguration config)
                                                              throws org.codehaus.plexus.archiver.jar.ManifestException,
                                                                     org.apache.maven.artifact.DependencyResolutionRequiredException

        getManifest.

        Parameters:
        mavenSession - MavenSession
        project - MavenProject
        config - ManifestConfiguration
        Returns:
        Manifest
        Throws:
        org.codehaus.plexus.archiver.jar.ManifestException - the manifest exception
        org.apache.maven.artifact.DependencyResolutionRequiredException - the dependency resolution required exception
      • getManifest

        protected org.codehaus.plexus.archiver.jar.Manifest getManifest​(org.apache.maven.execution.MavenSession session,
                                                                        org.apache.maven.project.MavenProject project,
                                                                        ManifestConfiguration config,
                                                                        java.util.Map<java.lang.String,​java.lang.String> entries)
                                                                 throws org.codehaus.plexus.archiver.jar.ManifestException,
                                                                        org.apache.maven.artifact.DependencyResolutionRequiredException

        getManifest.

        Parameters:
        session - MavenSession
        project - MavenProject
        config - ManifestConfiguration
        entries - The entries.
        Returns:
        Manifest
        Throws:
        org.codehaus.plexus.archiver.jar.ManifestException - the manifest exception
        org.apache.maven.artifact.DependencyResolutionRequiredException - the dependency resolution required exception
      • getArchiver

        public org.codehaus.plexus.archiver.jar.JarArchiver getArchiver()

        Getter for the field archiver.

        Returns:
        JarArchiver
      • setArchiver

        public void setArchiver​(org.codehaus.plexus.archiver.jar.JarArchiver archiver)

        Setter for the field archiver.

        Parameters:
        archiver - JarArchiver
      • setOutputFile

        public void setOutputFile​(java.io.File outputFile)

        setOutputFile.

        Parameters:
        outputFile - Set output file.
      • createArchive

        public void createArchive​(org.apache.maven.execution.MavenSession session,
                                  org.apache.maven.project.MavenProject project,
                                  MavenArchiveConfiguration archiveConfiguration)
                           throws org.codehaus.plexus.archiver.jar.ManifestException,
                                  java.io.IOException,
                                  org.apache.maven.artifact.DependencyResolutionRequiredException

        createArchive.

        Parameters:
        session - MavenSession
        project - MavenProject
        archiveConfiguration - MavenArchiveConfiguration
        Throws:
        org.codehaus.plexus.archiver.ArchiverException - Archiver Exception.
        org.codehaus.plexus.archiver.jar.ManifestException - Manifest Exception.
        java.io.IOException - IO Exception.
        org.apache.maven.artifact.DependencyResolutionRequiredException - Dependency resolution exception.
      • setCreatedBy

        public void setCreatedBy​(java.lang.String description,
                                 java.lang.String groupId,
                                 java.lang.String artifactId)
        Define a value for "Created By" entry.
        Parameters:
        description - description of the plugin, like "Maven Source Plugin"
        groupId - groupId where to get version in pom.properties
        artifactId - artifactId where to get version in pom.properties
        Since:
        3.5.0
      • setBuildJdkSpecDefaultEntry

        public void setBuildJdkSpecDefaultEntry​(boolean buildJdkSpecDefaultEntry)
        Add "Build-Jdk-Spec" entry as part of default manifest entries (true by default). For plugins whose output is not impacted by JDK release (like maven-source-plugin), adding Jdk spec adds unnecessary requirement on JDK version used at build to get reproducible result.
        Parameters:
        buildJdkSpecDefaultEntry - the value for "Build-Jdk-Spec" entry
        Since:
        3.5.0
      • parseOutputTimestamp

        @Deprecated
        public java.util.Date parseOutputTimestamp​(java.lang.String outputTimestamp)
        Deprecated.
        Parse output timestamp configured for Reproducible Builds' archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH.
        Parameters:
        outputTimestamp - the value of ${project.build.outputTimestamp} (may be null)
        Returns:
        the parsed timestamp, may be null if null input or input contains only 1 character
        Throws:
        java.lang.IllegalArgumentException - if the outputTimestamp is neither ISO 8601 nor an integer, or it's not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z
        Since:
        3.5.0
      • configureReproducible

        @Deprecated
        public java.util.Date configureReproducible​(java.lang.String outputTimestamp)
        Deprecated.
        Configure Reproducible Builds archive creation if a timestamp is provided.
        Parameters:
        outputTimestamp - the value of ${project.build.outputTimestamp} (may be null)
        Returns:
        the parsed timestamp as Date
        Since:
        3.5.0
        See Also:
        parseOutputTimestamp(java.lang.String)
      • parseBuildOutputTimestamp

        public static java.util.Optional<java.time.Instant> parseBuildOutputTimestamp​(java.lang.String outputTimestamp)
        Parse output timestamp configured for Reproducible Builds' archive entries.

        Either as DateTimeFormatter.ISO_OFFSET_DATE_TIME or as a number representing seconds since the epoch (like SOURCE_DATE_EPOCH).

        Parameters:
        outputTimestamp - the value of ${project.build.outputTimestamp} (may be null)
        Returns:
        the parsed timestamp as an Optional<Instant>, empty if input is null or input contains only 1 character (not a number)
        Throws:
        java.lang.IllegalArgumentException - if the outputTimestamp is neither ISO 8601 nor an integer, or it's not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z
        Since:
        3.6.0
      • configureReproducibleBuild

        public void configureReproducibleBuild​(java.lang.String outputTimestamp)
        Configure Reproducible Builds archive creation if a timestamp is provided.
        Parameters:
        outputTimestamp - the value of project.build.outputTimestamp (may be null)
        Since:
        3.6.0
        See Also:
        parseBuildOutputTimestamp(String)