Home | History | Annotate | Download | only in compiler
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 import android.support.LibraryVersions
     17 import android.support.SupportLibraryExtension
     18 
     19 apply plugin: android.support.SupportKotlinLibraryPlugin
     20 
     21 def antlrOut = "$buildDir/generated/antlr/grammar-gen/"
     22 sourceSets {
     23     main.java.srcDirs += 'src/main/grammar-gen'
     24     test.java.srcDirs += 'src/tests/kotlin'
     25     main.java.srcDirs += antlrOut
     26 }
     27 project.ext.noDocs = true
     28 version = LibraryVersions.ROOM.toString()
     29 
     30 // Temporary hack to stop AS to adding two guavas into test's classpath
     31 configurations.all {
     32     resolutionStrategy {
     33         force libs.guava
     34     }
     35 }
     36 
     37 dependencies {
     38     // taken from ButterKnife
     39     def logger = new com.android.build.gradle.internal.LoggerWrapper(project.logger)
     40     def sdkHandler = new com.android.build.gradle.internal.SdkHandler(project, logger)
     41     compile project(":room:common")
     42     compile project(":room:migration")
     43     compile libs.kotlin.stdlib
     44     compile libs.auto_common
     45     compile libs.javapoet
     46     compile libs.antlr
     47     compile libs.xerial
     48     compile libs.apache.commons.codec
     49     testCompile libs.google_compile_testing
     50     testCompile project(":paging:common")
     51     testCompile libs.junit
     52     testCompile libs.ij_annotations
     53     testCompile libs.jsr250
     54     testCompile libs.mockito_core
     55     testCompile fileTree(dir: "${sdkHandler.sdkFolder}/platforms/android-$tools.current_sdk/",
     56             include : "android.jar")
     57     testCompile fileTree(dir: "${new File(project(":room:runtime").buildDir, "libJar")}",
     58             include : "*.jar")
     59     testCompile fileTree(dir: "${new File(project(":persistence:db").buildDir, "libJar")}",
     60             include : "*.jar")
     61     testCompile files(org.gradle.internal.jvm.Jvm.current().getToolsJar())
     62 }
     63 
     64 def generateAntlrTask = task('generateAntlrGrammar', type: JavaExec) {
     65     def outFolder = file(antlrOut)
     66     outputs.dir(outFolder)
     67     inputs.dir("$projectDir/SQLite.g4")
     68     classpath configurations.runtime
     69     main "org.antlr.v4.Tool"
     70     args "SQLite.g4", "-visitor", "-o", new File(outFolder, "android/arch/persistence/room/parser").path,
     71             "-package", "android.arch.persistence.room.parser"
     72 }
     73 
     74 tasks.findByName("compileKotlin").dependsOn(generateAntlrTask)
     75 tasks.findByName("compileKotlin").dependsOn(":room:runtime:jarDebug")
     76 tasks.findByName("compileKotlin").dependsOn(":persistence:db:jarDebug")
     77 
     78 createKotlinCheckstyle(project)
     79 
     80 supportLibrary {
     81     name 'Android Room Compiler'
     82     publish true
     83     inceptionYear '2017'
     84     description "Android Room annotation processor"
     85     url SupportLibraryExtension.ARCHITECTURE_URL
     86 }
     87