项目作者: blipinsk

项目描述 :
Kotlin extension bridge library for Dagger2 (proof-of-concept)
高级语言: Java
项目地址: git://github.com/blipinsk/dagger2-ktx.git
创建时间: 2018-05-29T21:50:13Z
项目社区:https://github.com/blipinsk/dagger2-ktx

开源协议:

下载


dagger2-ktx

Kotlin extension bridge library for Dagger2 (proof-of-concept)

Read more here: @blipinsk/kotlin-extension-methods-generation-15b5e6499dc8">Kotlin extension function generation 🚀…

Usage

For a working implementation of this library see the sample/ module.

  1. Add to your module’s build.gradle

    • for Android project:

      1. android {
      2. sourceSets {
      3. main.java.srcDirs += 'src/main/kotlin'
      4. debug.java.srcDirs += 'src/debug/kotlin'
      5. release.java.srcDirs += 'src/release/kotlin'
      6. test.java.srcDirs += 'src/test/kotlin'
      7. // For kapt stubs
      8. main.java.srcDirs += [file("$buildDir/generated/source/kapt/main")]
      9. debug.java.srcDirs += [file("$buildDir/generated/source/kapt/debug")]
      10. release.java.srcDirs += [file("$buildDir/generated/source/kapt/release")]
      11. test.java.srcDirs += [file("$buildDir/generated/source/kapt/test")]
      12. // For kotlin code gen during kapt
      13. main.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/main")]
      14. debug.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/debug")]
      15. release.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/release")]
      16. test.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/test")]
      17. }
      18. }
    • for Java/Kotlin project:

      1. apply plugin: 'idea'
      2. idea {
      3. module {
      4. sourceDirs += files(
      5. 'build/generated/source/kapt/main',
      6. 'build/generated/source/kaptKotlin/main',
      7. 'build/tmp/kapt/main/kotlinGenerated')
      8. generatedSourceDirs += files(
      9. 'build/generated/source/kapt/main',
      10. 'build/generated/source/kaptKotlin/main',
      11. 'build/tmp/kapt/main/kotlinGenerated')
      12. }
      13. }
  1. Instead of creating your component with

    1. DaggerYourComponent.create()

    use:

    1. Dagger.create(YourComponent::class)
  2. Enjoy no issues with imports of the DaggerYourComponent

Including In Your Project

Add in your build.gradle:

  1. repositories {
  2. maven { url 'https://dl.bintray.com/blipinsk/maven/' }
  3. }
  4. dependencies {
  5. kapt "com.bartoszlipinski:dagger2-ktx-compiler:0.1.0"
  6. implementation "com.bartoszlipinski:dagger2-ktx:0.1.0"
  7. }

Developed by

  • Bartosz Lipiński

License

  1. Copyright 2018 Bartosz Lipiński
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.