JpsCompositePackagingElement (@NotNull JpsCompositePackagingElement root, @NotNull @NonNls String path, final boolean directory) { path = StringUtil.trimStart(StringUtil.trimEnd(path, "/"), "/"); if (path.length() == 0) { return root; } int index = path.lastIndexOf('/'); String lastName = path.substring(index + 1); String parentPath = index != -1 ? path.substring(0, index) : ""; final JpsCompositePackagingElement parent = getOrCreateDirectoryOrArchive(root, parentPath, true); final JpsCompositePackagingElement last = directory ? createDirectory(lastName) : createArchive(lastName); return parent.addChild(last); }