@@ -530,7 +530,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
530
530
// skip adding resource folders that are included by other resource folders
531
531
log .info ("Skipping resource folder " + path + " since it's contained by another resource folder" );
532
532
} else {
533
- addResourceFolder (classpath , path , outputPath , addTestFlag );
533
+ addResourceFolder (classpath , path , outputPath , addTestFlag , resource );
534
534
}
535
535
// Set folder encoding (null = platform default)
536
536
IFolder resourceFolder = project .getFolder (relativePath );
@@ -544,14 +544,29 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
544
544
}
545
545
546
546
private void addResourceFolder (IClasspathDescriptor classpath , IPath resourceFolder , IPath outputPath ,
547
- boolean addTestFlag ) {
547
+ boolean addTestFlag , Resource resource ) {
548
548
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*/ );
551
552
descriptor .setClasspathAttribute (IClasspathManager .TEST_ATTRIBUTE , addTestFlag ? "true" : null );
552
553
descriptor .setClasspathAttribute (IClasspathAttribute .OPTIONAL , "true" ); //$NON-NLS-1$
553
554
}
554
555
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
+
555
570
private void configureOverlapWithSource (IClasspathDescriptor classpath , IClasspathEntryDescriptor enclosing ,
556
571
IPath resourceFolder ) {
557
572
// resources and sources folders overlap. make sure JDT only processes java sources.
0 commit comments