-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
The files target property: Add support for directories #1053
Conversation
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.
LGTM! Useful feature. Let's merge.
Co-authored-by: Edward A. Lee <eal@eecs.berkeley.edu>
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.
I think the added feature makes sense, but I had some comments in the pipeline that I didn't get to share before the PR was merged.
* @param dstDir Where the file or directory should be placed. | ||
* @return The name of the file or directory in destinationDirectory or an empty string on failure. | ||
*/ | ||
public static String copyFileOrResource(String fileName, Path srcDir, |
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.
I think it would be better to rename fileName
to fileOrDir
.
// because it is the only one currently capable of handling asynchronous events. | ||
if (!targetConfig.threading) { | ||
if (!targetConfig.threading && !targetConfig.setByUser.contains(TargetProperty.THREADING)) { |
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.
I'm a little confused about this change. What does it do? I seems entirely unrelated to the PR.
public static String copyFileOrResource(String fileName, Path srcDir, | ||
Path dstDir) { | ||
// Try to copy the file or directory from the file system. | ||
Path file = findFileOrDirectory(fileName, srcDir); |
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.
I would rename file
to path
here.
} | ||
} | ||
|
||
String filenameWithoutPath = fileName; |
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.
The following takes the tail of a path (e.g., foo/bar/baz.lf
yields baz.lf
; foo/bar
yields bar
) and just looks for it on the class path. This doesn't seem right to me. I don't think there are any tests for this, and I think the FIXME
below alludes to this. I realize this FIXME
preexists this PR, but I think we should fix and not ignore it.
This adds support for including entire directories in the
files
target property (e.g.,files: ["/etc"]
).I found this to be very convenient. Imagine a game that requires a number of images that are located in a folder.
It would be convenient to be able to use
files: ["images"]
instead of listing each image file one by one.