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 
     17 
     18 import androidx.build.SupportConfig
     19 
     20 import static androidx.build.dependencies.DependenciesKt.*
     21 import androidx.build.LibraryGroups
     22 import androidx.build.LibraryVersions
     23 import androidx.build.SupportLibraryExtension
     24 
     25 plugins {
     26     id("SupportKotlinLibraryPlugin")
     27 }
     28 
     29 def antlrOut = "$buildDir/generated/antlr/grammar-gen/"
     30 sourceSets {
     31     main.java.srcDirs += 'src/main/grammar-gen'
     32     test.java.srcDirs += 'src/tests/kotlin'
     33     main.java.srcDirs += antlrOut
     34 }
     35 
     36 // Temporary hack to stop AS to adding two guavas into test's classpath
     37 configurations.all {
     38     resolutionStrategy {
     39         force GUAVA
     40     }
     41 }
     42 
     43 dependencies {
     44     // taken from ButterKnife
     45     def logger = new com.android.build.gradle.internal.LoggerWrapper(project.logger)
     46     def sdkHandler = new com.android.build.gradle.internal.SdkHandler(project, logger)
     47     compile(project(":room:room-common"))
     48     compile(project(":room:room-migration"))
     49     compile(KOTLIN_STDLIB)
     50     compile(AUTO_COMMON)
     51     compile(JAVAPOET)
     52     compile(ANTLR)
     53     compile(XERIAL)
     54     compile(KOTLIN_METADATA)
     55     compile(APACHE_COMMONS_CODEC)
     56     testCompile(GOOGLE_COMPILE_TESTING)
     57     testCompile project(":paging:paging-common")
     58     testCompile(JUNIT)
     59     testCompile(INTELLIJ_ANNOTATIONS)
     60     testCompile(JSR250)
     61     testCompile(MOCKITO_CORE)
     62     testCompile fileTree(dir: "${sdkHandler.sdkFolder}/platforms/android-$SupportConfig.CURRENT_SDK_VERSION/",
     63             include : "android.jar")
     64     testCompile fileTree(dir: "${new File(project(":room:room-runtime").buildDir, "libJar")}",
     65             include : "*.jar")
     66     testCompile fileTree(dir: "${new File(project(":sqlite:sqlite").buildDir, "libJar")}",
     67             include : "*.jar")
     68     testCompile files(org.gradle.internal.jvm.Jvm.current().getToolsJar())
     69 }
     70 
     71 def generateAntlrTask = task('generateAntlrGrammar', type: JavaExec) {
     72     def outFolder = file(antlrOut)
     73     outputs.dir(outFolder)
     74     inputs.file("$projectDir/SQLite.g4")
     75     classpath configurations.runtime
     76     main "org.antlr.v4.Tool"
     77     args "SQLite.g4", "-visitor", "-o", new File(outFolder, "androidx/room/parser").path,
     78             "-package", "androidx.room.parser"
     79 }
     80 
     81 tasks.findByName("compileKotlin").dependsOn(generateAntlrTask)
     82 tasks.findByName("compileKotlin").dependsOn(":room:room-runtime:jarDebug")
     83 tasks.findByName("compileKotlin").dependsOn(":sqlite:sqlite:jarDebug")
     84 
     85 supportLibrary {
     86     name = "Android Room Compiler"
     87     publish = true
     88     generateDocs = false
     89     mavenVersion = LibraryVersions.ROOM
     90     mavenGroup = LibraryGroups.ROOM
     91     inceptionYear = "2017"
     92     description = "Android Room annotation processor"
     93     url = SupportLibraryExtension.ARCHITECTURE_URL
     94 }
     95