f2prateek / dart

Extras binding and intent builders for Android apps.
Apache License 2.0
1.19k stars 88 forks source link

Multi module using DH3, M2 to M1 cycle navigation #217

Closed cooperkong closed 6 years ago

cooperkong commented 6 years ago

Hi, almost feels like getting DH3 working đź‘Ť

except that I got below Unresolved Reference error, but it seems the correct files are already generated and IDE doesn't complaint about it. Only when running gradle builds.

screen shot 2018-06-01 at 10 09 46
cooperkong commented 6 years ago

If I add

sourceSets {
        main.java.srcDirs += 'build/generated/source/navigator/debug'
    }

it compiles and cycle navigation works fine. M1->M2, M2->M1, but this is not something I want to add to gradle.

cooperkong commented 6 years ago

I think my activity is in Kotlin, thus it can't be resolved. Change it to java class works fine.

stephanenicolas commented 6 years ago

Thank you very much for the detail. We actually don't use Kotlin yet.

Not sure how to address this issue, it seems to me that the generated code folder should have been added. Kotlin or Java should not matter.

I keep the issue open to double check that the folder is added explicitly by the gradle plugin of DH3.

2018-05-31 17:42 GMT-07:00 WenChao Kong notifications@github.com:

I think my activity is in Kotlin, thus it can't be resolved. Change it to java class works fine.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/f2prateek/dart/issues/217#issuecomment-393725044, or mute the thread https://github.com/notifications/unsubscribe-auth/ABv33Z1uq5feI8lBu9YahAn_VaxOmn-Kks5t4I4OgaJpZM4UV6eI .

stephanenicolas commented 6 years ago

And your work around is actually good, the plugin should be doing it for you.

Note to self: Oh, maybe we added the path to the java compile task, but the kotlin task should use it too. There must be a better way to do it (regiserGeneratedFolder maybe ? )

2018-05-31 20:34 GMT-07:00 Stéphane NICOLAS steff.nicolas@gmail.com:

Thank you very much for the detail. We actually don't use Kotlin yet.

Not sure how to address this issue, it seems to me that the generated code folder should have been added. Kotlin or Java should not matter.

I keep the issue open to double check that the folder is added explicitly by the gradle plugin of DH3.

2018-05-31 17:42 GMT-07:00 WenChao Kong notifications@github.com:

I think my activity is in Kotlin, thus it can't be resolved. Change it to java class works fine.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/f2prateek/dart/issues/217#issuecomment-393725044, or mute the thread https://github.com/notifications/unsubscribe-auth/ABv33Z1uq5feI8lBu9YahAn_VaxOmn-Kks5t4I4OgaJpZM4UV6eI .

stephanenicolas commented 6 years ago

Can you try version 3.0.1-SNAPSHOT please ? I am trying to make the plugin compatible with Java and Kotlin. We were not using the abstract model of the gradle android plugin, but only tweeking the java gradle tasks directly.

Thanks for reporting this issue and following up !

stephanenicolas commented 6 years ago

@cooperkong ^

cooperkong commented 6 years ago

Hi, I don't see 3.0.1-SNAPSHOT in maven central

stephanenicolas commented 6 years ago

Snapshots are in a different repo:

repositories {
    ...
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
cooperkong commented 6 years ago

Hi, @stephanenicolas it's working now with the snapshot! No need to manually add source set.

stephanenicolas commented 6 years ago

Good news @cooperkong , I am gonna merge the PR then. Are you sure you also removed the modification of the source set ?

If you want you can have a look at https://github.com/f2prateek/dart/blob/master/henson-plugin/src/functTest/groovy/dart/henson/plugin/HensonPluginFunctionalTest.groovy#L133

I would like to add a Kotlin functional test. Basically, I need some help to write this 2 classes in Kotlin:

package module1;

        import android.app.Activity;
        import android.os.Bundle;
        import android.content.Intent;

        class FooActivity extends Activity {

          @Override
          public void onCreate(Bundle bundle) {
            super.onCreate(bundle);
            FooActivityNavigationModel foo = new FooActivityNavigationModel();
            Intent intent = HensonNavigator.gotoFooActivity(this)
              .s("s")
              .build();
          }
        }

and

package module1;

        import dart.BindExtra;
        import dart.DartModel;

        @DartModel()
        class FooActivityNavigationModel {
          @BindExtra String s;
        }

I guess I can deal with the gradle setup. Thx already for your follow up!

cooperkong commented 6 years ago

Yeah sure.

package module1

import android.app.Activity
import android.os.Bundle
import android.content.Intent
class FooActivity : Activity() {

    override fun onCreate(bundle :Bundle?) {
        super.onCreate(bundle)
        val foo = FooActivityNavigationModel()
        val intent = HensonNavigator.gotoFooActivity(this)
                .s("s")
                .build()
    }
}
package module1
import dart.BindExtra
import dart.DartModel
@DartModel
class FooActivityNavigationModel {
    @BindExtra
    lateinit var s : String
}
stephanenicolas commented 6 years ago

@cooperkong, I am close but it looks like Kotlin can't find the Henson navigator. I had to run the task manually to generate the navigator and it looks like I must also add the folder where the generated source is... Can you post the build file you use please ? (For the module that uses Henson generator).

stephanenicolas commented 6 years ago

I could get it solved @cooperkong , I was using a bad version of the henson plugin... We are gonna release the fix soon, with kotlin support. Thx a lot for your help.

cooperkong commented 6 years ago

@stephanenicolas Nice, can't wait!

dlemures commented 6 years ago

PR merged https://github.com/f2prateek/dart/pull/218 ! Releasing in 1 hour.