-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix package names and add support for incremental compilation #1539
Conversation
Oops, this PR should be against lib_reorg. |
It is now against current master. Hence, it can be merged independendly. BTW: Package names in comments were not renamed to keep the commit small. |
Changing all this files will make it very hard to other pull requests and branches. |
If we don't want to go directly to AndroidX support using jettifyier (I've another branch in preparation for it), we have to rename at least all packages using annotations. This maybe only affect a smaller subset of files. I'll change this PR later. Anyway, renaming packages to fulfill the package naming convention does not break the business logic. Maybe we should consider this after narrowing down the number of open PRs and do this in smaller PRs. |
There is no way around fixing the package names. After migration to AndroidX, the same errors occur:
Tomorrow, I'll try to just fix the relevant packages: |
The new PR #1598 is much smaller and does not rename the packages, which is still necessary in the future. |
Instead of changing 1200+ files and creating merge conflicts with every feature branch out there, can we not try any of these alternative approaches:
|
Please can you provide a link to the unit tests you found? At the other side, we may also have to patch AGP and any future version of the databinding library, if we need other features in the future or security fixes. IMHO, not a good idea. The main cause of the problem is the incorrect package naming. Hence, I would not call it a regression. Instead, it was an unsupported feature in v1.
A shadow jar is one big jar containing all packages/classes unpacked from their original library jars. Hence, not available during databinding annotation.
Yes, this mapping is mainly useful for incremental obfuscation and not available during databinding/annotation. I tried a 4th approach: creating lowercase package naming folders and migrating the POJO classes incrementally. I've not finished this yet but it worked for a few classes, even in Windows build environment. But it looks not very nice having to directories with the same name but different casing. If I remember correctly, I even had to fix the package names after migration to androidx. I highly recommend combining both steps and maybe combine it further with the extraction of all hard-coded strings into resource strings. Regarding to potential merge conflicts with feature branches: The features can either be merged before or fixed afterwards at the time they get integrated. Many features (PRs) laying around for months or years and maybe never get merged. AND: I'm willing to patch these feature branch (all or those CI does not complain) with a script to fix potential merge conflicts, if that finally advances migration and further development. |
Here is the mixed case data-binding test I saw: https://android.googlesource.com/platform/frameworks/data-binding/+/897cf5a29761b556e392382086a29355a2841022/integration-tests/ViewBindingTestApp/app/src/androidTest/java/com/example/viewbinding/WeirdCasingTest.java As far as I know mixed case package names are legal in java but very rarely used as the convention is to always lower-case them. So there is a 5th way to solve this which I have put together and looks like it works. It uses a gradle pre-processor to remap the package names to lower case in the java source and xml files during compilation. This allows The pre-processing takes about 1 second but I still need to do some more work to make sure it properly injects in to the build process with regards to caching, ide ui etc. The AndroidManifest also needs slightly different handling. I'll push something up soon once I've refined it a bit further. |
Cool. I've searched for a long time for such a solution.
That would be really interesting. It would be great if I can be involved in testing. |
This PR affects a lot of files because it changes package names to all lowercase (see Naming a Package). The app works still very well.
If we would upgrade the Android Gradle plugin directly to 3.6.x or higher and enable
android.useAndroidX=true
andandroid.enableJetifier=true
ingradle.properties
, we would not have to apply these changes. IMHO, it is a good idea to fix the package names.