[Gradle] Update the Kapt3AndroidExternalIT.testRealm test project
Now it uses the latest version of realm-gradle-plugin #KT-45748 Fixed
This commit is contained in:
committed by
Space Team
parent
ff6442a1cb
commit
71b431db15
+6
-2
@@ -109,8 +109,12 @@ class Kapt3AndroidExternalIT : Kapt3BaseIT() {
|
||||
) {
|
||||
build("assembleDebug") {
|
||||
assertKaptSuccessful()
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/CatRealmProxy.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/CatRealmProxyInterface.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/io_realm_examples_kotlin_model_CatRealmProxy.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/io_realm_examples_kotlin_model_CatRealmProxyInterface.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/io_realm_examples_kotlin_model_DogRealmProxy.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/io_realm_examples_kotlin_model_DogRealmProxyInterface.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/io_realm_examples_kotlin_model_PersonRealmProxy.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/io_realm_examples_kotlin_model_PersonRealmProxyInterface.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/DefaultRealmModule.java")
|
||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/DefaultRealmModuleMediator.java")
|
||||
}
|
||||
|
||||
+9
-42
@@ -1,37 +1,26 @@
|
||||
buildscript {
|
||||
ext.realm_version = '1.1.1'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'https://maven.google.com' }
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jcenter.bintray.com/") }
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:$android_tools_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath("io.realm:realm-gradle-plugin:$realm_version") {
|
||||
exclude group: 'com.android.tools.build', module: 'gradle'
|
||||
}
|
||||
classpath "io.realm:realm-gradle-plugin:10.12.0"
|
||||
}
|
||||
}
|
||||
|
||||
// workaround for com.android.tools.build:gradle:1.1.1 adding dependencies to the `compile` configuration
|
||||
configurations {
|
||||
maybeCreate("compile")
|
||||
implementation.extendsFrom(compile)
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("org.jetbrains.kotlin.kapt")
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'realm-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
defaultConfig {
|
||||
applicationId 'io.realm.examples.kotlin'
|
||||
minSdkVersion 14
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
@@ -51,32 +40,10 @@ android {
|
||||
sourceCompatibility 1.8
|
||||
targetCompatibility 1.8
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
// Workaround for org.jetbrains.kotlin.gradle.Kapt3Android33IT#testRealm
|
||||
// Android Plugin 3.3.2 fails with:
|
||||
// Execution failed for task ':transformResourcesWithMergeJavaResForDebug'.
|
||||
// com.android.builder.merge.DuplicateRelativeFileException: (these appear one by one if you exclude single files)
|
||||
// - More than one file was found with OS independent path 'kotlin/reflect/reflect.kotlin_builtins'
|
||||
// - More than one file was found with OS independent path 'kotlin/coroutines/coroutines.kotlin_builtins'
|
||||
// - More than one file was found with OS independent path 'kotlin/collections/collections.kotlin_builtins'
|
||||
// - More than one file was found with OS independent path 'kotlin/internal/internal.kotlin_builtins'
|
||||
// (maybe more)
|
||||
exclude '**/*.kotlin_builtins'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'https://maven.google.com' }
|
||||
maven {
|
||||
url 'https://oss.jfrog.org/artifactory/oss-snapshot-local'
|
||||
}
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
implementation 'org.jetbrains.anko:anko-common:0.9'
|
||||
}
|
||||
}
|
||||
+16
-23
@@ -22,13 +22,11 @@ import android.util.Log
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import io.realm.Realm
|
||||
import io.realm.Sort
|
||||
import io.realm.RealmConfiguration
|
||||
import io.realm.Sort
|
||||
import io.realm.examples.kotlin.model.Cat
|
||||
import io.realm.examples.kotlin.model.Dog
|
||||
import io.realm.examples.kotlin.model.Person
|
||||
import org.jetbrains.anko.doAsync
|
||||
import org.jetbrains.anko.uiThread
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
|
||||
@@ -52,7 +50,7 @@ class KotlinExampleActivity : Activity() {
|
||||
// we can generally safely run them on the UI thread.
|
||||
|
||||
// Create configuration and reset Realm.
|
||||
realmConfig = RealmConfiguration.Builder(this).build()
|
||||
realmConfig = RealmConfiguration.Builder().build()
|
||||
Realm.deleteRealm(realmConfig)
|
||||
|
||||
// Open the realm for the UI thread.
|
||||
@@ -69,17 +67,11 @@ class KotlinExampleActivity : Activity() {
|
||||
realm.delete(Person::class.java)
|
||||
}
|
||||
|
||||
// More complex operations can be executed on another thread, for example using
|
||||
// Anko's async extension method.
|
||||
doAsync() {
|
||||
var info: String
|
||||
info = complexReadWrite()
|
||||
info += complexQuery()
|
||||
var info: String
|
||||
info = complexReadWrite()
|
||||
info += complexQuery()
|
||||
|
||||
uiThread {
|
||||
showStatus(info)
|
||||
}
|
||||
}
|
||||
showStatus(info)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -107,7 +99,7 @@ class KotlinExampleActivity : Activity() {
|
||||
}
|
||||
|
||||
// Find the first person (no query conditions) and read a field
|
||||
var person = realm.where(Person::class.java).findFirst()
|
||||
var person = realm.where(Person::class.java).findFirst() ?: error("No person")
|
||||
showStatus(person.name + ": " + person.age)
|
||||
|
||||
// Update person in a transaction
|
||||
@@ -122,7 +114,8 @@ class KotlinExampleActivity : Activity() {
|
||||
showStatus("\nPerforming basic Query operation...")
|
||||
showStatus("Number of persons: ${realm.where(Person::class.java).count()}")
|
||||
|
||||
val results = realm.where(Person::class.java).equalTo("age", 99).findAll()
|
||||
val age = 99
|
||||
val results = realm.where(Person::class.java).equalTo("age", age).findAll()
|
||||
|
||||
showStatus("Size of result set: " + results.size)
|
||||
}
|
||||
@@ -184,9 +177,9 @@ class KotlinExampleActivity : Activity() {
|
||||
}
|
||||
|
||||
// Sorting
|
||||
val sortedPersons = realm.where(Person::class.java).findAllSorted("age", Sort.DESCENDING);
|
||||
check(realm.where(Person::class.java).findAll().last().name == sortedPersons.first().name)
|
||||
status += "\nSorting ${sortedPersons.last().name} == ${realm.where(Person::class.java).findAll().first().name}"
|
||||
val sortedPersons = realm.where(Person::class.java).sort("age", Sort.DESCENDING).findAll()
|
||||
check(realm.where(Person::class.java).findAll().last()!!.name == sortedPersons.first()!!.name)
|
||||
status += "\nSorting ${sortedPersons.last()!!.name} == ${realm.where(Person::class.java).findAll().first()!!.name}"
|
||||
|
||||
realm.close()
|
||||
return status
|
||||
@@ -203,10 +196,10 @@ class KotlinExampleActivity : Activity() {
|
||||
|
||||
// Find all persons where age between 7 and 9 and name begins with "Person".
|
||||
val results = it
|
||||
.where(Person::class.java)
|
||||
.between("age", 7, 9) // Notice implicit "and" operation
|
||||
.beginsWith("name", "Person")
|
||||
.findAll()
|
||||
.where(Person::class.java)
|
||||
.between("age", 7, 9) // Notice implicit "and" operation
|
||||
.beginsWith("name", "Person")
|
||||
.findAll()
|
||||
|
||||
status += "\nSize of result set: ${results.size}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user