[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") {
|
build("assembleDebug") {
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/CatRealmProxy.java")
|
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/io_realm_examples_kotlin_model_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_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/DefaultRealmModule.java")
|
||||||
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/DefaultRealmModuleMediator.java")
|
assertFileInProjectExists("build/generated/source/kapt/debug/io/realm/DefaultRealmModuleMediator.java")
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-41
@@ -1,37 +1,26 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.realm_version = '1.1.1'
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
google()
|
||||||
maven { url 'https://maven.google.com' }
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = uri("https://jcenter.bintray.com/") }
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.android.tools.build:gradle:$android_tools_version"
|
classpath "io.realm:realm-gradle-plugin:10.12.0"
|
||||||
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'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround for com.android.tools.build:gradle:1.1.1 adding dependencies to the `compile` configuration
|
plugins {
|
||||||
configurations {
|
id("com.android.application")
|
||||||
maybeCreate("compile")
|
id("org.jetbrains.kotlin.android")
|
||||||
implementation.extendsFrom(compile)
|
id("org.jetbrains.kotlin.kapt")
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
|
||||||
apply plugin: 'kotlin-android'
|
|
||||||
apply plugin: 'kotlin-kapt'
|
|
||||||
apply plugin: 'realm-android'
|
apply plugin: 'realm-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 23
|
compileSdkVersion 23
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'io.realm.examples.kotlin'
|
applicationId 'io.realm.examples.kotlin'
|
||||||
minSdkVersion 14
|
minSdkVersion 16
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
@@ -51,32 +40,10 @@ android {
|
|||||||
sourceCompatibility 1.8
|
sourceCompatibility 1.8
|
||||||
targetCompatibility 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 {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven { url 'https://maven.google.com' }
|
google()
|
||||||
maven {
|
|
||||||
url 'https://oss.jfrog.org/artifactory/oss-snapshot-local'
|
|
||||||
}
|
|
||||||
mavenCentral()
|
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.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.Sort
|
|
||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
|
import io.realm.Sort
|
||||||
import io.realm.examples.kotlin.model.Cat
|
import io.realm.examples.kotlin.model.Cat
|
||||||
import io.realm.examples.kotlin.model.Dog
|
import io.realm.examples.kotlin.model.Dog
|
||||||
import io.realm.examples.kotlin.model.Person
|
import io.realm.examples.kotlin.model.Person
|
||||||
import org.jetbrains.anko.doAsync
|
|
||||||
import org.jetbrains.anko.uiThread
|
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +50,7 @@ class KotlinExampleActivity : Activity() {
|
|||||||
// we can generally safely run them on the UI thread.
|
// we can generally safely run them on the UI thread.
|
||||||
|
|
||||||
// Create configuration and reset Realm.
|
// Create configuration and reset Realm.
|
||||||
realmConfig = RealmConfiguration.Builder(this).build()
|
realmConfig = RealmConfiguration.Builder().build()
|
||||||
Realm.deleteRealm(realmConfig)
|
Realm.deleteRealm(realmConfig)
|
||||||
|
|
||||||
// Open the realm for the UI thread.
|
// Open the realm for the UI thread.
|
||||||
@@ -69,17 +67,11 @@ class KotlinExampleActivity : Activity() {
|
|||||||
realm.delete(Person::class.java)
|
realm.delete(Person::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
// More complex operations can be executed on another thread, for example using
|
var info: String
|
||||||
// Anko's async extension method.
|
info = complexReadWrite()
|
||||||
doAsync() {
|
info += complexQuery()
|
||||||
var info: String
|
|
||||||
info = complexReadWrite()
|
|
||||||
info += complexQuery()
|
|
||||||
|
|
||||||
uiThread {
|
showStatus(info)
|
||||||
showStatus(info)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
@@ -107,7 +99,7 @@ class KotlinExampleActivity : Activity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the first person (no query conditions) and read a field
|
// 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)
|
showStatus(person.name + ": " + person.age)
|
||||||
|
|
||||||
// Update person in a transaction
|
// Update person in a transaction
|
||||||
@@ -122,7 +114,8 @@ class KotlinExampleActivity : Activity() {
|
|||||||
showStatus("\nPerforming basic Query operation...")
|
showStatus("\nPerforming basic Query operation...")
|
||||||
showStatus("Number of persons: ${realm.where(Person::class.java).count()}")
|
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)
|
showStatus("Size of result set: " + results.size)
|
||||||
}
|
}
|
||||||
@@ -184,9 +177,9 @@ class KotlinExampleActivity : Activity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sorting
|
// Sorting
|
||||||
val sortedPersons = realm.where(Person::class.java).findAllSorted("age", Sort.DESCENDING);
|
val sortedPersons = realm.where(Person::class.java).sort("age", Sort.DESCENDING).findAll()
|
||||||
check(realm.where(Person::class.java).findAll().last().name == sortedPersons.first().name)
|
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}"
|
status += "\nSorting ${sortedPersons.last()!!.name} == ${realm.where(Person::class.java).findAll().first()!!.name}"
|
||||||
|
|
||||||
realm.close()
|
realm.close()
|
||||||
return status
|
return status
|
||||||
@@ -203,10 +196,10 @@ class KotlinExampleActivity : Activity() {
|
|||||||
|
|
||||||
// Find all persons where age between 7 and 9 and name begins with "Person".
|
// Find all persons where age between 7 and 9 and name begins with "Person".
|
||||||
val results = it
|
val results = it
|
||||||
.where(Person::class.java)
|
.where(Person::class.java)
|
||||||
.between("age", 7, 9) // Notice implicit "and" operation
|
.between("age", 7, 9) // Notice implicit "and" operation
|
||||||
.beginsWith("name", "Person")
|
.beginsWith("name", "Person")
|
||||||
.findAll()
|
.findAll()
|
||||||
|
|
||||||
status += "\nSize of result set: ${results.size}"
|
status += "\nSize of result set: ${results.size}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user