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

Consider Require-Capability when validating BREE #1000

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
private boolean fOsgiR4;
private IPluginModelBase fModel;
private Set<String> fProjectPackages;
private static final String osgiEE = "osgi.ee"; //$NON-NLS-1$

public BundleErrorReporter(IFile file) {
super(file);
Expand Down Expand Up @@ -136,7 +137,7 @@
if (desc == null && fModel.getInstallLocation() != null) {
// There was a problem creating the OSGi bundle description, possibly a bad header
try {
StateObjectFactory stateObjectFactory = Platform.getPlatformAdmin().getFactory();

Check warning on line 140 in ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler and API Tools

Deprecation

NORMAL: The method getPlatformAdmin() from the type Platform has been deprecated and marked for removal
File bundleLocation = new File(fModel.getInstallLocation());
Map<String, String> manifest = ManifestUtils.loadManifest(bundleLocation);
TargetWeaver.weaveManifest(manifest, bundleLocation);
Expand Down Expand Up @@ -553,6 +554,21 @@
}
}

private boolean isCompatibleOsgiEE() {
IHeader header = getHeader(Constants.REQUIRE_CAPABILITY);
if (header == null) {
return false;
}
String ee = header.getValue();
String[] parts = ee.split(";"); //$NON-NLS-1$
if (parts[0] == null) {
return false;
}
if (!parts[0].equalsIgnoreCase(osgiEE)) {
return false;
}
return true;
Comment on lines +563 to +570
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not very robust, in general you probably would want to use ManifestElement.parseHeader() instead.
But as written in the general comment, this should be done at a more abstract level.

}
private void validateRequiredExecutionEnvironment() {
int sev = CompilerFlags.getFlag(fProject, CompilerFlags.P_INCOMPATIBLE_ENV);
if (sev == CompilerFlags.IGNORE) {
Expand Down Expand Up @@ -587,7 +603,7 @@
IPath currentPath = entry.getPath();
if (JavaRuntime.newDefaultJREContainerPath().matchingFirstSegments(currentPath) > 0) {
String eeId = JavaRuntime.getExecutionEnvironmentId(currentPath);
if (eeId != null) {
if (eeId != null && !isCompatibleOsgiEE()) {
VirtualMarker marker = report(PDECoreMessages.BundleErrorReporter_noExecutionEnvironmentSet, 1, sev, PDEMarkerFactory.M_EXECUTION_ENVIRONMENT_NOT_SET, PDEMarkerFactory.CAT_EE);
addMarkerAttribute(marker, "ee_id", eeId); //$NON-NLS-1$
addMarkerAttribute(marker,PDEMarkerFactory.compilerKey, CompilerFlags.P_INCOMPATIBLE_ENV);
Expand Down Expand Up @@ -615,7 +631,7 @@
if (vm != null) {
for (IExecutionEnvironment systemEnv : systemEnvs) {
// Get strictly compatible EE for the default VM
if (systemEnv.isStrictlyCompatible(vm)) {
if (systemEnv.isStrictlyCompatible(vm) && !isCompatibleOsgiEE()) {
VirtualMarker marker = report(PDECoreMessages.BundleErrorReporter_noExecutionEnvironmentSet, 1, sev, PDEMarkerFactory.M_EXECUTION_ENVIRONMENT_NOT_SET, PDEMarkerFactory.CAT_EE);
addMarkerAttribute(marker, "ee_id", systemEnv.getId()); //$NON-NLS-1$
addMarkerAttribute(marker,PDEMarkerFactory.compilerKey, CompilerFlags.P_INCOMPATIBLE_ENV);
Expand Down
Loading