Add script to copy studio configruation to playground

This CL adds a playground script that will copy the .idea configuration
from the main androidx project. I've also added .idea for work, room and playground.

Bug: n/a
Test: ./gradlew studio
Change-Id: I082aff26a64b6dc2a6d6fc21db91687aaf2d10ca
diff --git a/playground-common/README.md b/playground-common/README.md
index 063dfb6..59bd21f 100644
--- a/playground-common/README.md
+++ b/playground-common/README.md
@@ -18,13 +18,16 @@
 to pull select projects from AndroidX.
 
 To share as much common configuration as possible, it is also recommended
-to symlink to the following files of `playground-common`:
+to symlink some common files like `gradle` and `.idea` configuration.
 
+To do that, execute "setup-playground.sh" comamnd in your playground directory.
 ```
-gradle -> playground-common/gradle
-gradlew -> playground-common/gradlew
-gradlew.bat -> playground-common/gradlew.bat
+cd room;
+../playground-common/setup-playground.sh
 ```
+This script will create symbolic links for `gradle` and `.idea` files that are committed
+to the git repository. It also force adds the `.idea` files to the git repository because
+by default any nested .idea folder is ignored from git.
 
 The `playground-settings.gradle` file sets a pre-defined build file (`playground-build.gradle`)
 for the root project and also provides `includeProject` and `selectProjectsFromAndroidX`
diff --git a/playground-common/setup-playground.sh b/playground-common/setup-playground.sh
new file mode 100755
index 0000000..650ae3d
--- /dev/null
+++ b/playground-common/setup-playground.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Helper script to kick-off a playground project setup.
+# This is intended to be used when we create a new Playground project or update existing ones
+# if we do structural changes in Playground's setup.
+
+function relativize() {
+    python -c "import os.path; print os.path.relpath('$1', '$2')"
+}
+
+PLAYGROUND_REL_PATH=$(dirname $0)
+WORKING_DIR=$(pwd)
+
+# create gradle symlinks
+rm -rf gradle
+ln -s "${PLAYGROUND_REL_PATH}/gradle" gradle
+rm -rf gradlew
+ln -s "${PLAYGROUND_REL_PATH}/gradlew" gradlew
+rm -rf gradlew.bat
+ln -s "${PLAYGROUND_REL_PATH}/gradlew.bat" gradlew.bat
+
+ANDROIDX_IDEA_DIR="${PLAYGROUND_REL_PATH}/../.idea"
+
+# cleanup .idea, we'll re-create it
+rm -rf .idea
+mkdir .idea
+
+# create idea directories first .idea config directories that are tracked in git
+git ls-tree -d -r HEAD --name-only --full-name $ANDROIDX_IDEA_DIR|xargs mkdir -p
+
+# get a list of all .idea files that are in git tree
+# we excluse vcs as it is used for multiple repo setup which we don't need in playground
+TRACKED_IDEA_FILES=( $(git ls-tree -r HEAD --name-only --full-name $ANDROIDX_IDEA_DIR| grep -v vcs| grep -v Compose) )
+
+# create a symlink for each one of them
+for IDEA_CONFIG_FILE in "${TRACKED_IDEA_FILES[@]}"
+do
+    # path to the actual .idea config file
+    ORIGINAL_FILE="$PLAYGROUND_REL_PATH/../$IDEA_CONFIG_FILE"
+    TARGET_DIR=$(dirname $IDEA_CONFIG_FILE)
+    # relativize it wrt to the file we'll create
+    REL_PATH=$(relativize $ORIGINAL_FILE $TARGET_DIR )
+    # symlink to the original idea file
+    ln -s $REL_PATH $IDEA_CONFIG_FILE
+    # forse add the file to git
+    git add -f $IDEA_CONFIG_FILE
+done
\ No newline at end of file
diff --git a/playground/.idea/codeStyles b/playground/.idea/codeStyles
deleted file mode 100644
index e2e415d..0000000
--- a/playground/.idea/codeStyles
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectCodeStyleConfiguration">
-    <code_scheme name="Project" version="173">
-      <codeStyleSettings language="XML">
-        <indentOptions>
-          <option name="CONTINUATION_INDENT_SIZE" value="4" />
-        </indentOptions>
-        <arrangement>
-          <rules>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>xmlns:android</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>^$</XML_NAMESPACE>
-                  </AND>
-                </match>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>xmlns:.*</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>^$</XML_NAMESPACE>
-                  </AND>
-                </match>
-                <order>BY_NAME</order>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>.*:id</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                  </AND>
-                </match>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>.*:name</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                  </AND>
-                </match>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>name</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>^$</XML_NAMESPACE>
-                  </AND>
-                </match>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>style</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>^$</XML_NAMESPACE>
-                  </AND>
-                </match>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>.*</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>^$</XML_NAMESPACE>
-                  </AND>
-                </match>
-                <order>BY_NAME</order>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>.*</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                  </AND>
-                </match>
-                <order>ANDROID_ATTRIBUTE_ORDER</order>
-              </rule>
-            </section>
-            <section>
-              <rule>
-                <match>
-                  <AND>
-                    <NAME>.*</NAME>
-                    <XML_ATTRIBUTE />
-                    <XML_NAMESPACE>.*</XML_NAMESPACE>
-                  </AND>
-                </match>
-                <order>BY_NAME</order>
-              </rule>
-            </section>
-          </rules>
-        </arrangement>
-      </codeStyleSettings>
-    </code_scheme>
-  </component>
-</project>
\ No newline at end of file
diff --git a/playground/.idea/codeStyles/Project.xml b/playground/.idea/codeStyles/Project.xml
new file mode 120000
index 0000000..b52b28c
--- /dev/null
+++ b/playground/.idea/codeStyles/Project.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/Project.xml
\ No newline at end of file
diff --git a/playground/.idea/codeStyles/codeStyleConfig.xml b/playground/.idea/codeStyles/codeStyleConfig.xml
new file mode 120000
index 0000000..19c4848
--- /dev/null
+++ b/playground/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/codeStyleConfig.xml
\ No newline at end of file
diff --git a/playground/.idea/copyright/AndroidCopyright.xml b/playground/.idea/copyright/AndroidCopyright.xml
new file mode 120000
index 0000000..afbbd04
--- /dev/null
+++ b/playground/.idea/copyright/AndroidCopyright.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/AndroidCopyright.xml
\ No newline at end of file
diff --git a/playground/.idea/copyright/profiles_settings.xml b/playground/.idea/copyright/profiles_settings.xml
new file mode 120000
index 0000000..5996ccd
--- /dev/null
+++ b/playground/.idea/copyright/profiles_settings.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/profiles_settings.xml
\ No newline at end of file
diff --git a/playground/.idea/inspectionProfiles/Project_Default.xml b/playground/.idea/inspectionProfiles/Project_Default.xml
new file mode 120000
index 0000000..a7481f4
--- /dev/null
+++ b/playground/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1 @@
+../../../.idea/inspectionProfiles/Project_Default.xml
\ No newline at end of file
diff --git a/playground/.idea/scopes/Ignore_API_Files.xml b/playground/.idea/scopes/Ignore_API_Files.xml
new file mode 120000
index 0000000..3361ee1
--- /dev/null
+++ b/playground/.idea/scopes/Ignore_API_Files.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/Ignore_API_Files.xml
\ No newline at end of file
diff --git a/playground/.idea/scopes/buildSrc.xml b/playground/.idea/scopes/buildSrc.xml
new file mode 120000
index 0000000..25b7d3b
--- /dev/null
+++ b/playground/.idea/scopes/buildSrc.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/buildSrc.xml
\ No newline at end of file
diff --git a/room/.idea/codeStyles/Project.xml b/room/.idea/codeStyles/Project.xml
new file mode 120000
index 0000000..b52b28c
--- /dev/null
+++ b/room/.idea/codeStyles/Project.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/Project.xml
\ No newline at end of file
diff --git a/room/.idea/codeStyles/codeStyleConfig.xml b/room/.idea/codeStyles/codeStyleConfig.xml
new file mode 120000
index 0000000..19c4848
--- /dev/null
+++ b/room/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/codeStyleConfig.xml
\ No newline at end of file
diff --git a/room/.idea/copyright/AndroidCopyright.xml b/room/.idea/copyright/AndroidCopyright.xml
new file mode 120000
index 0000000..afbbd04
--- /dev/null
+++ b/room/.idea/copyright/AndroidCopyright.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/AndroidCopyright.xml
\ No newline at end of file
diff --git a/room/.idea/copyright/profiles_settings.xml b/room/.idea/copyright/profiles_settings.xml
new file mode 120000
index 0000000..5996ccd
--- /dev/null
+++ b/room/.idea/copyright/profiles_settings.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/profiles_settings.xml
\ No newline at end of file
diff --git a/room/.idea/inspectionProfiles/Project_Default.xml b/room/.idea/inspectionProfiles/Project_Default.xml
new file mode 120000
index 0000000..a7481f4
--- /dev/null
+++ b/room/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1 @@
+../../../.idea/inspectionProfiles/Project_Default.xml
\ No newline at end of file
diff --git a/room/.idea/scopes/Ignore_API_Files.xml b/room/.idea/scopes/Ignore_API_Files.xml
new file mode 120000
index 0000000..3361ee1
--- /dev/null
+++ b/room/.idea/scopes/Ignore_API_Files.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/Ignore_API_Files.xml
\ No newline at end of file
diff --git a/room/.idea/scopes/buildSrc.xml b/room/.idea/scopes/buildSrc.xml
new file mode 120000
index 0000000..25b7d3b
--- /dev/null
+++ b/room/.idea/scopes/buildSrc.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/buildSrc.xml
\ No newline at end of file
diff --git a/work/.idea/codeStyles/Project.xml b/work/.idea/codeStyles/Project.xml
new file mode 120000
index 0000000..b52b28c
--- /dev/null
+++ b/work/.idea/codeStyles/Project.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/Project.xml
\ No newline at end of file
diff --git a/work/.idea/codeStyles/codeStyleConfig.xml b/work/.idea/codeStyles/codeStyleConfig.xml
new file mode 120000
index 0000000..19c4848
--- /dev/null
+++ b/work/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1 @@
+../../../.idea/codeStyles/codeStyleConfig.xml
\ No newline at end of file
diff --git a/work/.idea/copyright/AndroidCopyright.xml b/work/.idea/copyright/AndroidCopyright.xml
new file mode 120000
index 0000000..afbbd04
--- /dev/null
+++ b/work/.idea/copyright/AndroidCopyright.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/AndroidCopyright.xml
\ No newline at end of file
diff --git a/work/.idea/copyright/profiles_settings.xml b/work/.idea/copyright/profiles_settings.xml
new file mode 120000
index 0000000..5996ccd
--- /dev/null
+++ b/work/.idea/copyright/profiles_settings.xml
@@ -0,0 +1 @@
+../../../.idea/copyright/profiles_settings.xml
\ No newline at end of file
diff --git a/work/.idea/inspectionProfiles/Project_Default.xml b/work/.idea/inspectionProfiles/Project_Default.xml
new file mode 120000
index 0000000..a7481f4
--- /dev/null
+++ b/work/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1 @@
+../../../.idea/inspectionProfiles/Project_Default.xml
\ No newline at end of file
diff --git a/work/.idea/scopes/Ignore_API_Files.xml b/work/.idea/scopes/Ignore_API_Files.xml
new file mode 120000
index 0000000..3361ee1
--- /dev/null
+++ b/work/.idea/scopes/Ignore_API_Files.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/Ignore_API_Files.xml
\ No newline at end of file
diff --git a/work/.idea/scopes/buildSrc.xml b/work/.idea/scopes/buildSrc.xml
new file mode 120000
index 0000000..25b7d3b
--- /dev/null
+++ b/work/.idea/scopes/buildSrc.xml
@@ -0,0 +1 @@
+../../../.idea/scopes/buildSrc.xml
\ No newline at end of file