in enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/ExternalRules.java [162:186]
private InputStream resolveDescriptor(String path) throws EnforcerRuleError {
InputStream descriptorStream;
if (path != null) {
if (path.startsWith(LOCATION_PREFIX_CLASSPATH)) {
String classpathLocation = path.substring(LOCATION_PREFIX_CLASSPATH.length());
getLog().debug("Read rules form classpath location: " + classpathLocation);
ClassLoader classRealm = mojoExecution.getMojoDescriptor().getRealm();
descriptorStream = classRealm.getResourceAsStream(classpathLocation);
if (descriptorStream == null) {
throw new EnforcerRuleError("Location '" + classpathLocation + "' not found in classpath");
}
} else {
File descriptorFile = evaluator.alignToBaseDirectory(new File(path));
getLog().debug("Read rules form file location: " + descriptorFile);
try {
descriptorStream = Files.newInputStream(descriptorFile.toPath());
} catch (IOException e) {
throw new EnforcerRuleError("Could not read descriptor in " + descriptorFile, e);
}
}
} else {
throw new EnforcerRuleError("No location provided");
}
return descriptorStream;
}