List<VirtualFile> (CompositePackagingElement<?> parent, final String outputPath, final PackagingElementResolvingContext context, final ArtifactType artifactType) { final String path = StringUtil.trimStart(outputPath, "/"); if (path.isEmpty()) { return Collections.emptyList(); } int i = path.indexOf('/'); final String firstName = i != -1 ? path.substring(0, i) : path; final String tail = i != -1 ? path.substring(i+1) : ""; final List<VirtualFile> result = new SmartList<>(); processElementsWithSubstitutions(parent.getChildren(), context, artifactType, PackagingElementPath.EMPTY, new PackagingElementProcessor<>() { @Override public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath elementPath) { //todo replace by method findSourceFile() in PackagingElement if (element instanceof CompositePackagingElement<?> compositeElement) { if (firstName.equals(compositeElement.getName())) { result.addAll(findSourceFilesByOutputPath(compositeElement, tail, context, artifactType)); } } else if (element instanceof FileCopyPackagingElement fileCopyElement) { if (firstName.equals(fileCopyElement.getOutputFileName()) && tail.isEmpty()) { ContainerUtil.addIfNotNull(result, fileCopyElement.findFile()); } } else if (element instanceof DirectoryCopyPackagingElement || element instanceof ExtractedDirectoryPackagingElement) { final VirtualFile sourceRoot = ((FileOrDirectoryCopyPackagingElement<?>)element).findFile(); if (sourceRoot != null) { ContainerUtil.addIfNotNull(result, sourceRoot.findFileByRelativePath(path)); } } else if (element instanceof ModulePackagingElement modulePackaging) { ContainerUtil.addIfNotNull(result, findResourceFile(modulePackaging, context, path)); } return true; } }); return result; }