Skip to content
A fast and simple tool to assist in migrating to AndroidX.
Rust Makefile
Branch: master
Clone or download
Latest commit 337495f Oct 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore Initial commit Apr 2, 2019
.pre-commit-config.yaml Add test coverage and reporting of star imports/globs Oct 15, 2019
.secrets.baseline
.travis.yml Add Travis CI file Oct 16, 2019
Cargo.lock Add test coverage and reporting of star imports/globs Oct 15, 2019
Cargo.toml
LICENSE
Makefile Add test coverage and reporting of star imports/globs Oct 15, 2019
README.md
android_arch_mappings.csv Initial commit Apr 2, 2019
android_artifact_mappings.csv
android_databinding_mappings.csv Initial commit Apr 2, 2019
android_support_mappings.csv

README.md

rusty_jetpack

A fast and simple tool to assist in migrating to AndroidX.

Rationale

A hackathon project inspired by sd and Dan Lew's smallscript, rusty_jetpack attempts to make up for some of the pain points experienced with the provided AndroidX migration tool. While it makes no attempt to guarantee post migration compilation or runtime stability, it aims to make iteration as fast as possible when dealing with the ever changing nature of a large code base.

How it works

Relevant (.gradle, gradle.kts, .java, .kt, .pro, .xml) files are found through git ls-files and are distributed evenly to a thread pool. Each thread employs a Matcher that sequentially loads the file into a memory map. The file is then read line by line and matches are replaced according to Android's provided class mapping CSV file. Only files that change are then written back to disk.

Old libraries are also searched for with the provided library mapping file. However, they are not replaced and a notice about the location and what the library should be updated to are printed to STDERR.

Since only explicit mappings are used, it is still recommended to use the provided tool to verify as many cases are found when initial migration is started. rusty_jetpack can then be distributed to developers to significantly decrease adoption and migration time.

Usage

Installation

rusty_jetpack is written in Rust. It was written with rustc version 1.33.0, but can be built with version 1.31.0 or higher. The recommended way to install Rust is from the official installation page.

With Rust installed, installation can be done by cloning the repository and then installing via cargo install. You should then be able to run rusty_jetpack if cargo is part of your $PATH.

cargo install --git https://github.com/Yelp/rusty_jetpack.git

Command line usage

Usage is as simple as calling rusty_jetpack in the root of your Android repository.

Uninstalling

It can then be unistalled by simply calling cargo uninstall rusty_jetpack.

Performance

Note: This is highly unscientific and not a real benchmark of performance. All results were taken on a 2018 MacBook Pro with 32GB of RAM and 12 threads.

App Execution time
Yelp 0.95s
Kickstarter 0.33s

Caveats

  • git ls-files is used to determine which files to operate on. Therefore, this tool will not operate on projects not managed by git and will also ignore submodules and untracked files.
  • Star imports and star proguard rules are not migrated since exact matches are required to map to the correct AndroidX class. Though a warning about them will be printed.
  • Carriage return line feeds (\r\n, CRLF) are not respected and will be replaced with plain line feeds (\n, LF). As such Windows based projects are not fully supported and might experience unexpected changes. See writeln!() for more information.
  • Replacements are done in place and imports are therefore likely to be out of order. Formatters such as Google Java Format and KtLint are better suited to resolve this issue.

License

Apache 2.0 - Please read the LICENSE file.

You can’t perform that action at this time.