blob: 73849fa4b2d311f425a0fb50da77a3eb29ecc0f8 [file] [log] [blame]
Yigit Boyarab52dda2020-07-16 14:54:56 -07001#!/bin/bash
2# Helper script to kick-off a playground project setup.
3# This is intended to be used when we create a new Playground project or update existing ones
4# if we do structural changes in Playground's setup.
5
6function relativize() {
Yigit Boyar0f75ad82021-05-31 17:10:27 -07007 python -c "import os.path; print(os.path.relpath('$1', '$2'))"
Yigit Boyarab52dda2020-07-16 14:54:56 -07008}
9
10PLAYGROUND_REL_PATH=$(dirname $0)
11WORKING_DIR=$(pwd)
12
13# create gradle symlinks
14rm -rf gradle
15ln -s "${PLAYGROUND_REL_PATH}/gradle" gradle
16rm -rf gradlew
17ln -s "${PLAYGROUND_REL_PATH}/gradlew" gradlew
18rm -rf gradlew.bat
19ln -s "${PLAYGROUND_REL_PATH}/gradlew.bat" gradlew.bat
Yigit Boyara4abb182020-07-31 21:44:05 -070020rm -rf gradle.properties
21ln -s "${PLAYGROUND_REL_PATH}/androidx-shared.properties" gradle.properties
Jeff Gaston5633a812021-08-13 11:34:58 -040022rm -rf buildSrc
23ln -s "${PLAYGROUND_REL_PATH}/../buildSrc" buildSrc
Yigit Boyarab52dda2020-07-16 14:54:56 -070024
25ANDROIDX_IDEA_DIR="${PLAYGROUND_REL_PATH}/../.idea"
26
27# cleanup .idea, we'll re-create it
28rm -rf .idea
29mkdir .idea
30
31# create idea directories first .idea config directories that are tracked in git
32git ls-tree -d -r HEAD --name-only --full-name $ANDROIDX_IDEA_DIR|xargs mkdir -p
33
34# get a list of all .idea files that are in git tree
35# we excluse vcs as it is used for multiple repo setup which we don't need in playground
36TRACKED_IDEA_FILES=( $(git ls-tree -r HEAD --name-only --full-name $ANDROIDX_IDEA_DIR| grep -v vcs| grep -v Compose) )
37
38# create a symlink for each one of them
39for IDEA_CONFIG_FILE in "${TRACKED_IDEA_FILES[@]}"
40do
41 # path to the actual .idea config file
42 ORIGINAL_FILE="$PLAYGROUND_REL_PATH/../$IDEA_CONFIG_FILE"
43 TARGET_DIR=$(dirname $IDEA_CONFIG_FILE)
44 # relativize it wrt to the file we'll create
45 REL_PATH=$(relativize $ORIGINAL_FILE $TARGET_DIR )
46 # symlink to the original idea file
47 ln -s $REL_PATH $IDEA_CONFIG_FILE
48 # forse add the file to git
49 git add -f $IDEA_CONFIG_FILE
Jeff Gaston5633a812021-08-13 11:34:58 -040050done