Interface IClasspathContainer
CPE_CONTAINER
. Typically, a classpath container can
be used to describe a complex library composed of multiple JARs or projects, considering also
that containers can map to different set of entries on each project, in other words, several
projects can reference the same generic container path, but have each of them actually bound
to a different container object.
The set of entries associated with a classpath container may contain any of the following:
- library entries (
CPE_LIBRARY
) - project entries (
CPE_PROJECT
)
A library entry can reference other libraries through the Class-Path section of the JAR's MANIFEST.MF file. If the
container wants such referenced entries to be part of the classpath, the container must explicitly add them to the
array returned from getClasspathEntries()
.
Classpath container values are persisted locally to the workspace, but are not preserved from a
session to another. It is thus highly recommended to register a ClasspathContainerInitializer
for each referenced container (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
- Since:
- 2.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Kind for a container mapping to an application librarystatic final int
Kind for a container mapping to a default system library, implicitly contributed by the runtimestatic final int
Kind for a container mapping to a system library -
Method Summary
Modifier and TypeMethodDescriptionAnswers the set of classpath entries this container is mapping to.Answers a readable description of this containerint
getKind()
Answers the kind of this container.org.eclipse.core.runtime.IPath
getPath()
Answers the container path identifying this container.static String[]
Answer the IDs of all registered classpath containers (extensions at extension pointJavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID
).
-
Field Details
-
K_APPLICATION
static final int K_APPLICATIONKind for a container mapping to an application library- See Also:
-
K_SYSTEM
static final int K_SYSTEMKind for a container mapping to a system library- See Also:
-
K_DEFAULT_SYSTEM
static final int K_DEFAULT_SYSTEMKind for a container mapping to a default system library, implicitly contributed by the runtime- See Also:
-
-
Method Details
-
getClasspathEntries
IClasspathEntry[] getClasspathEntries()Answers the set of classpath entries this container is mapping to.The set of entries associated with a classpath container may contain any of the following:
- library entries (
CPE_LIBRARY
) - project entries (
CPE_PROJECT
)
A library entry can reference other libraries through the Class-Path section of the JAR's MANIFEST.MF file. If the container wants such referenced entries to be part of the classpath, the container must explicitly add them to the result.
This method is called by the Java model when it needs to resolve this classpath container entry into a list of library and project entries. The method is typically called exactly once for a given Java project, and the resulting list of entries cached internally by the Java model. This method must not be called by other clients.
There are a wide variety of conditions under which this method may be invoked. To ensure that the implementation does not interfere with correct functioning of the Java model, the implementation should use only the following Java model APIs:
JavaCore.newLibraryEntry(IPath, IPath, IPath, boolean)
and variantsJavaCore.newProjectEntry(IPath, boolean)
and variantsJavaCore.create(org.eclipse.core.resources.IWorkspaceRoot)
JavaCore.create(org.eclipse.core.resources.IProject)
JavaCore.getReferencedClasspathEntries(IClasspathEntry, IJavaProject)
withnull
as projectIJavaModel.getJavaProjects()
IJavaProject.getRawClasspath()
IJavaProject.readRawClasspath()
IJavaProject.getOutputLocation()
IJavaProject.readOutputLocation()
- Java element operations marked as "handle-only"
The effects of using other Java model APIs are unspecified.
- Returns:
- IClasspathEntry[] - the classpath entries this container represents
- See Also:
- library entries (
-
getDescription
String getDescription()Answers a readable description of this container- Returns:
- String - a string description of the container
-
getKind
int getKind()Answers the kind of this container. Can be either:K_APPLICATION
if this container maps to an application libraryK_SYSTEM
if this container maps to a system libraryK_DEFAULT_SYSTEM
if this container maps to a default system library (library implicitly contributed by the runtime).
- Returns:
- the kind of this container
-
getPath
org.eclipse.core.runtime.IPath getPath()Answers the container path identifying this container. A container path is formed by a first ID segment followed with extra segments, which can be used as additional hints for resolving to this container.The container ID is also used to identify a
ClasspathContainerInitializer
registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer", which can be invoked if needing to resolve the container before it is explicitly set.- Returns:
- IPath - the container path that is associated with this container
-
getRegisteredContainerIds
Answer the IDs of all registered classpath containers (extensions at extension pointJavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID
).- Returns:
- array of strings as extracted from the "id" attribute from all registered classpath containers.
- Since:
- 3.32
-