What I just did in a similar situation, is use additional source folders,
thus avoiding excessive use of libraries.
I have two versions of the same app: one for Market and one for another
store.
My source directory structure has:
src
package org.kman.FooBar.licensing
SomeClass.java
src-market
package org.kman.FooBar.licensing
SomeClassFactory.java
SomeClass_Market.java
src-another-store
package org.kman.FooBar.licensing
SomeClassFactory.java
SomeClass_AnotherStore.java
There are two versions of the same class, SomeClassFactory, in either
additional source folder, under the same name, in the same package, and so
I can just do "SomeClassFactory.create()" in the main body of application
code, without worrying about which one it is. The implementation of those
factories is different, each instantiating its own subclass of SomeClass -
the one for Market or for AnotherStore.
Now, the bulid setup:
1) In Eclipse: src-market and src-another-store are added as additional
source folders in the application project. Then src-another-store has an
exclude filter matching everything: "**/*.*".
This way, both folders are accesible for browsing / editing / source
control, but only the sources inside "src-market" are compiled.
2) For command line builds: I have a modified build.xml, and use
"sourcepathref" with <javac> when compiling, to supply one or the other
additional source folder, depending on which version I'm building.
This additional path reference is set by a task that executes early in the
ant build setup sequence, and makes the decision based on a property passed
into the build script with "-Dbuildtype=market" or
"-Dbuildtype=anotherstore" on the ant command line.
Finally, there are two very simple shell scripts that call ant with the
appropriate -D... flags.
End result:
- The sources for both versions are accessible in Eclipse
- The app can be built in Eclipse, defaulting to one of the two possible
configurations
- The main body of application code is not in a library, but rather a
regular application project so my change-compile-debug cycles are faster (I
think)
- Clean command line builds are just a simple shell command away, for
either configuration
- The Market version doesn't contain any code for the alternate store, and
vice versa.
- Command line builds name the build output with a suffix, something like
"FooBarApp-market-1.0.5.1.apk", where the version number is automatically
extracted from the manifest
This message is overly long and too detailed, so.... sorry, but I hope it
can provide some ideas.
-- Kostya
10 января 2012 г. 23:34 пользователь TreKing <[email protected]> написал:
> On Tue, Jan 10, 2012 at 12:55 PM, Ricardo Amaral <[email protected]
> > wrote:
>
>> You could include both libraries into your one project, abstract both
>>> into concrete classes that are instantiated based on some static flag, and
>>> only instantiate and use the one you need based on the flag. Build, flip
>>> bit, rebuild.
>>>
>>
>> That's the kind of behavior I wanted to automate, instead of manually
>> building the application twice...
>>
>
> Replying back to the whole group. Careful with which button you click.
>
>
> I haven't used Ant but doing an in-file replace and rebuild is probably
> something you can easily do with it.
>
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en