in src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java [106:153]
void initialize(String[] defaultIncludes, String[] defaultExcludes, Overlay currentProjectOverlay)
throws InvalidOverlayConfigurationException {
// Build the list of configured artifacts and makes sure that each overlay
// refer to a valid artifact
final List<Artifact> configuredWarArtifacts = new ArrayList<>();
final ListIterator<Overlay> it = overlays.listIterator();
while (it.hasNext()) {
Overlay overlay = it.next();
if (overlay == null) {
throw new InvalidOverlayConfigurationException("overlay could not be null.");
}
// If it's the current project, return the project instance
if (overlay.isCurrentProject()) {
overlay = currentProjectOverlay;
it.set(overlay);
}
// default includes/excludes - only if the overlay uses the default settings
if (Arrays.equals(Overlay.DEFAULT_INCLUDES, overlay.getIncludes())
&& Arrays.equals(Overlay.DEFAULT_EXCLUDES, overlay.getExcludes())) {
overlay.setIncludes(defaultIncludes);
overlay.setExcludes(defaultExcludes);
}
final Artifact artifact = getAssociatedArtifact(overlay);
if (artifact != null) {
configuredWarArtifacts.add(artifact);
overlay.setArtifact(artifact);
}
}
// Build the list of missing overlays
for (Artifact artifact : artifactsOverlays) {
if (!configuredWarArtifacts.contains(artifact)) {
// Add a default overlay for the given artifact which will be applied after
// the ones that have been configured
overlays.add(new DefaultOverlay(artifact, defaultIncludes, defaultExcludes));
}
}
// Final validation, make sure that the current project is in there. Otherwise add it first
for (Overlay overlay : overlays) {
if (overlay.equals(currentProjectOverlay)) {
return;
}
}
overlays.add(0, currentProjectOverlay);
}