@@ -566,7 +566,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
566566 // skip adding resource folders that are included by other resource folders
567567 log .info ("Skipping resource folder " + path + " since it's contained by another resource folder" );
568568 } else {
569- addResourceFolder (classpath , path , outputPath , addTestFlag );
569+ addResourceFolder (classpath , path , outputPath , addTestFlag , resource );
570570 }
571571 // Set folder encoding (null = platform default)
572572 if (r .exists ()) {
@@ -579,14 +579,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
579579 }
580580
581581 private void addResourceFolder (IClasspathDescriptor classpath , IPath resourceFolder , IPath outputPath ,
582- boolean addTestFlag ) {
582+ boolean addTestFlag , Resource resource ) {
583583 log .info ("Adding resource folder " + resourceFolder );
584- IClasspathEntryDescriptor descriptor = classpath .addSourceEntry (resourceFolder , outputPath , DEFAULT_INCLUSIONS ,
585- new IPath [] {IPath .fromOSString ("**/*.java" )}, false /*optional*/ );
584+ IClasspathEntryDescriptor descriptor = classpath .addSourceEntry (resourceFolder , outputPath ,
585+ toIPathList (resource .getIncludes (), null ),
586+ toIPathList (resource .getExcludes (), "**/*.java" ), false /*optional*/ );
586587 descriptor .setClasspathAttribute (IClasspathManager .TEST_ATTRIBUTE , addTestFlag ? "true" : null );
587588 descriptor .setClasspathAttribute (IClasspathAttribute .OPTIONAL , "true" ); //$NON-NLS-1$
588589 }
589590
591+ private IPath [] toIPathList (final List <String > fileNames , final String defaultPattern ) {
592+ if (fileNames == null ) {
593+ return defaultPattern != null ? new IPath [] {IPath .fromOSString (defaultPattern )} : DEFAULT_INCLUSIONS ;
594+ }
595+ final List <IPath > retList = new ArrayList <>();
596+ for (final String files : fileNames ) {
597+ retList .add (IPath .fromOSString (files ));
598+ }
599+ if (defaultPattern != null ) {
600+ retList .add (IPath .fromOSString (defaultPattern ));
601+ }
602+ return retList .toArray (DEFAULT_INCLUSIONS );
603+ }
604+
590605 private void configureOverlapWithSource (IClasspathDescriptor classpath , IClasspathEntryDescriptor enclosing ,
591606 IPath resourceFolder ) {
592607 // resources and sources folders overlap. make sure JDT only processes java sources.
0 commit comments