String contentType = null;
for (int i = 0; i < _specs.length; i++) {
final Class<?> scope = _specs[i].getScope();
final String fileName = _specs[i].getFile();
final IResourceStream resourceStream = findResourceStream(scope, fileName);
if (contentType != null) {
if (resourceStream.getContentType() != null
&& !contentType.equalsIgnoreCase(resourceStream.getContentType())) {
log.warn("content types of merged resources don't match: '" + resourceStream.getContentType()
+ "' and '" + contentType + "'");
}
} else {
contentType = resourceStream.getContentType();
}
try {
final Time lastModified = resourceStream.lastModifiedTime();
if (max == null || lastModified != null && lastModified.after(max)) {
max = lastModified;
}
if (i > 0) {
writeFileSeparator(out);
}
// process content from single spec
byte[] preprocessed = preProcess(_specs[i], StreamUtils.bytes(resourceStream.getInputStream()));
writeContent(out, new ByteArrayInputStream(preprocessed));
resourceStreams.add(resourceStream);
} catch (final IOException e) {
throw new WicketRuntimeException("failed to read from " + resourceStream, e);
} catch (final ResourceStreamNotFoundException e) {
throw new WicketRuntimeException("did not find resource", e);
} finally {
try {
if (resourceStream != null) {
resourceStream.close();
}
} catch (final IOException e) {
log.warn("error while closing reader", e);
}
}