@@ -530,7 +530,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
530530 // skip adding resource folders that are included by other resource folders
531531 log .info ("Skipping resource folder " + path + " since it's contained by another resource folder" );
532532 } else {
533- addResourceFolder (classpath , path , outputPath , addTestFlag );
533+ addResourceFolder (classpath , path , outputPath , addTestFlag , resource );
534534 }
535535 // Set folder encoding (null = platform default)
536536 IFolder resourceFolder = project .getFolder (relativePath );
@@ -544,14 +544,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
544544 }
545545
546546 private void addResourceFolder (IClasspathDescriptor classpath , IPath resourceFolder , IPath outputPath ,
547- boolean addTestFlag ) {
547+ boolean addTestFlag , Resource resource ) {
548548 log .info ("Adding resource folder " + resourceFolder );
549- IClasspathEntryDescriptor descriptor = classpath .addSourceEntry (resourceFolder , outputPath , DEFAULT_INCLUSIONS ,
550- new IPath [] {IPath .fromOSString ("**/*.java" )}, false /*optional*/ );
549+ IClasspathEntryDescriptor descriptor = classpath .addSourceEntry (resourceFolder , outputPath ,
550+ toIPathList (resource .getIncludes (), null ),
551+ toIPathList (resource .getExcludes (), "**/*.java" ), false /*optional*/ );
551552 descriptor .setClasspathAttribute (IClasspathManager .TEST_ATTRIBUTE , addTestFlag ? "true" : null );
552553 descriptor .setClasspathAttribute (IClasspathAttribute .OPTIONAL , "true" ); //$NON-NLS-1$
553554 }
554555
556+ private IPath [] toIPathList (final List <String > fileNames , final String defaultPattern ) {
557+ if (fileNames == null ) {
558+ return defaultPattern != null ? new IPath [] {IPath .fromOSString (defaultPattern )} : DEFAULT_INCLUSIONS ;
559+ }
560+ final List <IPath > retList = new ArrayList <>();
561+ for (final String files : fileNames ) {
562+ retList .add (IPath .fromOSString (files ));
563+ }
564+ if (defaultPattern != null ) {
565+ retList .add (IPath .fromOSString (defaultPattern ));
566+ }
567+ return retList .toArray (DEFAULT_INCLUSIONS );
568+ }
569+
555570 private void configureOverlapWithSource (IClasspathDescriptor classpath , IClasspathEntryDescriptor enclosing ,
556571 IPath resourceFolder ) {
557572 // resources and sources folders overlap. make sure JDT only processes java sources.
0 commit comments