1// Copyright (C) 2017 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14apply from: "${buildscript.sourceFile.parentFile}/constants.gradle"
15apply from: "${buildscript.sourceFile.parentFile}/javadoc_util.gradle"
16
17android.libraryVariants.all { variant ->
18    def name = variant.buildType.name
19    if (name != "release") {
20        return // Skip non-release builds.
21    }
22    def allSourceDirs = variant.sourceSets.inject ([]) {
23        acc, val -> acc << val.javaDirectories
24    }
25    task("generateJavadoc", type: Javadoc) {
26        description = "Generates Javadoc for the ${javadocTitle}."
27        title = "ExoPlayer ${javadocTitle}"
28        source = allSourceDirs + "${buildDir}/generated/aidl_source_output_dir/"
29        options {
30            links "https://developer.android.com/reference",
31                  "https://guava.dev/releases/$project.ext.guavaVersion/api/docs"
32            encoding = "UTF-8"
33        }
34        options.addBooleanOption "-no-module-directories", true
35        exclude "**/BuildConfig.java"
36        exclude "**/R.java"
37        doFirst {
38            classpath =
39                files(
40                    variant.javaCompileProvider.get().classpath.files,
41                    project.android.getBootClasspath())
42        }
43        doLast {
44            copy {
45                from "src/main/javadoc"
46                into "$buildDir/docs/javadoc"
47            }
48            project.fixJavadoc()
49        }
50    }
51}
52