Skip to content

Commit

Permalink
Merge pull request #523 from eclipse/CHE-589
Browse files Browse the repository at this point in the history
Exclude non-source directories from java project
  • Loading branch information
Vladyslav Zhukovskyi committed Feb 25, 2016
2 parents b163c2c + 049c60d commit 1082978
Showing 1 changed file with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,43 +75,30 @@ private ContentRoot getSourceType(Node node) {
final ProjectConfigDto projectConfig = folderNode.getProjectConfig();

String srcFolder = _getSourceFolder(projectConfig, getSrcFolderAttribute());
if (folderNode.getStorablePath().endsWith(srcFolder)) {
if (srcFolder != null && folderNode.getStorablePath().endsWith(srcFolder)) {
return ContentRoot.SOURCE;
}

String testSrcFolder = _getSourceFolder(projectConfig, getTestSrcFolderAttribute());
if (folderNode.getStorablePath().endsWith(testSrcFolder)) {
if (testSrcFolder != null && folderNode.getStorablePath().endsWith(testSrcFolder)) {
return ContentRoot.TEST_SOURCE;
}

return null;
}

private String _getSourceFolder(ProjectConfigDto projectConfig, String srcAttribute) {
Map<String, List<String>> attributes = projectConfig.getAttributes();
final Map<String, List<String>> attributes = projectConfig.getAttributes();
if (!attributes.containsKey(srcAttribute)) {
return "";
return null;
}

List<String> values = attributes.get(srcAttribute);

final List<String> values = attributes.get(srcAttribute);
if (values.isEmpty()) {
return "";
}

String srcFolder = "";

if ("maven.resource.folder".equals(srcAttribute)) {
for (String srcFolderValue : values) {
if (srcFolderValue.endsWith("/resources")) {
srcFolder = srcFolderValue;

break;
}
}
} else {
srcFolder = values.get(0);
}
final String srcFolder = values.get(0);

return projectConfig.getPath() + (srcFolder.startsWith("/") ? srcFolder : "/" + srcFolder);
}
Expand Down

0 comments on commit 1082978

Please sign in to comment.