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

Exclude non-source directories from java project #523

Merged
merged 1 commit into from
Feb 25, 2016
Merged
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 @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you return "" and null when srcAttribute doesn't have value?
https://github.com/eclipse/che/pull/523/files#diff-6063db316be1e2733d888f9686ae3133R98

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because maven project (which is java simultaneously) should have source folder definition, in this case it will be defined or empty, if empty, then we'll mark root folder as source. If project is java (not maven), then source folder may not be defined, if so, then we don't mark any folder as source.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a temporary solution, which I think will be refactored after GA.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explanation

}

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