Skip to content

Commit

Permalink
switched to modern libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixdev committed Sep 21, 2020
1 parent f6afcfc commit bae342b
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 58 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
26 changes: 18 additions & 8 deletions RoomigrantCompiler/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down

This file was deleted.

This file was deleted.

5 changes: 1 addition & 4 deletions RoomigrantLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
22 changes: 11 additions & 11 deletions RoomigrantTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// 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()
jcenter()
}

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'
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bae342b

Please sign in to comment.