Reputation: 2645
I need to copy a file from one location to another location using gradle and stop further processing if the file is not in the destination. But I don't have the exact file name. I have to use the format of the file to check like *.war or *.jar. But assert is not working on path/*.war but if I give "path/name.war" then it is working. Any idea how to do assert for "path/*.war"
from fileTree( "target" ), {
include "*.war"
into '/usr/share/bin/web/'
}
<code>
assert file("/usr/share/bin/web/\*.war").exists(); --> not working
assert file("/usr/share/bin/web/\name.war").exists(); --> working
Upvotes: 0
Views: 6784
Reputation: 8743
Is it this what you are looking for?
File directory = new File("/usr/share/bin/web/");
boolean found = false;
File[] files = directory.listFiles();
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".war")) {
found = true;
break;
}
}
if (!found) {
// throw Exception
}
Upvotes: 2