boolean (@NotNull final CompositePackagingElement<?> parent, @NotNull String relativePath, @NotNull final PackagingElementResolvingContext context, @NotNull final ArtifactType artifactType, @NotNull PackagingElementPath parentPath, @NotNull final PackagingElementProcessor<? super PackagingElement<?>> processor) { relativePath = StringUtil.trimStart(relativePath, "/"); if (relativePath.isEmpty()) { return true; } int i = relativePath.indexOf('/'); final String firstName = i != -1 ? relativePath.substring(0, i) : relativePath; final String tail = i != -1 ? relativePath.substring(i + 1) : ""; return processElementsWithSubstitutions( parent.getChildren(), context, artifactType, parentPath.appendComposite(parent), new PackagingElementProcessor<>() { @Override public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) { boolean process = element instanceof CompositePackagingElement<?> packagingElement && firstName.equals(packagingElement.getName()) || element instanceof FileCopyPackagingElement fileCopy && firstName.equals(fileCopy.getOutputFileName()); if (process) { if (tail.length() == 0) { if (!processor.process(element, path)) return false; } else if (element instanceof CompositePackagingElement<?> packagingElement) { return processElementsByRelativePath(packagingElement, tail, context, artifactType, path, processor); } } return true; } }); }