public static void packageFile(@NotNull VirtualFile file, @NotNull Project project, final Artifact[] artifacts,
                                 final boolean packIntoArchives) throws IOException {
    LOG.debug("Start packaging file: " + file.getPath());
    final Collection<ArtifactUtil.ArtifactInfo> items = ArtifactUtil.findContainingArtifactsWithOutputPaths(file, project, artifacts);
    File ioFile = VfsUtilCore.virtualToIoFile(file);
    for (ArtifactUtil.ArtifactInfo item : items) {
      final Artifact artifact = item.artifact();
      final String outputPath = artifact.getOutputPath();
      if (!StringUtil.isEmpty(outputPath)) {
        PackageFileWorker worker = new PackageFileWorker(ioFile, item.relativeOutputPath(), packIntoArchives);
        LOG.debug(" package to " + outputPath);
        worker.packageFile(outputPath, item.path().getParents());
      }
    }
  }
public static void packageFile(@NotNull VirtualFile file, @NotNull Project project, final Artifact[] artifacts,
                                 final boolean packIntoArchives)