Package org.apache.sling.feature.io.archive

# Class ArchiveWriter

java.lang.Object
org.apache.sling.feature.io.archive.ArchiveWriter

public class ArchiveWriter extends Object
The feature archive writer can be used to create an archive based on a feature model. The archive contains the feature model file and all artifacts using a maven repository layout.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ARCHIVE_VERSION`
Current support version of the feature model archive.
`static final String`
`CONTENTS_HEADER`
The manifest header listing the features in this archive.
`static final String`
`VERSION_HEADER`
The manifest header marking an archive as a feature archive.

## Constructor Summary

Constructors
Constructor
Description
`ArchiveWriter()`

## Method Summary

Modifier and Type
Method
Description
`static JarOutputStream`
`write(OutputStream out, Manifest baseManifest, ArtifactProvider provider, Feature... features)`
Create a feature model archive.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### VERSION_HEADER

public static final String VERSION_HEADER
The manifest header marking an archive as a feature archive.

See Also:
  - Constant Field Values

### CONTENTS_HEADER

public static final String CONTENTS_HEADER
The manifest header listing the features in this archive.

See Also:
  - Constant Field Values

### ARCHIVE_VERSION

public static final int ARCHIVE_VERSION
Current support version of the feature model archive.

See Also:
  - Constant Field Values

## Constructor Details

### ArchiveWriter

public ArchiveWriter()

## Method Details

### write

public static JarOutputStream write(OutputStream out, Manifest baseManifest, ArtifactProvider provider, Feature... features) throws IOException
Create a feature model archive. The output stream will not be closed by this method. The caller must call `ZipOutputStream.close()` on the return output stream. The caller can add additional files through the return stream. However, the files should not be compressed (which is the default for the output stream). A feature model can be in different states: it might be a partial feature model, a complete feature model or an assembled feature model. This method takes the feature model as provided and only writes the listed bundles and artifacts of this feature model into the archive. In general, the best approach for sharing features is to archive `complete` features.

Parameters:
  `out` - The output stream to write to
  `baseManifest` - Optional base manifest used for creating the manifest.
  `provider` - The artifact provider
  `features` - The features model to archive
Returns:
  The jar output stream.
Throws:
  `IOException` - If anything goes wrong