diff --git a/README.md b/README.md index ccdc476..2ccd8b0 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ Step 2. Add Roomigrant library and compiler dependencies: ```groovy dependencies { // Room - implementation 'android.arch.persistence.room:runtime:1.1.1' - kapt 'android.arch.persistence.room:compiler:1.1.1' + implementation 'androidx.room:room-runtime:2.2.5' + kapt 'androidx.room:room-compiler:2.2.5' // Roomigrant implementation 'com.github.MatrixDev.Roomigrant:RoomigrantLib:0.1.7' diff --git a/RoomigrantCompiler/build.gradle b/RoomigrantCompiler/build.gradle index 9e00e46..ee5222c 100644 --- a/RoomigrantCompiler/build.gradle +++ b/RoomigrantCompiler/build.gradle @@ -1,22 +1,32 @@ apply plugin: 'java-library' apply plugin: 'kotlin' -apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'kotlin-kapt' - -sourceCompatibility = "1.7" -targetCompatibility = "1.7" +apply plugin: 'com.github.dcendents.android-maven' group = 'com.github.MatrixDev' dependencies { implementation project(':RoomigrantLib') - implementation 'com.squareup:kotlinpoet:1.6.0' - implementation 'com.google.code.gson:gson:2.8.5' - implementation 'android.arch.persistence.room:runtime:1.1.1' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + // Kotlin runtime + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + + // Kotlin code generation + implementation('com.squareup:kotlinpoet:1.6.0') { + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' + } + // Room + implementation 'androidx.room:room-runtime:2.2.5' + + // Json parsing + implementation 'com.google.code.gson:gson:2.8.6' + + // Auto META-INF processor info generator + //noinspection AnnotationProcessorOnCompilePath compileOnly 'com.google.auto.service:auto-service:1.0-rc6' + + // Incremental processor support compileOnly 'net.ltgt.gradle.incap:incap:0.2' kapt 'net.ltgt.gradle.incap:incap-processor:0.2' } diff --git a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Database.kt b/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Database.kt index 705b948..4a51459 100644 --- a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Database.kt +++ b/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Database.kt @@ -17,8 +17,8 @@ import javax.tools.StandardLocation @Suppress("UNCHECKED_CAST", "MemberVisibilityCanBePrivate", "FunctionName", "DEPRECATION") class Database(val environment: ProcessingEnvironment, element: TypeElement) { - val migrationType = ClassName("android.arch.persistence.room.migration", "Migration") - val sqLiteDatabaseType = ClassName("android.arch.persistence.db", "SupportSQLiteDatabase") + val migrationType = ClassName("androidx.room.migration", "Migration") + val sqLiteDatabaseType = ClassName("androidx.sqlite.db", "SupportSQLiteDatabase") val migrationListType = ArrayList::class.asClassName().parameterizedBy(migrationType) val migrationArrayType = ClassName("kotlin", "Array").parameterizedBy(migrationType) @@ -43,10 +43,9 @@ class Database(val environment: ProcessingEnvironment, element: TypeElement) { .addProperties(generate_rules()) .addFunction(generate_build()) .addFunction(generate_buildScheme()) - - for (scheme in schemes) { - typeSpec.addFunction(generate_buildSchemeInfo(scheme)) - } + .also { + schemes.forEach { scheme -> it.addFunction(generate_buildSchemeInfo(scheme)) } + } val fileSpec = FileSpec.builder(packageName, migrationListClassName.simpleName) .addType(typeSpec.build()) diff --git a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/RoomigrantProcessor.kt b/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/RoomigrantProcessor.kt index c6fafbc..a3c286a 100644 --- a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/RoomigrantProcessor.kt +++ b/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/RoomigrantProcessor.kt @@ -15,11 +15,12 @@ import javax.annotation.processing.RoundEnvironment import javax.annotation.processing.SupportedSourceVersion import javax.lang.model.SourceVersion import javax.lang.model.element.TypeElement -import android.arch.persistence.room.Database as DatabaseAnnotation +import androidx.room.Database as DatabaseAnnotation /** * @author matrixdev */ +@Suppress("SpellCheckingInspection") @AutoService(Processor::class) @IncrementalAnnotationProcessor(ISOLATING) @SupportedSourceVersion(SourceVersion.RELEASE_7) @@ -44,7 +45,7 @@ class RoomigrantProcessor : AbstractProcessor() { private fun processDatabase(schemaLocation: String, element: TypeElement) { val folder = File(schemaLocation, element.asClassName().toString()) - val schemes = folder.listFiles().mapNotNull { readScheme(it) }.sortedBy { it.version } + val schemes = folder.listFiles().orEmpty().mapNotNull { readScheme(it) }.sortedBy { it.version } val database = Database(processingEnv, element) for (scheme in schemes) { diff --git a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/utils/Utils.kt b/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/utils/Utils.kt deleted file mode 100644 index 813b33c..0000000 --- a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/utils/Utils.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.matrix.roomigrant.compiler.utils - -/** - * @author matrixdev - */ - -fun String.asVarName() = "`$this`" \ No newline at end of file diff --git a/RoomigrantCompiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/RoomigrantCompiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor deleted file mode 100644 index 5447e23..0000000 --- a/RoomigrantCompiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ /dev/null @@ -1 +0,0 @@ -dev.matrix.roomigrant.compiler.RoomigrantProcessor diff --git a/RoomigrantLib/build.gradle b/RoomigrantLib/build.gradle index 64da67e..c4cf5df 100644 --- a/RoomigrantLib/build.gradle +++ b/RoomigrantLib/build.gradle @@ -2,11 +2,8 @@ apply plugin: 'java-library' apply plugin: 'kotlin' apply plugin: 'com.github.dcendents.android-maven' -sourceCompatibility = "1.7" -targetCompatibility = "1.7" - group = 'com.github.MatrixDev' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/RoomigrantTest/build.gradle b/RoomigrantTest/build.gradle index 06bd680..7ca3bfa 100644 --- a/RoomigrantTest/build.gradle +++ b/RoomigrantTest/build.gradle @@ -3,15 +3,15 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 27 + compileSdkVersion 30 defaultConfig { applicationId "dev.matrix.roomigrant.test" minSdkVersion 19 - targetSdkVersion 27 + targetSdkVersion 30 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' javaCompileOptions { annotationProcessorOptions { @@ -33,20 +33,20 @@ android { } dependencies { - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // room - implementation 'android.arch.persistence.room:runtime:1.1.1' - androidTestImplementation 'android.arch.persistence.room:testing:1.1.1' - kapt 'android.arch.persistence.room:compiler:1.1.1' + implementation 'androidx.room:room-runtime:2.2.5' + androidTestImplementation 'androidx.room:room-testing:2.2.5' + kapt 'androidx.room:room-compiler:2.2.5' // roomigrant compileOnly project(':RoomigrantLib') kapt project(':RoomigrantCompiler') // testing - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } diff --git a/RoomigrantTest/src/androidTest/java/dev/matrix/roomigrant/test/DatabaseTest.kt b/RoomigrantTest/src/androidTest/java/dev/matrix/roomigrant/test/DatabaseTest.kt index c5365d9..eb36a46 100644 --- a/RoomigrantTest/src/androidTest/java/dev/matrix/roomigrant/test/DatabaseTest.kt +++ b/RoomigrantTest/src/androidTest/java/dev/matrix/roomigrant/test/DatabaseTest.kt @@ -1,10 +1,10 @@ package dev.matrix.roomigrant.test -import android.arch.persistence.room.testing.MigrationTestHelper -import android.support.test.InstrumentationRegistry +import androidx.room.testing.MigrationTestHelper +import androidx.test.platform.app.InstrumentationRegistry import org.junit.Rule import org.junit.Test -import android.arch.persistence.room.Database as DatabaseAnnotation +import androidx.room.Database as DatabaseAnnotation /** * @author matrixdev diff --git a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Database.kt b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Database.kt index 74dbeeb..2acc386 100644 --- a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Database.kt +++ b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Database.kt @@ -1,7 +1,7 @@ package dev.matrix.roomigrant.test -import android.arch.persistence.room.Database -import android.arch.persistence.room.RoomDatabase +import androidx.room.Database +import androidx.room.RoomDatabase import dev.matrix.roomigrant.GenerateRoomMigrations /** diff --git a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dao.kt b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dao.kt index 6102a5b..1984992 100644 --- a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dao.kt +++ b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dao.kt @@ -1,7 +1,7 @@ package dev.matrix.roomigrant.test -import android.arch.persistence.room.Dao -import android.arch.persistence.room.Insert +import androidx.room.Dao +import androidx.room.Insert /** * @author matrixdev diff --git a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dbo.kt b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dbo.kt index 534f3c7..76fcefa 100644 --- a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dbo.kt +++ b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object1Dbo.kt @@ -1,7 +1,7 @@ package dev.matrix.roomigrant.test -import android.arch.persistence.room.Entity -import android.arch.persistence.room.PrimaryKey +import androidx.room.Entity +import androidx.room.PrimaryKey /** * @author matrixdev diff --git a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dao.kt b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dao.kt index 2d38354..25498e4 100644 --- a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dao.kt +++ b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dao.kt @@ -1,7 +1,7 @@ package dev.matrix.roomigrant.test -import android.arch.persistence.room.Dao -import android.arch.persistence.room.Insert +import androidx.room.Dao +import androidx.room.Insert /** * @author matrixdev diff --git a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dbo.kt b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dbo.kt index 2eba547..2052fcf 100644 --- a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dbo.kt +++ b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Object2Dbo.kt @@ -1,7 +1,7 @@ package dev.matrix.roomigrant.test -import android.arch.persistence.room.Entity -import android.arch.persistence.room.PrimaryKey +import androidx.room.Entity +import androidx.room.PrimaryKey /** * @author matrixdev diff --git a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Rules.kt b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Rules.kt index 8d723f8..200e62f 100644 --- a/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Rules.kt +++ b/RoomigrantTest/src/main/java/dev/matrix/roomigrant/test/Rules.kt @@ -1,6 +1,6 @@ package dev.matrix.roomigrant.test -import android.arch.persistence.db.SupportSQLiteDatabase +import androidx.sqlite.db.SupportSQLiteDatabase import dev.matrix.roomigrant.rules.FieldMigrationRule import dev.matrix.roomigrant.rules.OnMigrationEndRule import dev.matrix.roomigrant.rules.OnMigrationStartRule diff --git a/build.gradle b/build.gradle index db03782..0f2c9f7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.51' + ext.kotlin_version = '1.4.10' repositories { google() @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:4.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } diff --git a/gradle.properties b/gradle.properties index 743d692..8de5058 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,8 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index eee3586..b1ef7c3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip