in src/main/java/org/apache/maven/shared/verifier/Verifier.java [929:1015]
private void verifyFilePresence(String filePath, boolean wanted) throws VerificationException {
if (filePath.contains("!/")) {
Path basedir = Paths.get(getBasedir()).toAbsolutePath();
String urlString = "jar:" + basedir.toUri().toASCIIString() + "/" + filePath;
InputStream is = null;
try {
URL url = new URL(urlString);
is = url.openStream();
if (is == null) {
if (wanted) {
throw new VerificationException("Expected JAR resource was not found: " + filePath);
}
} else {
if (!wanted) {
throw new VerificationException("Unwanted JAR resource was found: " + filePath);
}
}
} catch (MalformedURLException e) {
throw new VerificationException("Error looking for JAR resource", e);
} catch (IOException e) {
if (wanted) {
throw new VerificationException("Error looking for JAR resource: " + filePath);
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
} else {
File expectedFile = new File(filePath);
// NOTE: On Windows, a path with a leading (back-)slash is relative to the current drive
if (!expectedFile.isAbsolute() && !expectedFile.getPath().startsWith(File.separator)) {
expectedFile = new File(getBasedir(), filePath);
}
if (filePath.indexOf('*') > -1) {
File parent = expectedFile.getParentFile();
if (!parent.exists()) {
if (wanted) {
throw new VerificationException(
"Expected file pattern was not found: " + expectedFile.getPath());
}
} else {
String shortNamePattern = expectedFile.getName().replaceAll("\\*", ".*");
String[] candidates = parent.list();
boolean found = false;
if (candidates != null) {
for (String candidate : candidates) {
if (candidate.matches(shortNamePattern)) {
found = true;
break;
}
}
}
if (!found && wanted) {
throw new VerificationException(
"Expected file pattern was not found: " + expectedFile.getPath());
} else if (found && !wanted) {
throw new VerificationException("Unwanted file pattern was found: " + expectedFile.getPath());
}
}
} else {
if (!expectedFile.exists()) {
if (wanted) {
throw new VerificationException("Expected file was not found: " + expectedFile.getPath());
}
} else {
if (!wanted) {
throw new VerificationException("Unwanted file was found: " + expectedFile.getPath());
}
}
}
}
}