Skip to content

Commit 6560151

Browse files
committed
Refactor bootclasspath impl for dackka
Instead of having a separate extension method for it, just use the already fetched `LibraryExtension`.
1 parent 706e275 commit 6560151

File tree

2 files changed

+24
-35
lines changed

2 files changed

+24
-35
lines changed

buildSrc/src/main/java/com/google/firebase/gradle/plugins/DackkaPlugin.kt

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,31 @@ abstract class DackkaPlugin : Plugin<Project> {
7070

7171
private fun registerGenerateDackkaDocumentationTask(project: Project) =
7272
project.tasks.register<GenerateDocumentationTask>("generateDackkaDocumentation") {
73-
project.extensions.getByType<LibraryExtension>().libraryVariants.all {
74-
if (name == "release") {
75-
mustRunAfter("createFullJarRelease")
76-
dependsOn("createFullJarRelease")
77-
78-
val classpath = project.provider {
79-
runtimeConfiguration.getJars() + project.javadocConfig.getJars() + project.bootClasspath
80-
}
81-
82-
val sourcesForJava = sourceSets.flatMap {
83-
it.javaDirectories.map { it.absoluteFile } + projectSpecificSources(project)
73+
with(project.extensions.getByType<LibraryExtension>()) {
74+
libraryVariants.all {
75+
if (name == "release") {
76+
mustRunAfter("createFullJarRelease")
77+
dependsOn("createFullJarRelease")
78+
79+
val classpath = project.provider {
80+
runtimeConfiguration.getJars() + project.javadocConfig.getJars() + bootClasspath
81+
}
82+
83+
val sourcesForJava = sourceSets.flatMap {
84+
it.javaDirectories.map { it.absoluteFile } + projectSpecificSources(project)
85+
}
86+
87+
// this will become useful with the agp upgrade, as they're separate in 7.x+
88+
val sourcesForKotlin = emptyList<File>()
89+
val excludedFiles = emptyList<File>() + projectSpecificSuppressedFiles(project)
90+
91+
dependencies.set(classpath)
92+
javaSources.set(sourcesForJava)
93+
kotlinSources.set(sourcesForKotlin)
94+
suppressedFiles.set(excludedFiles)
95+
96+
applyCommonConfigurations()
8497
}
85-
86-
// this will become useful with the agp upgrade, as they're separate in 7.x+
87-
val sourcesForKotlin = emptyList<File>()
88-
val excludedFiles = emptyList<File>() + projectSpecificSuppressedFiles(project)
89-
90-
dependencies.set(classpath)
91-
javaSources.set(sourcesForJava)
92-
kotlinSources.set(sourcesForKotlin)
93-
suppressedFiles.set(excludedFiles)
94-
95-
applyCommonConfigurations()
9698
}
9799
}
98100
}

buildSrc/src/main/java/com/google/firebase/gradle/plugins/ProjectUtils.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
// limitations under the License.
1414
package com.google.firebase.gradle.plugins
1515

16-
import com.android.build.gradle.BaseExtension
17-
import java.io.File
1816
import org.gradle.api.Project
1917
import org.gradle.api.artifacts.Configuration
2018
import org.gradle.api.attributes.Attribute
21-
import org.gradle.api.plugins.ExtensionContainer
22-
import org.gradle.kotlin.dsl.getByType
2319

2420
fun Project.isAndroid(): Boolean =
2521
listOf("com.android.application", "com.android.library", "com.android.test")
@@ -30,15 +26,6 @@ fun toBoolean(value: Any?): Boolean {
3026
return "true" == trimmed || "y" == trimmed || "1" == trimmed
3127
}
3228

33-
/**
34-
* Shorthand for [BaseExtension.getBootClasspath]
35-
*
36-
* This method assumes your project has the [BaseExtension] extension,
37-
* as it uses [ExtensionContainer.getByType]
38-
*/
39-
val Project.bootClasspath: List<File>
40-
get() = extensions.getByType<BaseExtension>().bootClasspath
41-
4229
/**
4330
* Finds or creates the javadocClasspath [Configuration].
4431
*/

0 commit comments

Comments
 (0)