@@ -569,7 +569,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
569
569
// skip adding resource folders that are included by other resource folders
570
570
log .info ("Skipping resource folder " + path + " since it's contained by another resource folder" );
571
571
} else {
572
- addResourceFolder (classpath , path , outputPath , addTestFlag );
572
+ addResourceFolder (classpath , path , outputPath , addTestFlag , resource );
573
573
}
574
574
// Set folder encoding (null = platform default)
575
575
if (r .exists () && !Objects .equals (r .getDefaultCharset (false ), resourceEncoding )) {
@@ -582,14 +582,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
582
582
}
583
583
584
584
private void addResourceFolder (IClasspathDescriptor classpath , IPath resourceFolder , IPath outputPath ,
585
- boolean addTestFlag ) {
585
+ boolean addTestFlag , Resource resource ) {
586
586
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*/ );
589
590
descriptor .setClasspathAttribute (IClasspathManager .TEST_ATTRIBUTE , addTestFlag ? "true" : null );
590
591
descriptor .setClasspathAttribute (IClasspathAttribute .OPTIONAL , "true" ); //$NON-NLS-1$
591
592
}
592
593
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
+
593
608
private void configureOverlapWithSource (IClasspathDescriptor classpath , IClasspathEntryDescriptor enclosing ,
594
609
IPath resourceFolder ) {
595
610
// resources and sources folders overlap. make sure JDT only processes java sources.
0 commit comments