Exports group's target "data" property

Change was discussed here:
https://groups.google.com/a/chromium.org/g/gn-dev/c/Cd7hGiVW5xs

Change-Id: I9e79ed2e507398a8eb56f9a344ac4a972fbdcbdf
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/21880
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: David Turner <digit@google.com>
Commit-Queue: David Turner <digit@google.com>
diff --git a/src/gn/desc_builder.cc b/src/gn/desc_builder.cc
index 8c6d897..1823520 100644
--- a/src/gn/desc_builder.cc
+++ b/src/gn/desc_builder.cc
@@ -391,6 +391,10 @@
       }
     }
 
+    if (what(variables::kData) && !target_->data().empty())
+      res->SetWithoutPathExpansion(variables::kData,
+                                   RenderValue(target_->data()));
+
     if (what(variables::kSources) && !target_->sources().empty())
       res->SetWithoutPathExpansion(variables::kSources,
                                    RenderValue(target_->sources()));
diff --git a/src/gn/json_project_writer.h b/src/gn/json_project_writer.h
index 0557689..63549a9 100644
--- a/src/gn/json_project_writer.h
+++ b/src/gn/json_project_writer.h
@@ -29,6 +29,7 @@
   FRIEND_TEST_ALL_PREFIXES(JSONWriter, ForEachWithResponseFile);
   FRIEND_TEST_ALL_PREFIXES(JSONWriter, RustTarget);
   FRIEND_TEST_ALL_PREFIXES(JSONWriter, FilterTargetsWithDataDeps);
+  FRIEND_TEST_ALL_PREFIXES(JSONWriter, GroupWithData);
 
   static bool FilterTargets(const BuildSettings* build_settings,
                             std::vector<const Target*>& all_targets,
diff --git a/src/gn/json_project_writer_unittest.cc b/src/gn/json_project_writer_unittest.cc
index a050b09..6c43cc7 100644
--- a/src/gn/json_project_writer_unittest.cc
+++ b/src/gn/json_project_writer_unittest.cc
@@ -835,3 +835,48 @@
   EXPECT_GT(labels_all.count(Label(SourceDir("//foo/"), "b")), 0u);
   EXPECT_GT(labels_all.count(Label(SourceDir("//foo/"), "c")), 0u);
 }
+
+TEST_F(JSONWriter, GroupWithData) {
+  Err err;
+  TestWithScope setup;
+
+  Target target(setup.settings(), Label(SourceDir("//foo/"), "docs"));
+  target.set_output_type(Target::GROUP);
+  target.data().push_back("README.md");
+  target.data().push_back("docs/help.txt");
+  target.SetToolchain(setup.toolchain());
+  ASSERT_TRUE(target.OnResolved(&err));
+
+  std::vector<const Target*> targets = {&target};
+  std::string out =
+      JSONProjectWriter::RenderJSON(setup.build_settings(), targets);
+#if defined(OS_WIN)
+  base::ReplaceSubstringsAfterOffset(&out, 0, "\r\n", "\n");
+#endif
+  const char expected_json[] =
+      R"_({
+   "build_settings": {
+      "build_dir": "//out/Debug/",
+      "default_toolchain": "//toolchain:default",
+      "gen_input_files": [  ],
+      "root_path": ""
+   },
+   "targets": {
+      "//foo:docs()": {
+         "data": [ "README.md", "docs/help.txt" ],
+         "deps": [  ],
+         "metadata": {
+
+         },
+         "public": "*",
+         "testonly": false,
+         "toolchain": "",
+         "type": "group",
+         "visibility": [  ]
+      }
+   },
+   "toolchains": {
+)_";
+
+  EXPECT_TRUE(out.starts_with(expected_json)) << out;
+}