Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

classpathentry should respect pom resource excludes/includes #1625

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
// skip adding resource folders that are included by other resource folders
log.info("Skipping resource folder " + path + " since it's contained by another resource folder");
} else {
addResourceFolder(classpath, path, outputPath, addTestFlag);
addResourceFolder(classpath, path, outputPath, addTestFlag, resource);
}
// Set folder encoding (null = platform default)
if(r.exists()) {
Expand All @@ -579,14 +579,26 @@ private void addResourceDirs(IClasspathDescriptor classpath, IProject project, M
}

private void addResourceFolder(IClasspathDescriptor classpath, IPath resourceFolder, IPath outputPath,
boolean addTestFlag) {
boolean addTestFlag, Resource resource) {
log.info("Adding resource folder " + resourceFolder);
IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath, DEFAULT_INCLUSIONS,
new IPath[] {IPath.fromOSString("**")}, false /*optional*/);
IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(resourceFolder, outputPath,
toIPathList(resource.getIncludes(), null),
toIPathList(resource.getExcludes(), null), false /*optional*/);
descriptor.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, addTestFlag ? "true" : null);
descriptor.setClasspathAttribute(IClasspathAttribute.OPTIONAL, "true"); //$NON-NLS-1$
}

private IPath[] toIPathList(final List<String> fileNames, final String defaultPattern) {
if (fileNames == null) {
return defaultPattern != null ? new IPath[] {IPath.fromOSString(defaultPattern)} : DEFAULT_INCLUSIONS;
}
final List<IPath> retList = new ArrayList<>();
for (final String files : fileNames) {
retList.add(IPath.fromOSString(files));
}
return retList.toArray(DEFAULT_INCLUSIONS);
}

private void configureOverlapWithSource(IClasspathDescriptor classpath, IClasspathEntryDescriptor enclosing,
IPath resourceFolder) {
// resources and sources folders overlap. make sure JDT only processes java sources.
Expand Down