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 17import static androidx.build.dependencies.DependenciesKt.* 18import androidx.build.LibraryGroups 19import androidx.build.LibraryVersions 20import androidx.build.SupportLibraryExtension 21import androidx.build.SupportConfig 22 23apply plugin: androidx.build.SupportKotlinLibraryPlugin 24apply plugin: 'java-gradle-plugin' 25 26ext.generatedResources = "$buildDir/generated/resources" 27 28sourceSets { 29 test.java.srcDirs += 'src/tests/kotlin' 30 test.resources.srcDirs += generatedResources 31} 32 33dependencies { 34 compile build_libs.gradle 35 compile project(":navigation:navigation-safe-args-generator") 36 compile gradleApi() 37 compile(GSON) 38 testCompile gradleTestKit() 39 testCompile(JUNIT) 40} 41 42task 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 56test { 57 testLogging { showStandardStreams = true } 58} 59 60tasks["compileTestJava"].dependsOn generateSdkResource 61 62gradlePlugin { 63 plugins { 64 safeargs { 65 id = "androidx.navigation.safeargs" 66 implementationClass = "androidx.navigation.safeargs.gradle.SafeArgsPlugin" 67 } 68 } 69} 70 71supportLibrary { 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} 80