greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

GreenDAO generator not taking product flavor into account #587

Open WebMajstr- opened 7 years ago

WebMajstr- commented 7 years ago

When I build application with flavor, objects for all classes marked with @Entity tag get build, not just the ones in current flavor or in main folder.

This is causing build issues in cases where greenDAO dependency exists just for a specific flavor.

For example, if I have classes with @Entity in pro flavor, they get generated even if i build lite version, and the app.gradle looks like following

apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'    

android {
   ...
    productFlavors {
        lite {
            ...    
        }
        pro {
            ...
        }
    }
}    

greendao {
   schemaVersion 1
}    

dependencies {
    proCompile 'org.greenrobot:greendao:3.2.0'
}
greenrobot-team commented 7 years ago

Thinking about this I do not believe there is an easy way around this without introducing additional greenDAO config options. The plugin does not know wich flavors use greenDAO and which not. It just looks for classes annotated with @Entity. -ut

one-more-alex commented 6 years ago

Voting to have some solution here.

YuHayring commented 1 year ago

There is a new solution: https://stackoverflow.com/a/77126766/20329042