A fast and simple tool to assist in migrating to AndroidX.
A hackathon project inspired by
sd and Dan
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
.xml) files are
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
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.
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
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.
It can then be unistalled by simply calling
cargo uninstall rusty_jetpack.
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.
git ls-filesis 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.
Apache 2.0 - Please read the LICENSE file.