@NotNull
  private DataNode<ModuleData> createModuleData(
      @NotNull DataNode<ProjectData> projectInfoDataNode,
      @NotNull String targetName,
      @NotNull TargetInfo targetInfo,
      @NotNull PantsCompileOptionsExecutor executor) {
    final Collection<SourceRoot> roots = targetInfo.getRoots();
    final PantsSourceType rootType = targetInfo.getSourcesType();
    final String moduleName = PantsUtil.getCanonicalModuleName(targetName);

    final ModuleData moduleData =
        new ModuleData(
            targetName,
            PantsConstants.SYSTEM_ID,
            ModuleTypeId.JAVA_MODULE,
            moduleName,
            projectInfoDataNode.getData().getIdeProjectFileDirectoryPath() + "/" + moduleName,
            new File(executor.getWorkingDir(), targetName).getAbsolutePath());

    final DataNode<ModuleData> moduleDataNode =
        projectInfoDataNode.createChild(ProjectKeys.MODULE, moduleData);

    final TargetMetadata metadata = new TargetMetadata(PantsConstants.SYSTEM_ID, moduleName);
    metadata.setTargetAddresses(
        ContainerUtil.map(
            targetInfo.getAddressInfos(),
            new Function<TargetAddressInfo, String>() {
              @Override
              public String fun(TargetAddressInfo info) {
                return info.getTargetAddress();
              }
            }));
    metadata.setLibraryExcludes(targetInfo.getExcludes());
    moduleDataNode.createChild(TargetMetadata.KEY, metadata);

    return moduleDataNode;
  }