Snap for 5400754 from 64e8981657e42ad20c0bbf406315b7fc4c94c922 to studio-3.4-release

Change-Id: Ic3e7db72ed650a8daeec8d1fbe9ddf3bc6636565
tree: 41022da73d9203445d18d6157c53308df0a46d2b
  1. .gitignore
  2. Android.mk
  3. BUILD.bazel
  4. CleanSpec.mk
  5. README.md
  6. baseLibrary/
  7. baseLibrarySupport/
  8. build.gradle
  9. buildForGradlePlugin.sh
  10. compilationTests/
  11. compiler/
  12. compilerCommon/
  13. databinding.properties
  14. developmentPlugins/
  15. exec/
  16. extensions-support/
  17. extensions/
  18. gradle.properties
  19. gradle/
  20. gradlePlugin/
  21. gradlew
  22. gradlew.bat
  23. init.sh
  24. integration-tests-support/
  25. integration-tests/
  26. localize.sh
  27. prebuilds/
  28. proguard.cfg
  29. propLoader.gradle
  30. run_compilation_tests.sh
  31. samples/
  32. settings.gradle
  33. update_googe3.sh
README.md

Setting up

run the init.sh script in {src}/tools/data-binding. This will make the extensions and integration tests runnable directly.

cd {src}/tools/data-binding && ./init.sh

To match the sdk used by android gradle plugin, this script sets the local properties to use the checked in sdk. This might conflict with your local sdk or Android Studio setup. Unfortunately, Android Studio does not support multiple SDKs so you need to live with that. (and your local sdk might just work fine if tools did not upgrade to an unreleased version. YMMV)

Building Artifacts

Compile Time Artifacts

They are compiled as part of the Android Gradle Plugin when they are shipped. Under {src}/tools, you can run tasks for

./gradlew :dB:<TASK_NAME>

It also works independently, so you can just run

cd {src}/data-binding && ./gradlew :dB:comp:test

It also compiles with BAZEL :). It will take ages when you run it for the first time, go for a coffee. Then it will be faster and more reliable than gradle.

bazel build //tools/data-binding/...

Runtime Artifacts (extensions)

This project is compiled using android gradle plugin or bazel to compile from gradle (under {src}/tools)

./gradlew :dB:buildDataBindingRuntimeArtifacts

to compile from bazel run

bazel build //tools/data-binding:runtimeLibraries

You can also compile them from command line if you've run init.sh you must first compile the android gradle plugin:

cd {src}/tools && ./gradlew :pL
cd {src}/tools/data-binding && ./gradlew build

Due to the androidX change, we still keep the libraries in the old namespace. They are under extensions-support so any change in extensions should be ported to extensions-support.

Running in the IDE

Compile Time Code

The main project still has proper gradle configuration so you can open it in Intellij

Runtime Libraries (a.k.a extensions)

First, compile the local gradle plugin and also make sure you've run init.gradle

cd {src}/tools && ./gradlew :pL

The run the init script:

cd {src}/tools/data-binding && ./init.sh

Now you can open extensions in Android Studio.

Running Android Gradle Plugin Data Binding Tests

Some of data binding tests are only in AGP. To run them:

gw :base:build-system:integration-test:databinding:te

Running Integration Tests

These are run by gradle build.

gw :base:build-system:integration-test:application:cIT -D:base:build-system:integration-test:application:connectedIntegrationTest.single=DataBinding\* We also compile them in bazel builds:

bazel test //tools/base/build-system/integration-test/databinding:tests --test_output=errors --action_env="GTEST_COLOR=1"

You can pass --test_filter=<test class name>\* to filter certain tests

If you did run ./init.sh, you can open integration tests in Android Studio.

Due to the AndroidX change, we still keep old integration tests that use the android.databinding package. They live in integration-tests-support folder and are an exact copy of what we had at the time of the migration.

Making Build File Changes

There are multiple ways data binding is compiled so build file changes are a bit tricky.

If you add a new dependency, you should update: {src}/tools/data-binding/BUILD.bazel compiler/db-compiler.iml and compilerCommon/db-compilerCommon.iml

Manually editing them and then running bazel to test is the most reliable approach. If you break it, presubmit will catch. Bazel uses these iml files while compiling. You may need to modify the .idea folder inside {src}/tools if your dependency does not already exist for some other project.

After changing the iml files, you should run bazel run //tools/base/bazel:iml_to_build to re-generate the related bazel files. (if you forget, presubmit will probably catch it)

If you add a new integration test app, update {src}/tools/base/build-system/integration-test/src/test/java/com/android/build/gradle/integration/databinding/DataBindingIntegrationTestAppsTest.java to include it.

Misc

working on compiler

If you are working on compiler but testing via integration tests, run: ./gradlew :publishAndroidGradleLocal //(in tools/base) then run your integration test.

all gradle tests at once

gw :base:build-system:integration-test:databinding:test :base:build-system:integration-test:application:cIT -D:base:build-system:integration-test:application:connectedIntegrationTest.single=DataBinding*

generating online docs for runtime libs

cd extensions && gw :generateDocs -Pandroid.injected.invoked.from.ide=true --info -Ponline=true -PincludeDoclava

// remove online parameter to get offline docs // we pass invoked from ide to enable default setup