Skip to content

Commit eec33d4

Browse files
qxoHannesWell
authored andcommitted
feat: classpathentry should respect pom resource
excludes/includes,: so we build project on eclipse without org.eclipse.m2e.core.maven2Builder
1 parent 5ca5763 commit eec33d4

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
567567
// skip adding resource folders that are included by other resource folders
568568
log.info("Skipping resource folder " + path + " since it's contained by another resource folder");
569569
} else {
570-
addResourceFolder(classpath, path, outputPath, addTestFlag);
570+
addResourceFolder(classpath, path, outputPath, addTestFlag, resource);
571571
}
572572
// Set folder encoding (null = platform default)
573573
if(r.exists()) {
@@ -580,14 +580,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
580580
}
581581

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

592+
private IPath[] toIPathList(final List<String> fileNames, final String defaultPattern) {
593+
if (fileNames == null) {
594+
return defaultPattern != null ? new IPath[] {IPath.fromOSString(defaultPattern)} : DEFAULT_INCLUSIONS;
595+
}
596+
final List<IPath> retList = new ArrayList<>();
597+
for (final String files : fileNames) {
598+
retList.add(IPath.fromOSString(files));
599+
}
600+
if (defaultPattern != null) {
601+
retList.add(IPath.fromOSString(defaultPattern));
602+
}
603+
return retList.toArray(DEFAULT_INCLUSIONS);
604+
}
605+
591606
private void configureOverlapWithSource(IClasspathDescriptor classpath, IClasspathEntryDescriptor enclosing,
592607
IPath resourceFolder) {
593608
// resources and sources folders overlap. make sure JDT only processes java sources.

0 commit comments

Comments
 (0)