Get All directories containing java source code
Answered
Hello,
I am developing a plugin that needs all the paths to directory containing any java source code. In Eclipse, it can be done using below code. I do not know how it can be done in IntelliJ IDEA. Please let me know if I can do the same in Intellij IDEA.
Documentation for IClasspathEntry : https://archive.eclipse.org/eclipse/downloads/documentation/2.0/html/plugins/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/IClasspathEntry.html
project = IJavaProject
IClasspathEntry[] entries = project.getResolvedClasspath(true);
List<IClasspathEntry> result = new ArrayList<IClasspathEntry>();
for (IClasspathEntry entry : entries) {
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
result.add(entry);
}
}
Please sign in to leave a comment.
Hi Rajat,
See: https://plugins.jetbrains.com/docs/intellij/project.html#getting-a-list-of-source-roots-for-all-modules-in-a-project
It Helped. Thank you.