Skip to content

Commit

Permalink
feat: classpathentry should respect pom resource
Browse files Browse the repository at this point in the history
excludes/includes,:
so we build project on eclipse without org.eclipse.m2e.core.maven2Builder
  • Loading branch information
qxo authored and HannesWell committed Feb 3, 2024
1 parent edfc716 commit 1e4fa5d
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
// skip adding resource folders that are included by other resource folders
log.info("Skipping resource folder " + path + " since it's contained by another resource folder");
} else {
addResourceFolder(classpath, path, outputPath, addTestFlag);
addResourceFolder(classpath, path, outputPath, addTestFlag, resource);
}
// Set folder encoding (null = platform default)
if(r.exists()) {
Expand All @@ -579,14 +579,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
}

private void addResourceFolder(IClasspathDescriptor classpath, IPath resourceFolder, IPath outputPath,
boolean addTestFlag) {
boolean addTestFlag, Resource resource) {
log.info("Adding resource folder " + resourceFolder);
IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath, DEFAULT_INCLUSIONS,
new IPath[] {IPath.fromOSString("**/*.java")}, false /*optional*/);
IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath,
toIPathList(resource.getIncludes(), null),
toIPathList(resource.getExcludes(), "**/*.java"), false /*optional*/);
descriptor.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, addTestFlag ? "true" : null);
descriptor.setClasspathAttribute(IClasspathAttribute.OPTIONAL, "true"); //$NON-NLS-1$
}

private IPath[] toIPathList(final List<String> fileNames, final String defaultPattern) {
if (fileNames == null) {
return defaultPattern != null ? new IPath[] {IPath.fromOSString(defaultPattern)} : DEFAULT_INCLUSIONS;
}
final List<IPath> retList = new ArrayList<>();
for (final String files : fileNames) {
retList.add(IPath.fromOSString(files));
}
if (defaultPattern != null) {
retList.add(IPath.fromOSString(defaultPattern));
}
return retList.toArray(DEFAULT_INCLUSIONS);
}

private void configureOverlapWithSource(IClasspathDescriptor classpath, IClasspathEntryDescriptor enclosing,
IPath resourceFolder) {
// resources and sources folders overlap. make sure JDT only processes java sources.
Expand Down

0 comments on commit 1e4fa5d

Please sign in to comment.