Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
Sergey Vasilinets | 98971a7 | 2018-04-18 10:33:33 -0700 | [diff] [blame^] | 17 | import static androidx.build.dependencies.DependenciesKt.* |
| 18 | import androidx.build.LibraryGroups |
| 19 | import androidx.build.LibraryVersions |
| 20 | import androidx.build.SupportLibraryExtension |
| 21 | import androidx.build.SupportConfig |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 22 | |
Sergey Vasilinets | 98971a7 | 2018-04-18 10:33:33 -0700 | [diff] [blame^] | 23 | apply plugin: androidx.build.SupportKotlinLibraryPlugin |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 24 | apply plugin: 'java-gradle-plugin' |
| 25 | |
Sergey Vasilinets | 973a5c0 | 2018-01-11 23:39:12 -0800 | [diff] [blame] | 26 | ext.generatedResources = "$buildDir/generated/resources" |
| 27 | |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 28 | sourceSets { |
| 29 | test.java.srcDirs += 'src/tests/kotlin' |
Sergey Vasilinets | 973a5c0 | 2018-01-11 23:39:12 -0800 | [diff] [blame] | 30 | test.resources.srcDirs += generatedResources |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | dependencies { |
Sergey Vasilinets | 973a5c0 | 2018-01-11 23:39:12 -0800 | [diff] [blame] | 34 | compile build_libs.gradle |
Ian Lake | c4ae7e6 | 2018-04-12 14:36:09 -0700 | [diff] [blame] | 35 | compile project(":navigation:navigation-safe-args-generator") |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 36 | compile gradleApi() |
Sergey Vasilinets | 7e7dfac | 2018-03-09 14:05:29 -0800 | [diff] [blame] | 37 | compile(GSON) |
Sergey Vasilinets | 973a5c0 | 2018-01-11 23:39:12 -0800 | [diff] [blame] | 38 | testCompile gradleTestKit() |
| 39 | testCompile(JUNIT) |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 40 | } |
| 41 | |
Sergey Vasilinets | 973a5c0 | 2018-01-11 23:39:12 -0800 | [diff] [blame] | 42 | task generateSdkResource() { |
| 43 | inputs.property("compileSdkVersion", SupportConfig.CURRENT_SDK_VERSION) |
| 44 | inputs.property("buildToolsVersion", SupportConfig.BUILD_TOOLS_VERSION) |
| 45 | outputs.dir(generatedResources) |
| 46 | doLast { |
| 47 | // Properties.write will have a timestamp, that invalidates the task, |
| 48 | // so we don't use it and write a file manually |
| 49 | new File(generatedResources, "sdk.prop").withWriter('UTF-8') { writer -> |
| 50 | writer.write("compileSdkVersion=$SupportConfig.CURRENT_SDK_VERSION\n") |
| 51 | writer.write("buildToolsVersion=$SupportConfig.BUILD_TOOLS_VERSION\n") |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
Sergey Vasilinets | 7e7dfac | 2018-03-09 14:05:29 -0800 | [diff] [blame] | 56 | test { |
| 57 | testLogging { showStandardStreams = true } |
| 58 | } |
| 59 | |
Sergey Vasilinets | 973a5c0 | 2018-01-11 23:39:12 -0800 | [diff] [blame] | 60 | tasks["compileTestJava"].dependsOn generateSdkResource |
| 61 | |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 62 | gradlePlugin { |
| 63 | plugins { |
| 64 | safeargs { |
Ian Lake | 1503d52 | 2018-02-15 13:43:50 -0800 | [diff] [blame] | 65 | id = "androidx.navigation.safeargs" |
| 66 | implementationClass = "androidx.navigation.safeargs.gradle.SafeArgsPlugin" |
Sergey Vasilinets | 968529a | 2018-01-03 16:13:53 -0800 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | supportLibrary { |
| 72 | name = "Android Navigation TypeSafe Arguments Gradle Plugin" |
| 73 | publish = true |
| 74 | mavenVersion = LibraryVersions.NAVIGATION |
| 75 | mavenGroup = LibraryGroups.NAVIGATION |
| 76 | inceptionYear = "2017" |
| 77 | description = "Android Navigation TypeSafe Arguments Gradle Plugin" |
| 78 | url = SupportLibraryExtension.ARCHITECTURE_URL |
| 79 | } |