blob: 99fb0988bc48fcd861f0f91693fc34dcc6535c21 [file] [log] [blame] [view]
Yigit Boyara755f332020-05-30 19:14:46 -07001# Playground Setup for AndroidX Projects
2
3AndroidX is a fairly large project with 300+ modules which makes it a
4very resource heavy project for local development.
5
6Playground setup allows sub projects to have an additional settings.gradle
7file that can be run independent of the main project.
8It also allows using external resources for artifacts such that just checking
9out the AndroidX git repository is enough without the prebuilt repositories
10that are needed by the main AndroidX project.
11
12These project setups are only meant to be used for local development and
13all CI tasks run using the root AndroidX project.
14
15## How it works?
16A playground project needs a `settings.gradle` file that applies
17`playground-common/playground-settings.gradle` which provides functionality
18to pull select projects from AndroidX.
19
20To share as much common configuration as possible, it is also recommended
Yigit Boyarab52dda2020-07-16 14:54:56 -070021to symlink some common files like `gradle` and `.idea` configuration.
Yigit Boyara755f332020-05-30 19:14:46 -070022
Yigit Boyarab52dda2020-07-16 14:54:56 -070023To do that, execute "setup-playground.sh" comamnd in your playground directory.
Yigit Boyara755f332020-05-30 19:14:46 -070024```
Yigit Boyarab52dda2020-07-16 14:54:56 -070025cd room;
26../playground-common/setup-playground.sh
Yigit Boyara755f332020-05-30 19:14:46 -070027```
Yigit Boyarab52dda2020-07-16 14:54:56 -070028This script will create symbolic links for `gradle` and `.idea` files that are committed
29to the git repository. It also force adds the `.idea` files to the git repository because
30by default any nested .idea folder is ignored from git.
Yigit Boyara755f332020-05-30 19:14:46 -070031
32The `playground-settings.gradle` file sets a pre-defined build file (`playground-build.gradle`)
33for the root project and also provides `includeProject` and `selectProjectsFromAndroidX`
34methods.
35
36The custom `settings.gradle` file should first call `setupPlayground(this, "..")` to
37run the main configuration. Here, the first argument is the `script` object itself and
38the second argument is the relative path to the main AndroidX project.
39
40After running `setupPlayground`, it can either include projects via `includeProject`
41method or filter projects from the main AndroidX settings gradle file using the
42`selectProjectsFromAndroidX` method.
43
Yigit Boyara4abb182020-07-31 21:44:05 -070044### Properties
45When a `gradle.properties` file shows up under a sub project, main AndroidX build ends up
46reading it. For this reason, we can only keep a minimal `gradle.properties` file in these
47sub modules that also support playground setup.
48
49We cannot avoid creating `gradle.properties` as certain properties (e.g. `useAndroidX`) are
50read at configuration time and we cannot set it dynamically.
51
52Properties that will be set dynamically are kept in `playground.properties` file while
53shared properties are kept in `androidx-shared.properties` file.
54The dynamic properties are read in the `playground-include-settings.gradle` file and set
55on each project.
56
57There is a `VerifyPlaygroundGradlePropertiesTask` task that validates the contents of
58`androidx-shared.properties` file as part of the main AndroidX build.
Yigit Boyara755f332020-05-30 19:14:46 -070059### Optional Dependencies
60Even though sub-projects usually declare exact coordinates for their dependencies,
61for tests, it is a common practice to declare `project` dependencies. To avoid needing
62to include all of those projects to make the build file work, `AndroidXPlaygroundRootPlugin`
63adds a `projectOrArtifact` method to each sub project. This function can be used instead of
64`project` to declare optional project dependencies. This function will return the
65`project` if it exists or default to its latest artifact if it doesn't.
66
67Note that range artifacts are not allowed in the main AndroidX build so when the sub
68project is opened as part of the main AndroidX build, `projectOrArtifact` always resolves
69to the `project`. In playground projects, it always resolves to the latest `SNAPSHOT`
70artifact that is included in the playground build.