Class JarPackageData
Clients may subclass.
- Since:
- 2.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Tells whether files can be overwritten without warning.boolean
Tells whether class files and resources are exported.boolean
Tells whether directory entries are added to the jar.boolean
Answers if compilation units with errors are exported.boolean
Tells whether files created by the Java builder are exported.boolean
Tells whether java files and resources are exported.boolean
Tells whether all output folders for the enclosing projects of the exported elements.Creates and returns a jar builder capable of handling files and archives.createJarDescriptionReader
(InputStream inputStream) Creates and returns a JAR package data description reader for this JAR package data object.createJarDescriptionWriter
(OutputStream outputStream) Deprecated.createJarDescriptionWriter
(OutputStream outputStream, String encoding) Creates and returns a JAR package data description writer for this JAR package data object.createJarExportRunnable
(JarPackageData[] jarPackagesData, org.eclipse.swt.widgets.Shell parent) Creates and returns a JarExportRunnable for a list of JAR package data objects.createJarExportRunnable
(org.eclipse.swt.widgets.Shell parent) Creates and returns a JarExportRunnable.createJarWriter
(org.eclipse.swt.widgets.Shell parent) Deprecated.UsecreateJarWriter3(Shell)
insteadcreateJarWriter3
(org.eclipse.swt.widgets.Shell parent) Deprecated.usecreatePlainJarBuilder()
insteadCreates and returns a jar builder capable of handling files but not archives.boolean
Answers if compilation units with warnings are exported.org.eclipse.core.resources.IFile[]
findClassfilesFor
(org.eclipse.core.resources.IFile javaFile) Finds the class files for the given java file and returns them.org.eclipse.core.runtime.IPath
Gets the absolute location of the JAR file.Returns the JAR's comment.org.eclipse.core.resources.IFile
Gets the description file (as workspace resource).org.eclipse.core.runtime.IPath
Returns the location of file containing the description of a JAR.Object[]
Returns the elements which will be exported.Returns the jar builder which can be used to build the jar described by this package data.org.eclipse.core.runtime.IPath
Gets the location of the JAR file.Get the name of the launch configuration from which to retrieve classpath information.org.eclipse.core.resources.IFile
Gets the manifest file (as workspace resource).org.eclipse.core.runtime.IPath
Returns the location of a user-defined manifest file.Gets the manifest's main class.Gets the manifest provider for this JAR package.Gets the manifest version.Gets the packages which should be sealed.Gets the packages which should explicitly be unsealed.org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy[]
Returns the refactoring descriptors to export.org.eclipse.core.resources.IProject[]
Returns the projects for which refactoring information should be stored.boolean
Answers if a build should be performed before exporting files.boolean
Tells whether the JAR is compressed or not.boolean
Is the JAR package deprecation aware?boolean
Tells whether a description of this JAR package must be saved to a file by a JAR description writer during the export operation.boolean
Is the JAR export wizard only exporting refactorings causing structural changes?boolean
Answers whether the JAR itself is sealed.boolean
isMainClassValid
(org.eclipse.jface.operation.IRunnableContext context) Tells whether the specified manifest main class is valid.boolean
Tells whether a manifest is available.boolean
Tells whether the manifest file must be generated.boolean
Tells whether a previously generated manifest should be reused.boolean
Tells whether the manifest file must be saved to the specified file during the export operation.boolean
Is the JAR package refactoring aware?boolean
isValid()
Tells whether this JAR package data can be used to generate a valid JAR.boolean
Deprecated.will be removed in final 2.0boolean
Deprecated.will be removed in final 2.0void
setBuildIfNeeded
(boolean buildIfNeeded) Sets if a build should be performed before exporting files.void
setComment
(String comment) Sets the JAR's comment.void
setCompress
(boolean state) Set whether the JAR is compressed or not.void
setDeprecationAware
(boolean aware) Determines whether the jar package is deprecation aware.void
setDescriptionLocation
(org.eclipse.core.runtime.IPath descriptionLocation) Set the location of the JAR description file.void
setElements
(Object[] elements) Set the elements which will be exported.void
setExportClassFiles
(boolean state) Sets option to export class files and resources.void
setExportErrors
(boolean exportErrors) Sets if compilation units with errors are exported.void
setExportJavaFiles
(boolean state) Sets the option to export Java source and resources.void
setExportOutputFolders
(boolean state) Sets option to export all output folders for the enclosing projects of the exported elements.void
setExportStructuralOnly
(boolean structural) Determines whether the jar packager exports only refactorings causing structural changes.void
setExportWarnings
(boolean exportWarnings) Sets if compilation units with warnings are exported.void
setGenerateManifest
(boolean state) Set whether a manifest must be generated or not.void
setIncludeDirectoryEntries
(boolean includeDirectoryEntries) Sets the option to include directory entries into the jar.void
setJarBuilder
(IJarBuilder jarBuilder) Set the jar builder to use to build the jar.void
setJarLocation
(org.eclipse.core.runtime.IPath jarLocation) Sets the JAR file location.void
Set the name of the launch configuration form which to retrieve classpath information.void
setLogErrors
(boolean logErrors) Deprecated.will be removed in final 2.0void
setLogWarnings
(boolean logWarnings) Deprecated.will be removed in final 2.0void
setManifestLocation
(org.eclipse.core.runtime.IPath manifestLocation) Sets the location of a user-defined manifest file.void
setManifestMainClass
(IType manifestMainClass) Set the manifest's main class.void
setManifestProvider
(IManifestProvider manifestProvider) Sets the manifest provider.void
setManifestVersion
(String manifestVersion) Sets the manifest version.void
setOverwrite
(boolean state) Sets whether files can be overwritten without warning.void
setPackagesToSeal
(IPackageFragment[] packagesToSeal) Sets the packages which should be sealed.void
setPackagesToUnseal
(IPackageFragment[] packagesToUnseal) Set the packages which should explicitly be unsealed.void
setRefactoringAware
(boolean aware) Determines whether the jar package is refactoring aware.void
setRefactoringDescriptors
(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy[] descriptors) Sets the refactoring descriptors to export.void
setRefactoringProjects
(org.eclipse.core.resources.IProject[] projects) Sets the projects for which refactoring information should be stored.void
setReuseManifest
(boolean state) Sets whether a previously generated manifest should be reused.void
setSaveDescription
(boolean state) Set whether a description of this JAR package must be saved to a file by a JAR description writer during the export operation.void
setSaveManifest
(boolean state) Sets whether the manifest file must be saved during export operation or not.void
setSealJar
(boolean sealJar) Sets whether the JAR itself is sealed.void
setUsesManifest
(boolean state) Sets whether a manifest must be included in the JAR.void
setUseSourceFolderHierarchy
(boolean state) Set the option to export the source folder hierarchy.boolean
Answers whether a manifest must be included in the JAR.boolean
Tells whether the source folder hierarchy is used.
-
Constructor Details
-
JarPackageData
public JarPackageData()Creates a new Jar Package Data structure
-
-
Method Details
-
isCompressed
public boolean isCompressed()Tells whether the JAR is compressed or not.- Returns:
true
if the JAR is compressed
-
setCompress
public void setCompress(boolean state) Set whether the JAR is compressed or not.- Parameters:
state
- a boolean indicating the new state
-
allowOverwrite
public boolean allowOverwrite()Tells whether files can be overwritten without warning.- Returns:
true
if files can be overwritten without warning
-
setOverwrite
public void setOverwrite(boolean state) Sets whether files can be overwritten without warning.- Parameters:
state
- a boolean indicating the new state
-
areClassFilesExported
public boolean areClassFilesExported()Tells whether class files and resources are exported.- Returns:
true
if class files and resources are exported
-
setExportClassFiles
public void setExportClassFiles(boolean state) Sets option to export class files and resources.- Parameters:
state
- a boolean indicating the new state
-
areOutputFoldersExported
public boolean areOutputFoldersExported()Tells whether all output folders for the enclosing projects of the exported elements.- Returns:
true
if output folder are exported- Since:
- 3.0
-
setExportOutputFolders
public void setExportOutputFolders(boolean state) Sets option to export all output folders for the enclosing projects of the exported elements.- Parameters:
state
- a boolean indicating the new state- Since:
- 3.0
-
areGeneratedFilesExported
public boolean areGeneratedFilesExported()Tells whether files created by the Java builder are exported.- Returns:
true
if output folder are exported- Since:
- 3.0
-
areJavaFilesExported
public boolean areJavaFilesExported()Tells whether java files and resources are exported.- Returns:
true
if java files and resources are exported
-
setExportJavaFiles
public void setExportJavaFiles(boolean state) Sets the option to export Java source and resources.- Parameters:
state
- the new state
-
useSourceFolderHierarchy
public boolean useSourceFolderHierarchy()Tells whether the source folder hierarchy is used.Using the source folder hierarchy only makes sense if java files are but class files aren't exported.
- Returns:
true
if source folder hierarchy is used
-
setUseSourceFolderHierarchy
public void setUseSourceFolderHierarchy(boolean state) Set the option to export the source folder hierarchy.- Parameters:
state
- the new state
-
getAbsoluteJarLocation
public org.eclipse.core.runtime.IPath getAbsoluteJarLocation()Gets the absolute location of the JAR file. This path is normally external to the workspace.- Returns:
- the absolute path representing the location of the JAR file
- Since:
- 3.0
-
getJarLocation
public org.eclipse.core.runtime.IPath getJarLocation()Gets the location of the JAR file. This path is normally external to the workspace.- Returns:
- the path representing the location of the JAR file
-
setJarLocation
public void setJarLocation(org.eclipse.core.runtime.IPath jarLocation) Sets the JAR file location.- Parameters:
jarLocation
- a path denoting the location of the JAR file
-
isManifestGenerated
public boolean isManifestGenerated()Tells whether the manifest file must be generated.- Returns:
true
if the manifest has to be generated
-
setGenerateManifest
public void setGenerateManifest(boolean state) Set whether a manifest must be generated or not.- Parameters:
state
- the new state
-
isManifestSaved
public boolean isManifestSaved()Tells whether the manifest file must be saved to the specified file during the export operation.- Returns:
true
if the manifest must be saved- See Also:
-
setSaveManifest
public void setSaveManifest(boolean state) Sets whether the manifest file must be saved during export operation or not.- Parameters:
state
- the new state- See Also:
-
isManifestReused
public boolean isManifestReused()Tells whether a previously generated manifest should be reused.- Returns:
true
if the generated manifest will be reused when regenerating this JAR,false
if the manifest has to be regenerated
-
setReuseManifest
public void setReuseManifest(boolean state) Sets whether a previously generated manifest should be reused.- Parameters:
state
- the new state
-
getManifestLocation
public org.eclipse.core.runtime.IPath getManifestLocation()Returns the location of a user-defined manifest file.- Returns:
- the path of the user-defined manifest file location,
or
null
if none is specified
-
setManifestLocation
public void setManifestLocation(org.eclipse.core.runtime.IPath manifestLocation) Sets the location of a user-defined manifest file.- Parameters:
manifestLocation
- the path of the user-define manifest location
-
getManifestFile
public org.eclipse.core.resources.IFile getManifestFile()Gets the manifest file (as workspace resource).- Returns:
- a file which points to the manifest
-
getManifestVersion
Gets the manifest version.- Returns:
- a string containing the manifest version
-
setManifestVersion
Sets the manifest version.- Parameters:
manifestVersion
- the string which contains the manifest version
-
usesManifest
public boolean usesManifest()Answers whether a manifest must be included in the JAR.- Returns:
true
if a manifest has to be included
-
setUsesManifest
public void setUsesManifest(boolean state) Sets whether a manifest must be included in the JAR.- Parameters:
state
- the new state
-
getManifestProvider
Gets the manifest provider for this JAR package.- Returns:
- the IManifestProvider
-
setManifestProvider
Sets the manifest provider.- Parameters:
manifestProvider
- the ManifestProvider to set
-
isJarSealed
public boolean isJarSealed()Answers whether the JAR itself is sealed. The manifest will contain a "Sealed: true" statement.This option should only be considered when the manifest file is generated.
- Returns:
true
if the JAR must be sealed- See Also:
-
setSealJar
public void setSealJar(boolean sealJar) Sets whether the JAR itself is sealed. The manifest will contain the following entry: Sealed: trueThis option should only be considered when the manifest file is generated.
- Parameters:
sealJar
-true
if the JAR must be sealed- See Also:
-
setPackagesToSeal
Sets the packages which should be sealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: trueThis should only be used if the JAR itself is not sealed.
- Parameters:
packagesToSeal
- an array ofIPackageFragment
to seal
-
getPackagesToSeal
Gets the packages which should be sealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: trueThis should only be used if the JAR itself is not sealed.
- Returns:
- an array of
IPackageFragment
-
getPackagesToUnseal
Gets the packages which should explicitly be unsealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: falseThis should only be used if the JAR itself is sealed.
- Returns:
- an array of
IPackageFragment
-
setPackagesToUnseal
Set the packages which should explicitly be unsealed. The following entry will be added to the manifest file for each package: Name: <name of the package> Sealed: falseThis should only be used if the JAR itself is sealed.
- Parameters:
packagesToUnseal
- an array ofIPackageFragment
-
isDescriptionSaved
public boolean isDescriptionSaved()Tells whether a description of this JAR package must be saved to a file by a JAR description writer during the export operation.The JAR writer defines the format of the file.
- Returns:
true
if this JAR package will be saved- See Also:
-
setSaveDescription
public void setSaveDescription(boolean state) Set whether a description of this JAR package must be saved to a file by a JAR description writer during the export operation.The format is defined by the client who implements the reader/writer pair.
- Parameters:
state
- a boolean containing the new state- See Also:
-
getDescriptionLocation
public org.eclipse.core.runtime.IPath getDescriptionLocation()Returns the location of file containing the description of a JAR. This location is inside the workspace.- Returns:
- the path of the description file location,
or
null
if none is specified
-
setDescriptionLocation
public void setDescriptionLocation(org.eclipse.core.runtime.IPath descriptionLocation) Set the location of the JAR description file.- Parameters:
descriptionLocation
- the path of location
-
getDescriptionFile
public org.eclipse.core.resources.IFile getDescriptionFile()Gets the description file (as workspace resource).- Returns:
- a file which points to the description
-
getManifestMainClass
Gets the manifest's main class.- Returns:
- the type which contains the main class or,
null
if none is specified
-
setManifestMainClass
Set the manifest's main class.- Parameters:
manifestMainClass
- the type with the main class for the manifest file
-
getElements
Returns the elements which will be exported. These elements are leaf objects e.g.IFile
and not containers.- Returns:
- an array of leaf objects
-
setElements
Set the elements which will be exported. These elements are leaf objects e.g.IFile
. and not containers.- Parameters:
elements
- an array with leaf objects
-
getComment
Returns the JAR's comment.- Returns:
- the comment string or
null
if the JAR does not contain a comment
-
setComment
Sets the JAR's comment.- Parameters:
comment
- a string ornull
if the JAR does not contain a comment
-
logErrors
Deprecated.will be removed in final 2.0Tell whether errors are logged.The export operation decides where and how the errors are logged.
- Returns:
true
if errors are logged
-
setLogErrors
Deprecated.will be removed in final 2.0Sets whether errors are logged.The export operation decides where and how the errors are logged.
- Parameters:
logErrors
-true
if errors are logged
-
logWarnings
Deprecated.will be removed in final 2.0Tells whether warnings are logged or not.The export operation decides where and how the warnings are logged.
- Returns:
true
if warnings are logged
-
setLogWarnings
Deprecated.will be removed in final 2.0Sets if warnings are logged.The export operation decides where and how the warnings are logged.
- Parameters:
logWarnings
-true
if warnings are logged
-
areErrorsExported
public boolean areErrorsExported()Answers if compilation units with errors are exported.- Returns:
true
if CUs with errors should be exported
-
setExportErrors
public void setExportErrors(boolean exportErrors) Sets if compilation units with errors are exported.- Parameters:
exportErrors
-true
if CUs with errors should be exported
-
exportWarnings
public boolean exportWarnings()Answers if compilation units with warnings are exported.- Returns:
true
if CUs with warnings should be exported
-
setExportWarnings
public void setExportWarnings(boolean exportWarnings) Sets if compilation units with warnings are exported.- Parameters:
exportWarnings
-true
if CUs with warnings should be exported
-
isBuildingIfNeeded
public boolean isBuildingIfNeeded()Answers if a build should be performed before exporting files. This flag is only considered if auto-build is off.- Returns:
- a boolean telling if a build should be performed
-
setBuildIfNeeded
public void setBuildIfNeeded(boolean buildIfNeeded) Sets if a build should be performed before exporting files. This flag is only considered if auto-build is off.- Parameters:
buildIfNeeded
- a boolean telling if a build should be performed
-
findClassfilesFor
public org.eclipse.core.resources.IFile[] findClassfilesFor(org.eclipse.core.resources.IFile javaFile) throws org.eclipse.core.runtime.CoreException Finds the class files for the given java file and returns them.This is a hook for subclasses which want to implement a different strategy for finding the class files. The default strategy is to query the class files for the source file name attribute. If this attribute is missing then all class files in the corresponding output folder are exported.
A CoreException can be thrown if an error occurs during this operation. The
CoreException
will not stop the export process but adds the status object to the status of the export runnable.- Parameters:
javaFile
- a .java file- Returns:
- an array with class files or
null
to used the default strategy - Throws:
org.eclipse.core.runtime.CoreException
- if find failed, e.g. I/O error or resource out of sync- See Also:
-
createJarWriter
@Deprecated public JarWriter2 createJarWriter(org.eclipse.swt.widgets.Shell parent) throws org.eclipse.core.runtime.CoreException Deprecated.UsecreateJarWriter3(Shell)
insteadCreates and returns a JarWriter for this JAR package.- Parameters:
parent
- the shell used to display question dialogs, ornull
if "false/no/cancel" is the answer and no dialog should be shown- Returns:
- a JarWriter2
- Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected exception happens- See Also:
-
createJarWriter3
@Deprecated public JarWriter3 createJarWriter3(org.eclipse.swt.widgets.Shell parent) throws org.eclipse.core.runtime.CoreException Deprecated.usecreatePlainJarBuilder()
insteadCreates and returns a JarWriter for this JAR package.- Parameters:
parent
- the shell used to display question dialogs, ornull
if "false/no/cancel" is the answer and no dialog should be shown- Returns:
- a JarWriter3
- Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected exception happens- Since:
- 3.2
- See Also:
-
createPlainJarBuilder
Creates and returns a jar builder capable of handling files but not archives.- Returns:
- a new instance of a plain jar builder
- Since:
- 3.4
-
createFatJarBuilder
Creates and returns a jar builder capable of handling files and archives.- Returns:
- a new instance of a fat jar builder
- Since:
- 3.4
-
createJarExportRunnable
Creates and returns a JarExportRunnable.- Parameters:
parent
- the parent for the dialog, ornull
if no questions should be asked and no checks for unsaved files should be made.- Returns:
- a JarExportRunnable
-
createJarExportRunnable
public IJarExportRunnable createJarExportRunnable(JarPackageData[] jarPackagesData, org.eclipse.swt.widgets.Shell parent) Creates and returns a JarExportRunnable for a list of JAR package data objects.- Parameters:
jarPackagesData
- an array with JAR package data objectsparent
- the parent for the dialog, ornull
if no dialog should be presented- Returns:
- the
IJarExportRunnable
-
createJarDescriptionWriter
Deprecated.UsecreateJarDescriptionWriter(OutputStream, String)
insteadCreates and returns a JAR package data description writer for this JAR package data object.It is the client's responsibility to close this writer.
- Parameters:
outputStream
- the output stream to write to- Returns:
- a JarWriter
-
createJarDescriptionWriter
Creates and returns a JAR package data description writer for this JAR package data object.It is the client's responsibility to close this writer.
- Parameters:
outputStream
- the output stream to write toencoding
- the encoding to use- Returns:
- a JarWriter
- Since:
- 3.3
-
createJarDescriptionReader
Creates and returns a JAR package data description reader for this JAR package data object.It is the client's responsibility to close this reader.
- Parameters:
inputStream
- the input stream to read from- Returns:
- a JarWriter
-
isValid
public boolean isValid()Tells whether this JAR package data can be used to generate a valid JAR.- Returns:
true
if the JAR Package info is valid
-
isManifestAccessible
public boolean isManifestAccessible()Tells whether a manifest is available.- Returns:
true
if the manifest is generated or the provided one is accessible
-
isMainClassValid
public boolean isMainClassValid(org.eclipse.jface.operation.IRunnableContext context) Tells whether the specified manifest main class is valid.- Parameters:
context
- theIRunnableContext
- Returns:
true
if a main class is specified and valid
-
areDirectoryEntriesIncluded
public boolean areDirectoryEntriesIncluded()Tells whether directory entries are added to the jar.- Returns:
true
if directory entries are to be included- Since:
- 3.1
-
setIncludeDirectoryEntries
public void setIncludeDirectoryEntries(boolean includeDirectoryEntries) Sets the option to include directory entries into the jar.- Parameters:
includeDirectoryEntries
-true
to include directory entriesfalse
otherwise- Since:
- 3.1
-
getRefactoringProjects
public org.eclipse.core.resources.IProject[] getRefactoringProjects()Returns the projects for which refactoring information should be stored.This information is used for JAR export.
- Returns:
- the projects for which refactoring information should be stored, or an empty array
- Since:
- 3.2
-
isExportStructuralOnly
public boolean isExportStructuralOnly()Is the JAR export wizard only exporting refactorings causing structural changes?This information is used for JAR export.
- Returns:
true
if exporting structural changes only,false
otherwise- Since:
- 3.2
-
isRefactoringAware
public boolean isRefactoringAware()Is the JAR package refactoring aware?This information is used both in JAR export and import
- Returns:
true
if it is refactoring aware,false
otherwise- Since:
- 3.2
-
isDeprecationAware
public boolean isDeprecationAware()Is the JAR package deprecation aware?This information is used in JAR export.
- Returns:
true
if it is deprecation aware,false
otherwise- Since:
- 3.2
-
setRefactoringProjects
public void setRefactoringProjects(org.eclipse.core.resources.IProject[] projects) Sets the projects for which refactoring information should be stored.This information is used for JAR export.
- Parameters:
projects
- the projects for which refactoring information should be stored- Since:
- 3.2
-
setRefactoringAware
public void setRefactoringAware(boolean aware) Determines whether the jar package is refactoring aware.This information is used both in JAR export and import.
- Parameters:
aware
-true
if it is refactoring aware,false
otherwise- Since:
- 3.2
-
setDeprecationAware
public void setDeprecationAware(boolean aware) Determines whether the jar package is deprecation aware.This information is used in JAR export.
- Parameters:
aware
-true
if it is deprecation aware,false
otherwise- Since:
- 3.2
-
setRefactoringDescriptors
public void setRefactoringDescriptors(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy[] descriptors) Sets the refactoring descriptors to export.This information is used in JAR export.
- Parameters:
descriptors
- the refactoring descriptors- Since:
- 3.2
-
getRefactoringDescriptors
public org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy[] getRefactoringDescriptors()Returns the refactoring descriptors to export.This information is used in JAR export.
- Returns:
- the refactoring descriptors to export
- Since:
- 3.2
-
setExportStructuralOnly
public void setExportStructuralOnly(boolean structural) Determines whether the jar packager exports only refactorings causing structural changes.This information is used for JAR export.
- Parameters:
structural
-true
if it exports only refactorings causing structural changes,false
otherwise- Since:
- 3.2
-
getJarBuilder
Returns the jar builder which can be used to build the jar described by this package data.- Returns:
- the builder to use
- Since:
- 3.4
-
setJarBuilder
Set the jar builder to use to build the jar.- Parameters:
jarBuilder
- the builder to use- Since:
- 3.4
-
getLaunchConfigurationName
Get the name of the launch configuration from which to retrieve classpath information.- Returns:
- the name of the launch configuration
- Since:
- 3.4
-
setLaunchConfigurationName
Set the name of the launch configuration form which to retrieve classpath information.- Parameters:
name
- name of the launch configuration- Since:
- 3.4
-
createJarDescriptionWriter(OutputStream, String)
instead