-
Notifications
You must be signed in to change notification settings - Fork 43
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
Allow mapping of Java source files. #455
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -585,4 +585,16 @@ class Utils { | |
static boolean projectMkDir(Project proj, Object path) { | ||
return proj.mkdir(path) | ||
} | ||
|
||
static FileCollection mapSourceFiles(Project proj, FileCollection files, | ||
Map<String, String> sourceMapping) { | ||
for (String before : sourceMapping.keySet()) { | ||
if (files.contains(proj.file(before))) { | ||
// Replace the before file with the after file. | ||
files = files.minus(proj.files(before)).plus( | ||
proj.files(sourceMapping.get(before))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How efficient is this for large sets of files? I'm sure it isn't efficient but is it in practice an issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm using this for large libraries and have noticed no issue. the slowdown is proportional to the number of sourceMappings, which we expect to be very small. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sense that performance will not be an issue. |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Produce an error if a sourceMapping doesn't exist? Likely that indicates a deeper error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would mean a failure of the JDK. let's not verify basic Java functionality. (the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like that should be an assert then ;-) |
||
} | ||
return files | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change ret => result, I think it's more legible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it seems like
ret
is a convention so shall we stick with that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep it is