private String ensureCorrectOutput(ModuleChunk chunk,
                                     OutputItem item,
                                     Map<T, String> generationOutputs,
                                     String compilerOutput,
                                     @NotNull T srcTarget) throws IOException {
    if (chunk.getModules().size() > 1 && !srcTarget.equals(representativeTarget(generationOutputs))) {
      File output = new File(item.outputPath);

      String srcTargetOutput = generationOutputs.get(srcTarget);
      if (srcTargetOutput == null) {
        LOG.info("No output for " + srcTarget + "; outputs=" + generationOutputs + "; targets = " + getTargets(chunk));
        return item.outputPath;
      }

      //todo honor package prefixes
      File correctRoot = new File(srcTargetOutput);
      File correctOutput = new File(correctRoot, Objects.requireNonNull(FileUtil.getRelativePath(new File(compilerOutput), output)));

      FileUtil.rename(output, correctOutput);
      return correctOutput.getPath();
    }
    return item.outputPath;
  }
private String ensureCorrectOutput(ModuleChunk chunk,
                                     OutputItem item,
                                     Map<T, String> generationOutputs,
                                     String compilerOutput,
                                     @NotNull T srcTarget)