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

Add support for the 'deprecated' directive on required bundles #1543

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public class PDECoreMessages extends NLS {
public static String BundleErrorReporter_unecessaryDependencyDueToFragmentHost;
public static String BundleErrorReporter_missingPackagesInProject;
public static String BundleErrorReporter_noExecutionEnvironmentSet;
public static String BundleErrorReporter_deprecatedBundle;

public static String BundleErrorReporter_startHeader_autoStartDeprecated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
Expand Down Expand Up @@ -97,6 +98,7 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.Version;
import org.osgi.framework.VersionRange;
import org.osgi.framework.wiring.BundleCapability;

public class BundleErrorReporter extends JarManifestErrorReporter {

Expand Down Expand Up @@ -184,6 +186,36 @@ protected void validate(IProgressMonitor monitor) {
validateEclipseGenericCapability();
validateEclipseGenericRequire();
validateServiceComponent();
if (isCheckDeprecated()) {
validateDeprecated();
}
}

private void validateDeprecated() {
IHeader header = getHeader(Constants.REQUIRE_BUNDLE);
if (header == null) {
return;
}
BundleDescription desc = fModel.getBundleDescription();
if (desc == null) {
return;
}
BundleSpecification[] requiredBundles = desc.getRequiredBundles();
for (BundleSpecification bundleSpecification : requiredBundles) {
BaseDescription bundle = bundleSpecification.getSupplier();
if (bundle != null) {
BundleCapability capability = bundle.getCapability();
if (capability != null) {
String deprecatedDirective = capability.getDirectives().get("deprecated"); //$NON-NLS-1$
if (deprecatedDirective != null) {
report(NLS.bind(PDECoreMessages.BundleErrorReporter_deprecatedBundle, bundle.getName(),
deprecatedDirective), header.getLineNumber(), CompilerFlags.WARNING,
PDEMarkerFactory.CAT_DEPRECATION);
}
}
}
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ BundleErrorReporter_eclipse_genericRequireDeprecated=''{0}'' header is deprecate
BundleErrorReporter_unecessaryDependencyDueToFragmentHost=The ''{0}'' dependency is not necessary as it is already specified in Fragment-Host header
BundleErrorReporter_localization_properties_file_not_exist=no valid properties files exist in the localization directory specified
BundleErrorReporter_illegalManifestVersion=The bundle manifest version is invalid. Valid ranges are 1-2.
BundleErrorReporter_deprecatedBundle=The bundle {0} is deprecated: {1}
BundleErrorReporter_serviceComponentLazyStart=Bundles with a Service-Component should set the Bundle-ActivationPolicy to lazy.
BundleManifestSourceLocationManager_problemProcessBundleManifestHeaderAttributeMissing=Problem processing bundle manifest header in source bundle {0}, plugin name and version must both be specified.
BundleValidationOperation_multiple_singletons={0} versions of singleton ''{1}'' exist
Expand Down
Loading