Package org.eclipse.jdt.ui.jarpackager

## Interface IJarBuilder

    public interface IJarBuilder

A JAR builder can be used to add elements to a JAR file which is about to be build.

The protocol defined by this interface is:

- open is called
- addFile and addJar is called multiple times
- close is called

It is guaranteed that addFile and addJar is only called after open is called and before close is called. Other methods may be called any time.

Implementors must be prepared that an instance if the implementation is reused multiple times.

In order to provide backward compatibility for clients of `IJarBuilder`, extension interfaces are used to provide a means of evolution. The following extension interfaces exist:

- `IJarBuilderExtension` since version 3.5 introducing the following functions:
  - Write a file to the JAR to build

Since:
  3.4
See Also:
  `JarPackageData`

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `close()` Called when building of the JAR finished.
`String` `getId()` Returns the unique id of this builder
`IManifestProvider` `getManifestProvider()` Returns the manifest provider to build the manifest
`void` `open​(JarPackageData jarPackage, Shell shell, MultiStatus status)` Called when building of the JAR starts
`void` `writeArchive​(ZipFile archive, IProgressMonitor monitor)` Add the given archive to the archive which is about to be build
`void` `writeFile​(IFile resource, IPath destinationPath)` Add the given resource to the archive at the given path

### Method Detail

#### getId

    String getId()

Returns the unique id of this builder

Returns:
  the unique id of this builder

#### getManifestProvider

    IManifestProvider getManifestProvider()

Returns the manifest provider to build the manifest

Returns:
  the manifest provider to build the manifest

#### open

    void open​(JarPackageData jarPackage,
              Shell shell,
              MultiStatus status)
       throws CoreException

Called when building of the JAR starts

Parameters:
  `jarPackage` - the package to build
  `shell` - shell to show dialogs, null if no dialog must be shown
  `status` - a status to use to report status to the user
Throws:
  `CoreException` - thrown when the JAR could not be opened

#### writeFile

    void writeFile​(IFile resource,
                   IPath destinationPath)
            throws CoreException

Add the given resource to the archive at the given path

Parameters:
  `resource` - the file to be written
  `destinationPath` - the path for the file inside the archive
Throws:
  `CoreException` - thrown when the file could not be written

#### writeArchive

    void writeArchive​(ZipFile archive,
                      IProgressMonitor monitor)

Add the given archive to the archive which is about to be build

Parameters:
  `archive` - the archive to add
  `monitor` - a monitor to report progress to

#### close

    void close()
        throws CoreException

Called when building of the JAR finished.

Throws:
  `CoreException` - thrown when the JAR could not be closed