Skip to content

Commit ef7bd58

Browse files
committed
Prepare for migration to javax.inject/annotation provided by Jakarta
Use Import-Package in all wizards/templates and tests instead of relying on the name of the bundle that provides the javax.inject/annotation packages. Part of eclipse-platform/eclipse.platform.releng.aggregator#1056
1 parent 9d7fdce commit ef7bd58

File tree

15 files changed

+32
-23
lines changed

15 files changed

+32
-23
lines changed

ui/org.eclipse.pde.ui.templates/META-INF/MANIFEST.MF

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Export-Package: org.eclipse.pde.internal.ui.templates;x-internal:=true,
1010
org.eclipse.pde.internal.ui.templates.ide;x-internal:=true,
1111
org.eclipse.pde.internal.ui.templates.osgi;x-internal:=true,
1212
org.eclipse.pde.internal.ui.templates.rcp;x-internal:=true
13+
Import-Package: javax.annotation;version="[1.3.0,2.0.0)"
1314
Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)",
1415
org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
1516
org.eclipse.pde.ui;bundle-version="[3.3.0,4.0.0)",

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationNewWizard.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
public class E4ApplicationNewWizard extends AbstractE4NewPluginTemplateWizard {
2222

2323
private static final List<String> PACKAGE_IMPORTS = List.of( //
24-
"javax.annotation;version=\"0.0.0\""); //$NON-NLS-1$
24+
"javax.annotation;version=\"[1.2.0,2.0.0)\"", //$NON-NLS-1$
25+
"javax.inject;version=\"[1.0.0,2.0.0)\""); //$NON-NLS-1$
2526

2627
@Override
2728
public void init(IFieldData data) {

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationTemplate.java

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class E4ApplicationTemplate extends PDETemplateSection {
4444
private static final String EMPTY_E4_MODEL_FILE = "bin" + File.separator + E4_MODEL_FILE; //$NON-NLS-1$
4545

4646
private static final List<String> REQUIRED_BUNDLES = List.of(//
47-
"javax.inject", //$NON-NLS-1$
4847
"org.eclipse.core.runtime", //$NON-NLS-1$
4948
"org.eclipse.swt", //$NON-NLS-1$
5049
"org.eclipse.e4.ui.model.workbench", //$NON-NLS-1$

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4HandlerNewWizard.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
public class E4HandlerNewWizard extends AbstractE4NewPluginTemplateWizard {
2222

2323
private static final List<String> PACKAGE_IMPORTS = List.of( //
24-
"javax.annotation;version=\"1.2.0\""); //$NON-NLS-1$
24+
"javax.annotation;version=\"[1.2.0,2.0.0)\"", //$NON-NLS-1$
25+
"javax.inject;version=\"[1.0.0,2.0.0)\"", //$NON-NLS-1$
26+
"org.osgi.framework;version=\"[1.10.0,2.0.0)\""); //$NON-NLS-1$
2527

2628
@Override
2729
public void init(IFieldData data) {

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4HandlerTemplate.java

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ public class E4HandlerTemplate extends PDETemplateSection {
2929
static final String E4_FRAGMENT_FILE = "fragment.e4xmi"; //$NON-NLS-1$
3030

3131
private static final List<String> REQUIRED_BUNDLES = List.of(//
32-
"javax.inject", //$NON-NLS-1$
33-
"org.eclipse.osgi", //$NON-NLS-1$
3432
"org.eclipse.jface", //$NON-NLS-1$
3533
"org.eclipse.e4.ui.services", //$NON-NLS-1$
3634
"org.eclipse.e4.core.di.annotations"); //$NON-NLS-1$

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ToolbarContributionNewWizard.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
public class E4ToolbarContributionNewWizard extends AbstractE4NewPluginTemplateWizard {
2222

2323
private static final List<String> PACKAGE_IMPORTS = List.of( //
24-
"javax.annotation;version=\"1.2.0\""); //$NON-NLS-1$
24+
"javax.annotation;version=\"[1.2.0,2.0.0)\"", //$NON-NLS-1$
25+
"javax.inject;version=\"[1.0.0,2.0.0)\"", //$NON-NLS-1$
26+
"org.osgi.framework;version=\"[1.10.0,2.0.0)\""); //$NON-NLS-1$
2527

2628
@Override
2729
public void init(IFieldData data) {

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ToolbarContributionTemplate.java

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ public class E4ToolbarContributionTemplate extends PDETemplateSection {
2929
static final String E4_FRAGMENT_FILE = "fragment.e4xmi"; //$NON-NLS-1$
3030

3131
private static final List<String> REQUIRED_BUNDLES = List.of(//
32-
"javax.inject", //$NON-NLS-1$
33-
"org.eclipse.osgi", //$NON-NLS-1$
3432
"org.eclipse.jface", //$NON-NLS-1$
3533
"org.eclipse.e4.ui.services", //$NON-NLS-1$
3634
"org.eclipse.e4.core.di.annotations"); //$NON-NLS-1$

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ViewNewWizard.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
public class E4ViewNewWizard extends AbstractE4NewPluginTemplateWizard {
2222

2323
private static final List<String> PACKAGE_IMPORTS = List.of( //
24-
"javax.annotation;version=\"1.2.0\""); //$NON-NLS-1$
24+
"javax.annotation;version=\"[1.2.0,2.0.0)\"", //$NON-NLS-1$
25+
"javax.inject;version=\"[1.0.0,2.0.0)\"", //$NON-NLS-1$
26+
"org.osgi.framework;version=\"[1.10.0,2.0.0)\""); //$NON-NLS-1$
2527

2628
@Override
2729
public void init(IFieldData data) {

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ViewTemplate.java

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public class E4ViewTemplate extends PDETemplateSection {
2828
static final String E4_FRAGMENT_FILE = "fragment.e4xmi"; //$NON-NLS-1$
2929

3030
private static final List<String> REQUIRED_BUNDLES = List.of(//
31-
"javax.inject", //$NON-NLS-1$
32-
"org.eclipse.osgi", //$NON-NLS-1$
3331
"org.eclipse.jface", //$NON-NLS-1$
3432
"org.eclipse.e4.ui.model.workbench", //$NON-NLS-1$
3533
"org.eclipse.e4.ui.di", //$NON-NLS-1$

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BrowserViewTemplate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public String getUsedExtensionPoint() {
111111
protected void updateModel(IProgressMonitor monitor) throws CoreException {
112112

113113
IBundle bundle = ((IBundlePluginModelBase) model).getBundleModel().getBundle();
114-
bundle.setHeader(Constants.IMPORT_PACKAGE, "javax.inject"); //$NON-NLS-1$
114+
bundle.setHeader(Constants.IMPORT_PACKAGE, "javax.inject;version=\"[1.0.0,2.0.0)\""); //$NON-NLS-1$
115115

116116
IPluginBase plugin = model.getPluginBase();
117117
IPluginExtension extension = createExtension("org.eclipse.ui.views", true); //$NON-NLS-1$

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/ViewTemplate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public String getUsedExtensionPoint() {
124124
protected void updateModel(IProgressMonitor monitor) throws CoreException {
125125

126126
IBundle bundle = ((IBundlePluginModelBase) model).getBundleModel().getBundle();
127-
bundle.setHeader(Constants.IMPORT_PACKAGE, "javax.inject"); //$NON-NLS-1$
127+
bundle.setHeader(Constants.IMPORT_PACKAGE, "javax.inject;version=\"[1.0.0,2.0.0)\""); //$NON-NLS-1$
128128

129129
IPluginBase plugin = model.getPluginBase();
130130
IPluginExtension extension = createExtension("org.eclipse.ui.views", true); //$NON-NLS-1$

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/rcp/ViewRCPTemplate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
8787
createProductExtension();
8888

8989
IBundle bundle = ((IBundlePluginModelBase) model).getBundleModel().getBundle();
90-
bundle.setHeader(Constants.IMPORT_PACKAGE, "javax.inject"); //$NON-NLS-1$
90+
bundle.setHeader(Constants.IMPORT_PACKAGE, "javax.inject;version=\"[1.0.0,2.0.0)\""); //$NON-NLS-1$
9191
}
9292

9393
private void createApplicationExtension() throws CoreException {

ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/$pluginId$.product

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
<plugin id="$pluginId$"/>
2020
<plugin id="com.sun.jna"/>
2121
<plugin id="com.sun.jna.platform"/>
22-
<plugin id="javax.annotation"/>
23-
<plugin id="javax.inject"/>
2422
<plugin id="org.apache.batik.constants"/>
2523
<plugin id="org.apache.batik.css"/>
2624
<plugin id="org.apache.batik.i18n"/>

ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ Require-Bundle: org.junit,
4242
org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="2.1.300",
4343
org.eclipse.platform,
4444
org.eclipse.ui.ide.application
45-
Import-Package: org.assertj.core.api;version="3.14.0",
45+
Import-Package: javax.annotation;version="[1.3.0,2.0.0)",
46+
org.assertj.core.api;version="3.14.0",
4647
org.assertj.core.presentation;version="3.21.0",
4748
org.eclipse.pde.internal.build,
4849
org.junit.jupiter.api.function;version="5.8.1",

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/classpath/ClasspathResolutionTest.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.junit.*;
3333
import org.junit.rules.TestRule;
3434
import org.osgi.framework.Bundle;
35+
import org.osgi.framework.FrameworkUtil;
3536

3637
public class ClasspathResolutionTest {
3738

@@ -43,6 +44,14 @@ public class ClasspathResolutionTest {
4344
@Rule
4445
public final TestRule deleteCreatedTestProjectsAfter = ProjectUtils.DELETE_CREATED_WORKSPACE_PROJECTS_AFTER;
4546

47+
private static String javaxAnnotationProviderBSN;
48+
49+
@BeforeClass
50+
public static void getJavaxAnnotationProviderBSN() {
51+
Bundle bundle = FrameworkUtil.getBundle(javax.annotation.PostConstruct.class);
52+
javaxAnnotationProviderBSN = bundle.getSymbolicName();
53+
}
54+
4655
@Test
4756
public void testImportSystemPackageDoesntAddExtraBundleJava11() throws Exception {
4857
loadTargetPlatform("org.w3c.dom.events");
@@ -73,30 +82,30 @@ public void testImportSystemPackageDoesntAddExtraBundleJava11() throws Exception
7382

7483
@Test
7584
public void testImportExternalPreviouslySystemPackageAddsExtraBundle() throws Exception {
76-
loadTargetPlatform("javax.annotation");
85+
loadTargetPlatform(javaxAnnotationProviderBSN);
7786
IProject project = ProjectUtils.importTestProject("tests/projects/demoMissedExternalPackage");
7887
// In Java 11, javax.annotation is not present, so the bundle *must* be
7988
// part of classpath
8089
List<String> classpathEntries = getRequiredPluginContainerEntries(project);
81-
assertThat(classpathEntries).anyMatch(filename -> filename.contains("javax.annotation"));
90+
assertThat(classpathEntries).anyMatch(filename -> filename.contains(javaxAnnotationProviderBSN));
8291
}
8392

8493
@Test
8594
public void testImportExternalPreviouslySystemPackageAddsExtraBundle_missingBREE() throws Exception {
86-
loadTargetPlatform("javax.annotation");
95+
loadTargetPlatform(javaxAnnotationProviderBSN);
8796
IProject project = ProjectUtils.importTestProject("tests/projects/demoMissedExternalPackageNoBREE");
8897

8998
IExecutionEnvironment java11 = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("JavaSE-11");
9099
assertThat(JavaRuntime.getVMInstall(JavaCore.create(project))).isIn(Arrays.asList(java11.getCompatibleVMs()));
91100
// In Java 11, javax.annotation is not present, so the bundle *must* be
92101
// part of classpath, even if no BREE is specified
93102
List<String> classpathEntries = getRequiredPluginContainerEntries(project);
94-
assertThat(classpathEntries).anyMatch(filename -> filename.contains("javax.annotation"));
103+
assertThat(classpathEntries).anyMatch(filename -> filename.contains(javaxAnnotationProviderBSN));
95104
}
96105

97106
@Test
98107
public void testImportSystemPackageDoesntAddExtraBundleJava8() throws Exception {
99-
loadTargetPlatform("javax.annotation");
108+
loadTargetPlatform(javaxAnnotationProviderBSN);
100109
IProject project = ProjectUtils.importTestProject("tests/projects/demoMissedSystemPackageJava8");
101110
// In Java 8, javax.annotation is present, so the bundle must *NOT* be
102111
// part of classpath
@@ -106,7 +115,7 @@ public void testImportSystemPackageDoesntAddExtraBundleJava8() throws Exception
106115

107116
@Test
108117
public void testImportSystemPackageDoesntAddExtraBundleJava8_osgiEERequirement() throws Exception {
109-
loadTargetPlatform("javax.annotation");
118+
loadTargetPlatform(javaxAnnotationProviderBSN);
110119
IProject project = ProjectUtils.importTestProject("tests/projects/demoMissedSystemPackageJava8OsgiEERequirement");
111120
// bundle is build with java 11, but declares java 8 requirement via
112121
// Require-Capability

0 commit comments

Comments
 (0)