Yigit Boyar | 19b4110 | 2016-11-20 10:46:32 -0800 | [diff] [blame] | 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 | buildscript { |
| 18 | addRepos(repositories) |
| 19 | dependencies { |
| 20 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | apply plugin: 'kotlin' |
| 25 | apply plugin: 'maven' |
| 26 | |
| 27 | def antlrOut = "$buildDir/generated/antlr/grammar-gen/" |
| 28 | sourceSets { |
| 29 | main.java.srcDirs += 'src/main/grammar-gen' |
| 30 | test.java.srcDirs += 'src/tests/kotlin' |
| 31 | main.java.srcDirs += antlrOut |
| 32 | } |
| 33 | |
| 34 | dependencies { |
Yigit Boyar | 2259e4d | 2016-11-25 18:26:10 -0800 | [diff] [blame] | 35 | // take from ButterKnife |
| 36 | def logger = new com.android.build.gradle.internal.LoggerWrapper(project.logger) |
| 37 | def sdkHandler = new com.android.build.gradle.internal.SdkHandler(project, logger) |
| 38 | |
Yigit Boyar | 2eb5199 | 2016-12-13 15:00:07 -0800 | [diff] [blame^] | 39 | compile project(":room:common") |
Yigit Boyar | 19b4110 | 2016-11-20 10:46:32 -0800 | [diff] [blame] | 40 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" |
| 41 | compile "com.google.auto:auto-common:$auto_common_version" |
| 42 | compile "com.squareup:javapoet:$javapoet_version" |
| 43 | compile 'org.antlr:antlr4:4.5.3' |
| 44 | testCompile "com.google.testing.compile:compile-testing:$compile_testing_version" |
Yigit Boyar | 19b4110 | 2016-11-20 10:46:32 -0800 | [diff] [blame] | 45 | testCompile "junit:junit:$junit_version" |
| 46 | testCompile "com.intellij:annotations:$intellij_annotation" |
Yigit Boyar | 1600cc1 | 2016-11-24 14:26:56 -0800 | [diff] [blame] | 47 | testCompile "org.mockito:mockito-core:$mockito_version" |
Yigit Boyar | efaf86a | 2016-12-02 15:16:35 -0800 | [diff] [blame] | 48 | testCompile fileTree(dir: "${sdkHandler.sdkFolder}/platforms/android-$target_sdk_version/", |
| 49 | include : "android.jar") |
Yigit Boyar | 2eb5199 | 2016-12-13 15:00:07 -0800 | [diff] [blame^] | 50 | testCompile fileTree(dir: "${new File(project(":room:runtime").buildDir, "libJar")}", |
| 51 | include : "*.jar") |
| 52 | testCompile fileTree(dir: "${new File(project(":room:db").buildDir, "libJar")}", |
| 53 | include : "*.jar") |
Yigit Boyar | efaf86a | 2016-12-02 15:16:35 -0800 | [diff] [blame] | 54 | testCompile files(org.gradle.internal.jvm.Jvm.current().getToolsJar()) |
Yigit Boyar | 19b4110 | 2016-11-20 10:46:32 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | uploadArchives { |
| 58 | repositories { |
| 59 | mavenDeployer { |
| 60 | repository(url: rootProject.ext.localMavenRepo) |
Yigit Boyar | fb3e49e | 2016-12-12 10:24:49 -0800 | [diff] [blame] | 61 | pom.artifactId = 'compiler' |
Yigit Boyar | 19b4110 | 2016-11-20 10:46:32 -0800 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | def generateAntlrTask = task('generateAntlrGrammar', type: JavaExec) { |
| 67 | def outFolder = file(antlrOut) |
| 68 | outputs.dir(outFolder) |
| 69 | inputs.dir("$projectDir/SQLite.g4") |
| 70 | classpath configurations.runtime |
| 71 | main "org.antlr.v4.Tool" |
| 72 | args "SQLite.g4", "-visitor", "-o", new File(outFolder, "com/android/support/room/parser").path, |
| 73 | "-package", "com.android.support.room.parser" |
| 74 | } |
| 75 | |
| 76 | tasks.findByName("compileKotlin").dependsOn(generateAntlrTask) |
Yigit Boyar | 2eb5199 | 2016-12-13 15:00:07 -0800 | [diff] [blame^] | 77 | tasks.findByName("compileKotlin").dependsOn(":room:runtime:jarDebug") |
| 78 | tasks.findByName("compileKotlin").dependsOn(":room:db:jarDebug") |
Yigit Boyar | 19b4110 | 2016-11-20 10:46:32 -0800 | [diff] [blame] | 79 | |
| 80 | createKotlinCheckstyle(project) |
| 81 | |