| /* |
| * Copyright (C) 2015 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. |
| */ |
| |
| configurations { |
| androidJar |
| } |
| |
| /** |
| * Gradle task for JAR creation that can be reused for library projects which don't have any |
| * resources. This is required because library modules by default only create an AAR artifact. |
| * The code below creates a make<variant>AndroidJar tasks which compiles the source of a |
| * given project, excludes the BuildConfig file from the JAR and adds it to the output of the |
| * androidJar configuration. |
| */ |
| android.libraryVariants.all { variant -> |
| if ('release' == variant.buildType.name || 'debug' == variant.buildType.name) { |
| def androidJarTask = project.tasks.create("make${variant.name.capitalize()}AndroidJar", Jar) |
| androidJarTask.from(variant.javaCompile.destinationDir) |
| androidJarTask.destinationDir = project.file("$buildDir/intermediates/android-jar/") |
| androidJarTask.excludes += '**/BuildConfig*' |
| |
| androidJarTask.dependsOn variant.javaCompile |
| |
| project.artifacts.add('androidJar', androidJarTask) |
| } |
| } |