| /* |
| * Copyright (C) 2017 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| import static androidx.build.dependencies.DependenciesKt.* |
| import androidx.build.CompilationTarget |
| import androidx.build.LibraryGroups |
| import androidx.build.LibraryVersions |
| import androidx.build.AndroidXExtension |
| import androidx.build.SupportConfig |
| import androidx.build.Publish |
| |
| plugins { |
| id("AndroidXPlugin") |
| id("kotlin") |
| id("java-gradle-plugin") |
| } |
| |
| ext.generatedResources = "$buildDir/generated/resources" |
| ext.prebuiltsRoot = SupportConfig.getPrebuiltsRootPath(project) |
| ext.debugKeystore = SupportConfig.getKeystore(project) |
| |
| sourceSets { |
| test.java.srcDirs += 'src/tests/kotlin' |
| test.resources.srcDirs += generatedResources |
| } |
| |
| dependencies { |
| compile(SAFE_ARGS_ANDROID_GRADLE_PLUGIN) |
| compile(SAFE_ARGS_KOTLIN_GRADLE_PLUGIN) |
| compile project(":navigation:navigation-safe-args-generator") |
| compile gradleApi() |
| compile(GSON) |
| testCompile gradleTestKit() |
| testCompile(JUNIT) |
| } |
| |
| task generateSdkResource() { |
| inputs.property("prebuiltsRoot", prebuiltsRoot) |
| inputs.property("compileSdkVersion", SupportConfig.COMPILE_SDK_VERSION) |
| inputs.property("buildToolsVersion", SupportConfig.BUILD_TOOLS_VERSION) |
| inputs.property("minSdkVersion", SupportConfig.DEFAULT_MIN_SDK_VERSION) |
| inputs.property("debugKeystore", debugKeystore) |
| inputs.property("navigationCommon", SAFE_ARGS_NAVIGATION_COMMON) |
| inputs.property("kotlinStdlib", KOTLIN_STDLIB) |
| outputs.dir(generatedResources) |
| doLast { |
| // Properties.write will have a timestamp, that invalidates the task, |
| // so we don't use it and write a file manually |
| new File(generatedResources, "sdk.prop").withWriter('UTF-8') { writer -> |
| writer.write("prebuiltsRepo=$prebuiltsRoot\n") |
| writer.write("compileSdkVersion=\"$SupportConfig.COMPILE_SDK_VERSION\"\n") |
| writer.write("buildToolsVersion=$SupportConfig.BUILD_TOOLS_VERSION\n") |
| writer.write("minSdkVersion=$SupportConfig.DEFAULT_MIN_SDK_VERSION\n") |
| writer.write("debugKeystore=$debugKeystore\n") |
| writer.write("navigationCommon=$SAFE_ARGS_NAVIGATION_COMMON\n") |
| writer.write("kotlinStdlib=$KOTLIN_STDLIB\n") |
| } |
| } |
| } |
| |
| test { |
| testLogging { showStandardStreams = true } |
| } |
| |
| tasks["compileTestJava"].dependsOn generateSdkResource |
| |
| gradlePlugin { |
| plugins { |
| safeargsJava { |
| id = "androidx.navigation.safeargs" |
| implementationClass = "androidx.navigation.safeargs.gradle.SafeArgsJavaPlugin" |
| } |
| safeargsKotlin { |
| id = "androidx.navigation.safeargs.kotlin" |
| implementationClass = "androidx.navigation.safeargs.gradle.SafeArgsKotlinPlugin" |
| } |
| } |
| } |
| |
| androidx { |
| name = "Android Navigation TypeSafe Arguments Gradle Plugin" |
| publish = Publish.SNAPSHOT_AND_RELEASE |
| toolingProject = true |
| mavenVersion = LibraryVersions.NAVIGATION |
| mavenGroup = LibraryGroups.NAVIGATION |
| inceptionYear = "2017" |
| description = "Android Navigation TypeSafe Arguments Gradle Plugin" |
| url = AndroidXExtension.ARCHITECTURE_URL |
| compilationTarget = CompilationTarget.HOST |
| } |