You can create a source folder that's used by different flavors.
For example create src/commonAB/java/.../FooClass.java and put this in your
build.gradle:
android {
sourceSet {
flavorA {
java.srcDir 'src/commonAB/java'
}
flavorB {
java.srcDir 'src/commonAB/java'
}
}
}
It works here because srcDir(String path) adds a new path to the existing
paths for the "java" source set.
On Sun, Jul 13, 2014 at 6:13 AM, Hannes Dorfmann <[email protected]>
wrote:
> Hi,
> does support for "linking / including code" of one product flavor to
> another flavor already exist?
>
>
> Correct me if Im wrong, but as far as I know I can not have a FooClass in
> main and a FooClass in a product flavor.
>
> So I have to remove the FooClass from main and move it in all of my
> product flavors, right?
>
> For instance, I have 3 product flavors:
>
> - FlavorA
> - FooClass
> - ConfigClass
>
> - FlavorB
> - FooClass (will be exactly the same code as in FlavorA, moreover
> it would be a copy of Flavor A's FooClass)
> - ConfigClass
>
> - FlavorC
> - FooClass
> - ConfigClass
>
> So flavor C has its own FooClass and ConfigClass. Also flavor A has its
> own FooClass and ConfigClass. But flavor B should use the same FooClass as
> flavor A and only provide a own ConfigClass. Is something like that
> possible?
>
> I want to avoid that I have duplicated code in my project. In the scenario
> described above I would like that each flavor has its own ConfigClass, but
> I also would like to avoid that I have to provide for Flavor A and Flavor B
> a FooClass. In this scenario The FooClass of Flavor B would be exactly the
> same code of Flavor A's FooClass (it's a copy, so thats what I mean with
> "duplicate" code).
>
> Is it possible to specify something like "linking" code files from one
> flavor to another? Or does something like an "include" or "extends" for
> flavors exist, that I could say, Flavor B extends/includes all classes of
> Flavor A so that in Flavor B I would only provide a ConfigClass that would
> override Flavor A's ConfigClass?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "adt-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com
Please do not send me questions directly. Thanks!
--
You received this message because you are subscribed to the Google Groups
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.