Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] Checking if a class is from a test package

As Mickael wrote, you have to find the classpathEntry, but then you don’t have to iterate the attributes yourself, but can
use org.eclipse.jdt.core.IClasspathEntry.isTest().

How to get the classpathEntry depends on what object you are starting with.

I’d suggest to look at existing usages of  org.eclipse.jdt.core.IClasspathEntry.isTest() to find code that is most similar.


Am 03.04.2020 um 14:06 schrieb Mickael Istria <mistria@xxxxxxxxxx>:



On Fri, Apr 3, 2020 at 12:45 PM Gayan Perera <gayanper@xxxxxxxxx> wrote:
How to check a given class is in side test source folder or production source folder.

Something like:
Arrays.stream(((IPackageFragmentRoot)javaProject.findElement(folder.getPath()).getParent()).getRawClasspathEntry().getExtraAttributes()).anyMatch(att -> "test".equals(att.getName()) && Boolean.parseBoolean(att.getValue()))
might work.

HTH
_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jdt-dev


Back to the top