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 org.eclipse.pde.feature dependency to pull additional requirements #1207

Merged
merged 2 commits into from Mar 19, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PDE JUnit Tests
Bundle-SymbolicName: org.eclipse.pde.ui.tests; singleton:=true
Bundle-Version: 3.12.400.qualifier
Bundle-Version: 3.12.500.qualifier
Bundle-ClassPath: tests.jar
Bundle-Activator: org.eclipse.pde.ui.tests.PDETestsPlugin
Bundle-Vendor: Eclipse.org
Expand Down
24 changes: 20 additions & 4 deletions ui/org.eclipse.pde.ui.tests/pom.xml
Expand Up @@ -18,14 +18,14 @@
<relativePath>../../</relativePath>
</parent>
<artifactId>org.eclipse.pde.ui.tests</artifactId>
<version>3.12.400-SNAPSHOT</version>
<version>3.12.500-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>

<properties>
<defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>
<testSuite>${project.artifactId}</testSuite>
<testClass>org.eclipse.pde.ui.tests.AllPDETests</testClass>
<surefire.testArgLine>-DDetectVMInstallationsJob.disabled=true</surefire.testArgLine>
<testSuite>${project.artifactId}</testSuite>
<testClass>org.eclipse.pde.ui.tests.AllPDETests</testClass>
<surefire.testArgLine>-DDetectVMInstallationsJob.disabled=true</surefire.testArgLine>
</properties>

<build>
Expand All @@ -45,6 +45,22 @@
</dependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<!-- require the pde feature so we get additional dependencies -->
<type>eclipse-feature</type>
<id>org.eclipse.pde</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Expand Up @@ -62,12 +62,12 @@ public class ClasspathResolutionTest {
@Rule
public final TestRule deleteCreatedTestProjectsAfter = ProjectUtils.DELETE_CREATED_WORKSPACE_PROJECTS_AFTER;

private static String javaxAnnotationProviderBSN;
private static String jakartaAnnotationProviderBSN;

@BeforeClass
public static void getJavaxAnnotationProviderBSN() {
Bundle bundle = FrameworkUtil.getBundle(jakarta.annotation.PostConstruct.class);
javaxAnnotationProviderBSN = bundle.getSymbolicName();
jakartaAnnotationProviderBSN = bundle.getSymbolicName();
}

@Test
Expand Down Expand Up @@ -100,50 +100,50 @@ public void testImportSystemPackageDoesntAddExtraBundleJava11() throws Exception

@Test
public void testImportExternalPreviouslySystemPackageAddsExtraBundle() throws Exception {
loadTargetPlatform(javaxAnnotationProviderBSN);
loadTargetPlatform(jakartaAnnotationProviderBSN);
IProject project = ProjectUtils.importTestProject("tests/projects/demoMissedExternalPackage");
// In Java 11, jakarta.annotation is not present, so the bundle *must*
// be part of classpath
List<String> classpathEntries = getRequiredPluginContainerEntries(project);
assertThat(classpathEntries).anyMatch(filename -> filename.contains(javaxAnnotationProviderBSN));
assertThat(classpathEntries).anyMatch(filename -> filename.contains(jakartaAnnotationProviderBSN));
}

@Test
public void testImportExternalPreviouslySystemPackageAddsExtraBundle_missingBREE() throws Exception {
loadTargetPlatform(javaxAnnotationProviderBSN);
loadTargetPlatform(jakartaAnnotationProviderBSN);
IProject project = ProjectUtils.importTestProject("tests/projects/demoMissedExternalPackageNoBREE");

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

@Test
public void testImportSystemPackageDoesntAddExtraBundleJava8() throws Exception {
loadTargetPlatform(javaxAnnotationProviderBSN);
loadTargetPlatform(jakartaAnnotationProviderBSN);
try (var mocked = mockExtraExtraJRESystemPackages("JavaSE-1.8", List.of("jakarta.annotation"))) {
IProject project = ProjectUtils.importTestProject("tests/projects/demoMissedSystemPackageJava8");
// In Java 8, jakarta.annotation is present, so the bundle must
// *NOT* be part of classpath
List<String> classpathEntries = getRequiredPluginContainerEntries(project);
assertThat(classpathEntries).isEmpty();
assertThat(classpathEntries).noneMatch(filename -> filename.contains(jakartaAnnotationProviderBSN));
}
}

@Test
public void testImportSystemPackageDoesntAddExtraBundleJava8_osgiEERequirement() throws Exception {
loadTargetPlatform(javaxAnnotationProviderBSN);
loadTargetPlatform(jakartaAnnotationProviderBSN);
try (var mocked = mockExtraExtraJRESystemPackages("JavaSE-1.8", List.of("jakarta.annotation"))) {
IProject project = ProjectUtils
.importTestProject("tests/projects/demoMissedSystemPackageJava8OsgiEERequirement");
// bundle is build with java 11, but declares java 8 requirement via
// Require-Capability
// --> jakarta.annotation bundle must not be on the classpath
List<String> classpathEntries = getRequiredPluginContainerEntries(project);
assertThat(classpathEntries).isEmpty();
assertThat(classpathEntries).noneMatch(filename -> filename.contains(jakartaAnnotationProviderBSN));
}
}

Expand Down