@@ -569,7 +569,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
569569 // skip adding resource folders that are included by other resource folders
570570 log .info ("Skipping resource folder " + path + " since it's contained by another resource folder" );
571571 } else {
572- addResourceFolder (classpath , path , outputPath , addTestFlag );
572+ addResourceFolder (classpath , path , outputPath , addTestFlag , resource );
573573 }
574574 // Set folder encoding (null = platform default)
575575 if (r .exists () && !Objects .equals (r .getDefaultCharset (false ), resourceEncoding )) {
@@ -582,14 +582,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
582582 }
583583
584584 private void addResourceFolder (IClasspathDescriptor classpath , IPath resourceFolder , IPath outputPath ,
585- boolean addTestFlag ) {
585+ boolean addTestFlag , Resource resource ) {
586586 log .info ("Adding resource folder " + resourceFolder );
587- IClasspathEntryDescriptor descriptor = classpath .addSourceEntry (resourceFolder , outputPath , DEFAULT_INCLUSIONS ,
588- new IPath [] {IPath .fromOSString ("**/*.java" )}, false /*optional*/ );
587+ IClasspathEntryDescriptor descriptor = classpath .addSourceEntry (resourceFolder , outputPath ,
588+ toIPathList (resource .getIncludes (), null ),
589+ toIPathList (resource .getExcludes (), "**/*.java" ), false /*optional*/ );
589590 descriptor .setClasspathAttribute (IClasspathManager .TEST_ATTRIBUTE , addTestFlag ? "true" : null );
590591 descriptor .setClasspathAttribute (IClasspathAttribute .OPTIONAL , "true" ); //$NON-NLS-1$
591592 }
592593
594+ private IPath [] toIPathList (final List <String > fileNames , final String defaultPattern ) {
595+ if (fileNames == null ) {
596+ return defaultPattern != null ? new IPath [] {IPath .fromOSString (defaultPattern )} : DEFAULT_INCLUSIONS ;
597+ }
598+ final List <IPath > retList = new ArrayList <>();
599+ for (final String files : fileNames ) {
600+ retList .add (IPath .fromOSString (files ));
601+ }
602+ if (defaultPattern != null ) {
603+ retList .add (IPath .fromOSString (defaultPattern ));
604+ }
605+ return retList .toArray (DEFAULT_INCLUSIONS );
606+ }
607+
593608 private void configureOverlapWithSource (IClasspathDescriptor classpath , IClasspathEntryDescriptor enclosing ,
594609 IPath resourceFolder ) {
595610 // resources and sources folders overlap. make sure JDT only processes java sources.
0 commit comments