@@ -566,7 +566,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
566
566
// skip adding resource folders that are included by other resource folders
567
567
log .info ("Skipping resource folder " + path + " since it's contained by another resource folder" );
568
568
} else {
569
- addResourceFolder (classpath , path , outputPath , addTestFlag );
569
+ addResourceFolder (classpath , path , outputPath , addTestFlag , resource );
570
570
}
571
571
// Set folder encoding (null = platform default)
572
572
if (r .exists ()) {
@@ -579,14 +579,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
579
579
}
580
580
581
581
private void addResourceFolder (IClasspathDescriptor classpath , IPath resourceFolder , IPath outputPath ,
582
- boolean addTestFlag ) {
582
+ boolean addTestFlag , Resource resource ) {
583
583
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*/ );
586
587
descriptor .setClasspathAttribute (IClasspathManager .TEST_ATTRIBUTE , addTestFlag ? "true" : null );
587
588
descriptor .setClasspathAttribute (IClasspathAttribute .OPTIONAL , "true" ); //$NON-NLS-1$
588
589
}
589
590
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
+
590
605
private void configureOverlapWithSource (IClasspathDescriptor classpath , IClasspathEntryDescriptor enclosing ,
591
606
IPath resourceFolder ) {
592
607
// resources and sources folders overlap. make sure JDT only processes java sources.
0 commit comments