Package org.apache.maven.archiver
Class MavenArchiver
- java.lang.Object
-
- org.apache.maven.archiver.MavenArchiver
-
public class MavenArchiver extends java.lang.ObjectMavenArchiver class.
- Version:
- $Id: $Id
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilearchiveFileprivate org.codehaus.plexus.archiver.jar.JarArchiverarchiverprivate static java.util.List<java.lang.String>ARTIFACT_EXPRESSION_PREFIXESprivate booleanbuildJdkSpecDefaultEntryprivate static java.lang.StringCREATED_BYprivate java.lang.StringcreatedByprivate static java.time.InstantDATE_MAXprivate static java.time.InstantDATE_MINstatic java.lang.StringREPOSITORY_LAYOUTRepository layout.static java.lang.StringREPOSITORY_LAYOUT_NONUNIQUERepository layout non unique.static java.lang.StringSIMPLE_LAYOUTThe simply layout.static java.lang.StringSIMPLE_LAYOUT_NONUNIQUEsimple layout non unique.
-
Constructor Summary
Constructors Constructor Description MavenArchiver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidaddCustomEntries(org.codehaus.plexus.archiver.jar.Manifest m, java.util.Map<java.lang.String,java.lang.String> entries, ManifestConfiguration config)private voidaddManifestAttribute(org.codehaus.plexus.archiver.jar.Manifest manifest, java.lang.String key, java.lang.String value)private voidaddManifestAttribute(org.codehaus.plexus.archiver.jar.Manifest manifest, java.util.Map<java.lang.String,java.lang.String> map, java.lang.String key, java.lang.String value)java.util.DateconfigureReproducible(java.lang.String outputTimestamp)Deprecated.UseconfigureReproducibleBuild(String)instead.voidconfigureReproducibleBuild(java.lang.String outputTimestamp)Configure Reproducible Builds archive creation if a timestamp is provided.voidcreateArchive(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, MavenArchiveConfiguration archiveConfiguration)createArchive.private java.lang.StringcreatedBy(java.lang.String description, java.lang.String groupId, java.lang.String artifactId)private org.apache.maven.artifact.ArtifactfindArtifactWithFile(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, java.io.File file)org.codehaus.plexus.archiver.jar.JarArchivergetArchiver()Getter for the fieldarchiver.private static java.lang.StringgetCreatedByVersion(java.lang.String groupId, java.lang.String artifactId)org.codehaus.plexus.archiver.jar.ManifestgetManifest(org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.project.MavenProject project, ManifestConfiguration config)getManifest.protected org.codehaus.plexus.archiver.jar.ManifestgetManifest(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.ManifestgetManifest(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, MavenArchiveConfiguration config)getManifest.org.codehaus.plexus.archiver.jar.ManifestgetManifest(org.apache.maven.project.MavenProject project, ManifestConfiguration config)Return a pre-configured manifest.private voidhandleBuildEnvironmentEntries(org.apache.maven.execution.MavenSession session, org.codehaus.plexus.archiver.jar.Manifest m, java.util.Map<java.lang.String,java.lang.String> entries)private voidhandleDefaultEntries(org.codehaus.plexus.archiver.jar.Manifest m, java.util.Map<java.lang.String,java.lang.String> entries)private voidhandleExtensions(org.apache.maven.project.MavenProject project, java.util.Map<java.lang.String,java.lang.String> entries, org.codehaus.plexus.archiver.jar.Manifest m)private voidhandleExtraExpression(org.apache.maven.artifact.Artifact artifact, java.util.List<org.codehaus.plexus.interpolation.ValueSource> valueSources)private voidhandleImplementationEntries(org.apache.maven.project.MavenProject project, java.util.Map<java.lang.String,java.lang.String> entries, org.codehaus.plexus.archiver.jar.Manifest m)private voidhandleSpecificationEntries(org.apache.maven.project.MavenProject project, java.util.Map<java.lang.String,java.lang.String> entries, org.codehaus.plexus.archiver.jar.Manifest m)private static booleanisNumeric(java.lang.String str)(package private) static booleanisValidModuleName(java.lang.String name)private static java.util.PropertiesloadOptionalProperties(java.io.InputStream inputStream)static java.util.Optional<java.time.Instant>parseBuildOutputTimestamp(java.lang.String outputTimestamp)Parse output timestamp configured for Reproducible Builds' archive entries.java.util.DateparseOutputTimestamp(java.lang.String outputTimestamp)Deprecated.UseparseBuildOutputTimestamp(String)instead.voidsetArchiver(org.codehaus.plexus.archiver.jar.JarArchiver archiver)Setter for the fieldarchiver.voidsetBuildJdkSpecDefaultEntry(boolean buildJdkSpecDefaultEntry)Add "Build-Jdk-Spec" entry as part of default manifest entries (true by default).voidsetCreatedBy(java.lang.String description, java.lang.String groupId, java.lang.String artifactId)Define a value for "Created By" entry.voidsetOutputFile(java.io.File outputFile)setOutputFile.
-
-
-
Field Detail
-
CREATED_BY
private static final java.lang.String CREATED_BY
- See Also:
- Constant Field Values
-
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
-
DATE_MIN
private static final java.time.Instant DATE_MIN
-
DATE_MAX
private static final java.time.Instant DATE_MAX
-
ARTIFACT_EXPRESSION_PREFIXES
private static final java.util.List<java.lang.String> ARTIFACT_EXPRESSION_PREFIXES
-
archiver
private org.codehaus.plexus.archiver.jar.JarArchiver archiver
-
archiveFile
private java.io.File archiveFile
-
createdBy
private java.lang.String createdBy
-
buildJdkSpecDefaultEntry
private boolean buildJdkSpecDefaultEntry
-
-
Method Detail
-
isValidModuleName
static boolean isValidModuleName(java.lang.String name)
-
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.DependencyResolutionRequiredExceptiongetManifest.
- Parameters:
session- the Maven Sessionproject- the Maven Projectconfig- the MavenArchiveConfiguration- Returns:
- the
Manifest - Throws:
org.codehaus.plexus.archiver.jar.ManifestException- in case of a failureorg.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.DependencyResolutionRequiredExceptionReturn a pre-configured manifest.- Parameters:
project-MavenProjectconfig-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.DependencyResolutionRequiredExceptiongetManifest.
- Parameters:
mavenSession-MavenSessionproject-MavenProjectconfig-ManifestConfiguration- Returns:
Manifest- Throws:
org.codehaus.plexus.archiver.jar.ManifestException- the manifest exceptionorg.apache.maven.artifact.DependencyResolutionRequiredException- the dependency resolution required exception
-
addManifestAttribute
private void addManifestAttribute(org.codehaus.plexus.archiver.jar.Manifest manifest, java.util.Map<java.lang.String,java.lang.String> map, java.lang.String key, java.lang.String value) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
addManifestAttribute
private void addManifestAttribute(org.codehaus.plexus.archiver.jar.Manifest manifest, java.lang.String key, java.lang.String value) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
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.DependencyResolutionRequiredExceptiongetManifest.
- Parameters:
session-MavenSessionproject-MavenProjectconfig-ManifestConfigurationentries- The entries.- Returns:
Manifest- Throws:
org.codehaus.plexus.archiver.jar.ManifestException- the manifest exceptionorg.apache.maven.artifact.DependencyResolutionRequiredException- the dependency resolution required exception
-
handleExtraExpression
private void handleExtraExpression(org.apache.maven.artifact.Artifact artifact, java.util.List<org.codehaus.plexus.interpolation.ValueSource> valueSources)
-
handleExtensions
private void handleExtensions(org.apache.maven.project.MavenProject project, java.util.Map<java.lang.String,java.lang.String> entries, org.codehaus.plexus.archiver.jar.Manifest m) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
handleImplementationEntries
private void handleImplementationEntries(org.apache.maven.project.MavenProject project, java.util.Map<java.lang.String,java.lang.String> entries, org.codehaus.plexus.archiver.jar.Manifest m) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
handleSpecificationEntries
private void handleSpecificationEntries(org.apache.maven.project.MavenProject project, java.util.Map<java.lang.String,java.lang.String> entries, org.codehaus.plexus.archiver.jar.Manifest m) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
addCustomEntries
private void addCustomEntries(org.codehaus.plexus.archiver.jar.Manifest m, java.util.Map<java.lang.String,java.lang.String> entries, ManifestConfiguration config) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
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.DependencyResolutionRequiredExceptioncreateArchive.
- Parameters:
session-MavenSessionproject-MavenProjectarchiveConfiguration-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.
-
handleDefaultEntries
private void handleDefaultEntries(org.codehaus.plexus.archiver.jar.Manifest m, java.util.Map<java.lang.String,java.lang.String> entries) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
handleBuildEnvironmentEntries
private void handleBuildEnvironmentEntries(org.apache.maven.execution.MavenSession session, org.codehaus.plexus.archiver.jar.Manifest m, java.util.Map<java.lang.String,java.lang.String> entries) throws org.codehaus.plexus.archiver.jar.ManifestException- Throws:
org.codehaus.plexus.archiver.jar.ManifestException
-
findArtifactWithFile
private org.apache.maven.artifact.Artifact findArtifactWithFile(java.util.Set<org.apache.maven.artifact.Artifact> artifacts, java.io.File file)
-
getCreatedByVersion
private static java.lang.String getCreatedByVersion(java.lang.String groupId, java.lang.String artifactId)
-
loadOptionalProperties
private static java.util.Properties loadOptionalProperties(java.io.InputStream inputStream)
-
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.propertiesartifactId- artifactId where to get version in pom.properties- Since:
- 3.5.0
-
createdBy
private java.lang.String createdBy(java.lang.String description, java.lang.String groupId, java.lang.String artifactId)
-
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.UseparseBuildOutputTimestamp(String)instead.Parse output timestamp configured for Reproducible Builds' archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH.- Parameters:
outputTimestamp- the value of${project.build.outputTimestamp}(may benull)- Returns:
- the parsed timestamp, may be
nullifnullinput 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.UseconfigureReproducibleBuild(String)instead.Configure Reproducible Builds archive creation if a timestamp is provided.- Parameters:
outputTimestamp- the value of${project.build.outputTimestamp}(may benull)- 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_TIMEor as a number representing seconds since the epoch (like SOURCE_DATE_EPOCH).- Parameters:
outputTimestamp- the value of${project.build.outputTimestamp}(may benull)- Returns:
- the parsed timestamp as an
Optional<Instant>,emptyif input isnullor 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
-
isNumeric
private static boolean isNumeric(java.lang.String str)
-
configureReproducibleBuild
public void configureReproducibleBuild(java.lang.String outputTimestamp)
Configure Reproducible Builds archive creation if a timestamp is provided.- Parameters:
outputTimestamp- the value ofproject.build.outputTimestamp(may benull)- Since:
- 3.6.0
- See Also:
parseBuildOutputTimestamp(String)
-
-