On Wed, Dec 3, 2014, at 03:45, Vyacheslav Blinov wrote:
> Thanks for the answer. Having this in mind I'm curious why then make
> support of such thing as including jar inside of aar if this is not the
> right thing to do. Just wonder why this was done at stage of desiging aar
> format?
There is nothing strictly wrong with having a JAR in an AAR. The problem
is in having a *publicly-distributed* JAR in an AAR, where external
developers might be independently depending upon the JAR, perhaps some
other version of the JAR than is in the AAR.
If I publish an AAR, and it made sense for me, with my code
organization, to have some of the AAR's code in JARs within the AAR,
that's perfectly fine... so long as those JARs are not available
separately from the AAR. This is what Xav referred on on this thread as
internal implementation. In this case, it should not matter to the
consumer of the AAR where the code is coming from. To get to Mr.
Ferguson's question ("if they are internal implementation of the AAR
then why not include them in classes.jar?"), that does not matter,
because it is the classes, not the JAR, that is what gets consumed.
However, support-v4 and support-v13 are not part of some internal
implementation of an AAR -- they are publicly-distributed JARs, and in
particular are available as first-class artifacts in their own right.
Packaging one of *those* in an AAR is bad form, for the very reasons
this thread gets into. And, to return to Mr. Ferguson's question,
whether classes like android.support.v4.view.ViewPager are in
classes.jar or android-support-v4.jar will not affect consumers of the
AAR containing those classes, as they will be equally screwed in either
case.
A simple (and simplistic) way to look at it is: everything inside an AAR
that *you* publish should be *written by you*. The reality is more
nuanced than that, of course, but IMHO it's not a bad basic rule of
thumb.
--
Mark Murphy (a Commons Guy)
http://commonsware.com |
http://github.com/commonsguy
http://commonsware.com/blog |
http://twitter.com/commonsguy
_The Busy Coder's Guide to Android Development_ Version 6.2: Lollipop!