android / android-studio-poet

Large Android projects generator
Apache License 2.0
702 stars 85 forks source link

Support sharing resources between Android modules #34

Open borisf opened 6 years ago

borisf commented 6 years ago

Make Android modules be dependent on other Andorid/Java modules:

borisf commented 6 years ago

in build.gradle


dependencies {
              ...
                implementation project(':module4')
                // generated
                compile project(':androidAppModule1')

            }

And in activity

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Set the layout for this activity.  You can find it
        // in res/layout/hello_activity.xml
        setContentView(R.layout.activity_main0);

        // generated source
        module1packageJava0.Foo0 zzz = new module1packageJava0.Foo0();
        zzz.foo0();

        // generated resources
        setContentView(com.androidAppModule1.R.layout.activity_main2);
    }
borisf commented 6 years ago

cc @NikitaKozlov

NikitaKozlov commented 6 years ago

Is this what is currently generated?

borisf commented 6 years ago

These are my tests, to support the feature fully we need to upgrade the dependencies system, for Android modules to be dependent on other Android modules

NikitaKozlov commented 6 years ago

Oh, I see. You want us to generate this kind of code? But why then it calls setContentView twice?

borisf commented 6 years ago

This is the minimal code I generated and updated by hand to understand the scope of generated code, thus setContentView twice is the minimal code to actually use resources from another Android module and activate relevant android gradle plugin mechanisms

NikitaKozlov commented 6 years ago

https://github.com/borisf/android-studio-poet/pull/46

NikitaKozlov commented 6 years ago

Done in "dev" branch