-
-
Notifications
You must be signed in to change notification settings - Fork 368
Description
Hi @j256 ,
I could work on the gradle plugin for Android :
https://github.com/stephanenicolas/ormlite-android-gradle-plugin
Currently the plugin is still immature. But it can work for most apps I think. It still needs more configuration and more adaptation to the gradle life cycle for android.
Nevertheless, it works only by using command line to drive the OrmLiteConfigUtil class. It was really the simplest way to do it. But a real API would be so much better !
Here are some concerns with this class :
- every method is static, it doesn't allow extension by inheritance
- most methods are static and you need to extend the class to use them
For this, it would be nice to have a simpler standard java class with public, protected and private methods.
Also, the class :
- is not customizable enough, it does too many things by itself and should not assume any project structure, like trying to find both java source files and the raw folder from a common root, then also loading the classes into memory from jar files, etc..
- for gradle we need to pass you :
** one or more folders that contains sources
** a destinationDir to write to
** the name of the config file in it
** glups, the hard part ! : the classpath
we need to feed you with a classpath because you load the classes and use them. (This problem would not be present with an annotation problem, but annotation processors have also their disadvantages.)
Also, we need to configure the classpath as with gradle, different classpaths can be defined for different flavors.
But then, we will run into a new problem (I know because I tried) : the annotation classes used in ormlite source code, will not be the same as the annotations classes used in the source code of the app. And ORM Lite is not able to recognize those annotations because they live in a different class loader.
Ways to workaround this would be
- share the classpath as you currently do : the utility app must have the classes to manipulate in its classpath. But that is harder to do programmatically, and may also look a bit awkward : the class loader being used as a kind of class storage shared by the app and the plugin
- make it possible to recognize annotations not by classes but by names.
Solution 2 is the most clean but can be tricky on the performance level. Maybe with a strategy pattern it can be smoothened. Solution 1 is a bit awkward, but can be the simplest for developers.
And this can be largely worked around with an annotation processor, but it also comes with some complexity, but probably the best way to do it.