sockeqwe / sqlbrite-dao

DAO for SQLBrite
http://hannesdorfmann.com/android/sqlbrite-dao
Apache License 2.0
182 stars 22 forks source link

ObjectMapper Kotlin issue #42

Open itslayo opened 8 years ago

itslayo commented 8 years ago

I used class KotlinCustomer from example app. After project was built everything is Ok with generated class KotlinCustomerMapper (it has all declared fields) but when I deploy app onto my device KotlinCustomerMapper loses all fields

public final class KotlinCustomerMapper {
  public static final Func1<Cursor, KotlinCustomer> MAPPER = new Func1<Cursor, com.layo.chuckfun.models.KotlinCustomer>() {
    @Override public com.ll.test.models.KotlinCustomer call(Cursor cursor) {
      KotlinCustomer item = new KotlinCustomer();
      return item;
    }
  };

  private KotlinCustomerMapper() {
  }

  /**
   * Get a typesafe ContentValues Builder 
   * @return The ContentValues Builder 
   */
  public static ContentValuesBuilder contentValues() {
    return new ContentValuesBuilder();
  }

  /**
   * Builder class to generate type sage {@link ContentValues } . At the end you have to call {@link #build()}
   */
  public static class ContentValuesBuilder {
    private ContentValues contentValues;

    private ContentValuesBuilder() {
      contentValues = new ContentValues();
    }

    /**
     * Creates and returns a ContentValues from the builder
     * @return ContentValues */
    public ContentValues build() {
      return contentValues;
    }
  }
}

same issue with all @ObjectMappable classes in project

Gradle dependencies:

    compile 'com.hannesdorfmann.sqlbrite:dao:0.6.1'
    compile 'com.hannesdorfmann.sqlbrite:annotations:0.6.1'
    kapt 'com.hannesdorfmann.sqlbrite:object-mapper:0.6.1'
sockeqwe commented 8 years ago

This is a kotlin issue. Try kotlin eap version and disable incremental build

Ruslan Andrievskiy notifications@github.com schrieb am So., 8. Mai 2016, 20:20:

I used class KotlinCustomer from example app. After project was built everything is Ok with generated class KotlinCustomerMapper (it has all declared fields) but when I deploy app onto my device KotlinCustomerMapper loses all fields

public final class KotlinCustomerMapper { public static final Func1<Cursor, KotlinCustomer> MAPPER = new Func1<Cursor, com.layo.chuckfun.models.KotlinCustomer>() { @Override public com.ll.test.models.KotlinCustomer call(Cursor cursor) { KotlinCustomer item = new KotlinCustomer(); return item; } };

private KotlinCustomerMapper() { }

/**

  • Get a typesafe ContentValues Builder
  • @return The ContentValues Builder */ public static ContentValuesBuilder contentValues() { return new ContentValuesBuilder(); }

    /**

  • Builder class to generate type sage {@link ContentValues } . At the end you have to call {@link #build()} */ public static class ContentValuesBuilder { private ContentValues contentValues;

    private ContentValuesBuilder() { contentValues = new ContentValues(); }

    /**

    • Creates and returns a ContentValues from the builder
    • @return ContentValues */ public ContentValues build() { return contentValues; } } }

same issue with all @ObjectMappable classes in project

Gradle dependencies:

compile 'com.hannesdorfmann.sqlbrite:dao:0.6.1'
compile 'com.hannesdorfmann.sqlbrite:annotations:0.6.1'
kapt 'com.hannesdorfmann.sqlbrite:object-mapper:0.6.1'

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/sockeqwe/sqlbrite-dao/issues/42

itslayo commented 8 years ago

I've used latest EAP build 1.0.2-eap-74 but with it no Mapper class wasn't generated. About incremental build. Did you mean kotlin.compileOptions.incremental ?

sockeqwe commented 8 years ago

No, I meant:

android {

compileOptions.incremental = false ... }

This plus kotlin eap should fix that (maybe kotlin eap is not needed at all)

Ruslan Andrievskiy notifications@github.com schrieb am Mo., 9. Mai 2016, 11:06:

I've used latest EAP build 1.0.2-eap-74 but with it no Mapper class wasn't generated. About incremental build. Did you mean kotlin.compileOptions.incremental ?

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/sockeqwe/sqlbrite-dao/issues/42#issuecomment-217812997

itslayo commented 8 years ago

I've already tried only

  compileOptions {
        incremental false
    }

and with different eap builds but nothing helps(

sockeqwe commented 8 years ago

Hm, ok:

android {
  compileOptions.incremental = false
  compileSdkVersion 23
  buildToolsVersion "23.0.2"
  ...
}

With kotlin 1.0.1 (not eap) works for me

itslayo commented 8 years ago

Doesn't work for me( Here is my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileOptions.incremental = false
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.ll.test"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        multiDexEnabled false
    }
    buildTypes {
        debug {
            applicationIdSuffix '.debug'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
}

kapt {
    generateStubs = true
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.1"

    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'

    compile 'com.jakewharton:butterknife:7.0.1'
    kapt 'com.jakewharton:butterknife:7.0.1'

    compile 'com.google.dagger:dagger:2.0.1'
    kapt 'com.google.dagger:dagger-compiler:2.0.2'
    provided 'org.glassfish:javax.annotation:10.0-b28'

    compile 'io.reactivex:rxjava:1.0.16'
    compile 'io.reactivex:rxandroid:1.0.1'

    compile 'com.hannesdorfmann.sqlbrite:dao:0.6.1'
    compile 'com.hannesdorfmann.sqlbrite:annotations:0.6.1'
    kapt 'com.hannesdorfmann.sqlbrite:object-mapper:0.6.1'

    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
    compile 'com.squareup.okhttp3:okhttp:3.1.2'
    compile 'com.squareup.okhttp3:logging-interceptor:3.1.2'
}

and

object Models {
    @ObjectMappable
    class User {
        companion object {
            const val TABLE_NAME: String = "users"
            const val COL_ID: String = "id"
            const val COL_NAME: String = "name"
            const val COL_LIKE: String = "like"
        }

        @Column(COL_NAME)
        var name: String? = null
        @Column(COL_LIKE)
        var liked: Boolean = false
    }
}