Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace APIs using equinox-resolve's BundleDescription #1164

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ui/org.eclipse.pde.core/.settings/.api_filters
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.pde.core" version="2">
<resource path="src/org/eclipse/pde/core/IClasspathContributor.java" type="org.eclipse.pde.core.IClasspathContributor">
<filter id="404000815">
<message_arguments>
<message_argument value="org.eclipse.pde.core.IClasspathContributor"/>
<message_argument value="getEntriesForDependency(IProject, Resource)"/>
</message_arguments>
</filter>
<filter id="404000815">
<message_arguments>
<message_argument value="org.eclipse.pde.core.IClasspathContributor"/>
<message_argument value="getInitialEntries(IProject)"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/pde/internal/core/project/BundleProjectService.java" type="org.eclipse.pde.internal.core.project.BundleProjectService">
<filter comment="Platform Team allows use of bundle importers for PDE import from source repository" id="640712815">
<message_arguments>
Expand Down
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %name
Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true
Bundle-Version: 3.18.0.qualifier
Bundle-Version: 3.19.0.qualifier
Bundle-Activator: org.eclipse.pde.internal.core.PDECore
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.plugin.PluginRegistry;
Expand All @@ -40,6 +41,8 @@
* @since 3.9
*/
public interface IClasspathContributor {
// TODO: The cleaner way would be to create a completely new interface and
// deprecate this one. But how to name it?

/**
* Get any additional classpath entries to add to a project when its
Expand All @@ -53,8 +56,21 @@ public interface IClasspathContributor {
* classpath computed
* @return additional classpath entries to add to the project, possibly
* empty, must not be <code>null</code>
* @since 3.19
*/
List<IClasspathEntry> getInitialEntries(BundleDescription project);
default List<IClasspathEntry> getInitialEntries(IProject project) {
BundleDescription description = PluginRegistry.findModel(project).getBundleDescription();
return getInitialEntries(description);
}

/**
* @deprecated Instead implement {@link #getInitialEntries(IProject)}
*/
@Deprecated(forRemoval = true, since = "4.19")
default List<IClasspathEntry> getInitialEntries(BundleDescription project) {
throw new UnsupportedOperationException(
"This method is deprecated. Implement and call getInitialEntries(IProject) instead");
}

/**
* Get any additional classpath entries to add to a project when a new bundle
Expand All @@ -66,6 +82,22 @@ public interface IClasspathContributor {
* @param project the bundle descriptor for the plug-in project having its classpath computed
* @param addedDependency the bundle descriptor for the bundle being added to the classpath as a dependency
* @return additional classpath entries to add to the project, possibly empty, must not be <code>null</code>
* @since 3.19
*/
List<IClasspathEntry> getEntriesForDependency(BundleDescription project, BundleDescription addedDependency);
default List<IClasspathEntry> getEntriesForDependency(IProject project, Resource addedDependency) {
BundleDescription description = PluginRegistry.findModel(project).getBundleDescription();
return getEntriesForDependency(description, (BundleDescription) addedDependency);
}

/**
* @deprecated Instead implement
* {@link #getEntriesForDependency(IProject, Resource)}
*/
@Deprecated(forRemoval = true, since = "4.19")
default List<IClasspathEntry> getEntriesForDependency(BundleDescription project,
BundleDescription addedDependency) {
throw new UnsupportedOperationException(
"This method is deprecated. Implement and call getEntriesForDependency(IProject, Resource) instead");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.net.URL;

import org.eclipse.core.runtime.URIUtil;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.IModelChangeProvider;
import org.eclipse.pde.core.build.IBuildModel;
import org.osgi.resource.Resource;

/**
* This type of model is created by parsing the manifest file.
Expand Down Expand Up @@ -63,7 +63,7 @@ public interface IPluginModelBase extends ISharedExtensionsModel, IModelChangePr
* @deprecated This method has always returned <code>null</code>.
* Since 3.7, use {@link PluginRegistry#createBuildModel(IPluginModelBase)} instead.
*/
@Deprecated
@Deprecated(forRemoval = true, since = "4.19")
IBuildModel getBuildModel();

/**
Expand Down Expand Up @@ -128,20 +128,35 @@ public interface IPluginModelBase extends ISharedExtensionsModel, IModelChangePr
* an encoding tool such as {@link URIUtil}. Deprecated in
* 4.3.
*/
@Deprecated
@Deprecated(forRemoval = true, since = "4.19")
URL getNLLookupLocation();

/**
* Returns the bundle description of the plug-in
* in case the plug-in uses the new OSGi bundle layout.
* Returns the bundle {@link Resource} of the plug-in in case the plug-in
* uses the OSGi bundle layout.
*
* @return bundle description if this is an OSGi plug-in,
* or <code>null</code> if the plug-in is in a classic
* format.
* @return resource if this is an OSGi plug-in, or <code>null</code> if the
* plug-in is in a legacy format.
* @since 3.19
*/
Resource getBundleResource();
// TODO: is the legacy format still supported? If yes, remove support for
// that as well?

/**
* Returns the bundle description of the plug-in in case the plug-in uses
* the new OSGi bundle layout.
*
* @return bundle description if this is an OSGi plug-in, or
* <code>null</code> if the plug-in is in a classic format.
*
* @since 3.0
* @deprecated Instead use {@link #getBundleResource() }
*/
BundleDescription getBundleDescription();
@Deprecated(forRemoval = true, since = "4.19")
default org.eclipse.osgi.service.resolver.BundleDescription getBundleDescription() {
return (org.eclipse.osgi.service.resolver.BundleDescription) getBundleResource();
}

/**
* Associates the bundle description of the plug-in
Expand All @@ -152,6 +167,11 @@ public interface IPluginModelBase extends ISharedExtensionsModel, IModelChangePr
* with this model
*
* @since 3.0
* @deprecated Users should never modify the OSGi bundle representation of a
* plugin-model, this is only done by PDE itself.
*/
void setBundleDescription(BundleDescription description);
@Deprecated(forRemoval = true, since = "4.19")
void setBundleDescription(org.eclipse.osgi.service.resolver.BundleDescription description);
// FIXME: I don't think users should be able to set a resource/desription.
// But check possible use-cases again.
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import java.util.ArrayList;

import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.resource.Resource;

/**
* A ModelEntry object has an ID and keeps track of all workspace plug-ins and target
Expand Down Expand Up @@ -105,7 +106,7 @@ public IPluginModelBase getModel() {
private IPluginModelBase getBestCandidate(IPluginModelBase[] models) {
IPluginModelBase result = null;
for (IPluginModelBase model : models) {
if (model.getBundleDescription() == null) {
if (model.getBundleResource() == null) {
continue;
}

Expand All @@ -119,9 +120,11 @@ private IPluginModelBase getBestCandidate(IPluginModelBase[] models) {
continue;
}

BundleDescription current = result.getBundleDescription();
BundleDescription candidate = model.getBundleDescription();
if (!current.isResolved() && candidate.isResolved()) {
BundleRevision current = result.getBundleDescription();
BundleRevision candidate = model.getBundleDescription();
// TODO: check if getWiring()!=null is really equivalent to
// BundleDescription.isResolved()
if (current.getWiring() == null && candidate.getWiring() != null) {
result = model;
continue;
}
Expand Down Expand Up @@ -175,34 +178,42 @@ public String getId() {
}

/**
* Return the plug-in model associated with the given bundle description or
* <code>null</code> if none is found.
* Return the plug-in model associated with the given bundle
* {@link Resource} or <code>null</code> if none is found.
*
* @param desc the given bundle description
* @param resource
* the given bundle resource
*
* @return the plug-in model associated with the given bundle description if such a
* model exists.
* @return the plug-in model associated with the given bundle description if
* such a model exists.
* @since 3.19
*/
public IPluginModelBase getModel(BundleDescription desc) {
if (desc == null) {
public IPluginModelBase getModel(Resource resource) {
if (resource == null) {
return null;
}

for (int i = 0; i < fWorkspaceEntries.size(); i++) {
IPluginModelBase model = fWorkspaceEntries.get(i);
if (desc.equals(model.getBundleDescription())) {
for (IPluginModelBase model : fWorkspaceEntries) {
if (resource.equals(model.getBundleResource())) {
return model;
}
}
for (int i = 0; i < fExternalEntries.size(); i++) {
IPluginModelBase model = fExternalEntries.get(i);
if (desc.equals(model.getBundleDescription())) {
for (IPluginModelBase model : fExternalEntries) {
if (resource.equals(model.getBundleResource())) {
return model;
}
}
return null;
}

/**
* @deprecated Instead use {@link #getModel(Resource) }
*/
@Deprecated(forRemoval = true, since = "4.19")
public IPluginModelBase getModel(org.eclipse.osgi.service.resolver.BundleDescription desc) {
return getModel((Resource) desc);
}

/**
* Returns <code>true</code> if there are workspace plug-ins associated with the ID
* of this model entry; <code>false</code>otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public boolean isBundleModel() {
}

@Override
public BundleDescription getBundleDescription() {
public BundleDescription getBundleResource() {
return fBundleDescription;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void dispose() {
}

@Override
public BundleDescription getBundleDescription() {
public BundleDescription getBundleResource() {
return fBundleDescription;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean isFragmentModel() {
}

@Override
public BundleDescription getBundleDescription() {
public BundleDescription getBundleResource() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean isFragmentModel() {
}

@Override
public BundleDescription getBundleDescription() {
public BundleDescription getBundleResource() {
return null;
}

Expand Down
Loading