From 8b2736035a33a51a9504b737a56e67b2affbb70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 13 Jul 2025 07:11:21 +0200 Subject: [PATCH] Handle test projects that are using the default output location If the only source folder in a project is a test folder it is allowed by JDT to use the standard output location. In such case currently nothing is added to the project jar. This now checks for this case and also includes compile classfiles from there. It also makes sure that test-only classpath entries are not added if not include test is given. --- .../eclipse/pde/internal/core/bnd/PdeProjectAnalyzer.java | 2 +- .../org/eclipse/pde/internal/core/bnd/PdeTestProjectJar.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeProjectAnalyzer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeProjectAnalyzer.java index c9751deafbd..d1e54445e80 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeProjectAnalyzer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeProjectAnalyzer.java @@ -37,7 +37,7 @@ public PdeProjectAnalyzer(IProject project, boolean includeTest) throws Exceptio IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] classpath = javaProject.getResolvedClasspath(true); for (IClasspathEntry cp : classpath) { - if (cp.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { + if (cp.getEntryKind() == IClasspathEntry.CPE_LIBRARY && (includeTest || !cp.isTest())) { IPath path = cp.getPath(); File file = path.toFile(); if (file != null && file.getName().endsWith(".jar") && !file.getName().equals("jrt-fs.jar") //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeTestProjectJar.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeTestProjectJar.java index 394e8571229..d4e945332ba 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeTestProjectJar.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/PdeTestProjectJar.java @@ -38,7 +38,10 @@ public PdeTestProjectJar(IProject project) throws CoreException { for (IClasspathEntry cp : classpath) { if (cp.getEntryKind() == IClasspathEntry.CPE_SOURCE && cp.isTest()) { IPath location = cp.getOutputLocation(); - if (location != null) { + if (location == null) { + IPath defaultOutputLocation = javaProject.getOutputLocation(); + FileResource.addResources(this, workspaceRoot.getFolder(defaultOutputLocation), null); + } else { IFolder otherOutputFolder = workspaceRoot.getFolder(location); FileResource.addResources(this, otherOutputFolder, null); }