Submitting a patch to AOSP
Google has the AOSP (Android Open Source Project) where you can find most of the source code regarding the Android ecosystem. Gradle Plugins, R8/D8, Lint and many other things are located there.
Submitting a patch is easier than expected. Last year, I’ve submitted my first patch — https://android-review.googlesource.com/c/platform/tools/base/+/783316
So let’s get started and see how we can set up our machine so we can contribute.
We need to authenticate our self with Google. Just go with the instructions on this link —- https://android.googlesource.com/new-password — your Google account will be used and you will end up with a Git Cookie for authentication.
This only needs to be done once per machine.
We need to use repo. According to Google,
repo is a tool that makes it easier to work with Git in the context of Android. There’s more information here.
So, let’s start by installing repo and making it executable:
wget -q https://storage.googleapis.com/git-repo-downloads/repo \
chmod a+x ~/bash/repo
If you’re on Mac you can also install it via brew:
brew install repo
Now, we can use repo to initialize and checkout our desired branch — which will take a while:
repo init -u https://android.googlesource.com/platform/manifest \
repo sync -c -j4 -q
Once everything is done, you can open the project where you want to contribute to with IntelliJ. Everything should be checked in as IntelliJ projects so there’s no need to use the build.gradle files for opening them.
Now it’s up to you and you can start tinkering around. After you have made your changes you can use repo to sync and create your first contribution:
repo start <branch_name> .
git add -A
git commit -s
git commit -s will open your default editor where you can place your title and description of your commit. An example would look like this:
short description on first line
more detailed description of your patch,
which is likely to take up multiple lines
Once you’ve entered your commit message you can upload your changes with
repo upload. It will create the patch and now you can request reviews.
Tor reviewed my contribution and gave me some feedback. In the end, he made some changes around it and in October 2018 it landed and is now being shipped to everyone who is using Lint with the Android Gradle Plugin 3.4.x or higher — https://android.googlesource.com/platform/tools/base/+/6f7b42cb93dd56d17a28f7a979b854f55c850b37