@@ -37,8 +37,7 @@ abstract class DackkaPlugin : Plugin<Project> {
37
37
val outputDirectory = generateDocumentation.flatMap { it.outputDirectory }
38
38
val firesiteTransform = registerFiresiteTransformTask(project, outputDirectory)
39
39
val deleteJavaReferences = registerDeleteDackkaGeneratedJavaReferencesTask(project, outputDirectory)
40
- val copyOutputToCommonDirectory =
41
- registerCopyDackkaOutputToCommonDirectoryTask(project, outputDirectory)
40
+ val copyOutputToCommonDirectory = registerCopyDackkaOutputToCommonDirectoryTask(project, outputDirectory)
42
41
43
42
project.tasks.register(" kotlindoc" ) {
44
43
group = " documentation"
@@ -68,60 +67,61 @@ abstract class DackkaPlugin : Plugin<Project> {
68
67
)
69
68
}
70
69
71
- private fun registerGenerateDackkaDocumentationTask (project : Project ) =
72
- project.tasks.register<GenerateDocumentationTask >(" generateDackkaDocumentation" ) {
73
- with (project.extensions.getByType<LibraryExtension >()) {
74
- libraryVariants.all {
75
- if (name == " release" ) {
76
- mustRunAfter(" createFullJarRelease" )
77
- dependsOn(" createFullJarRelease" )
70
+ // TODO(b/243534168): Refactor when fixed, so we no longer need stubs
71
+ private fun registerGenerateDackkaDocumentationTask (project : Project ): Provider <GenerateDocumentationTask > {
72
+ val docStubs = project.tasks.register<GenerateStubsTask >(" docStubsForDackkaInput" )
73
+ val docsTask = project.tasks.register<GenerateDocumentationTask >(" generateDackkaDocumentation" )
74
+ with (project.extensions.getByType<LibraryExtension >()) {
75
+ libraryVariants.all {
76
+ if (name == " release" ) {
77
+ val isKotlin = project.plugins.hasPlugin(" kotlin-android" )
78
78
79
- val classpath = project.provider {
80
- runtimeConfiguration.getJars() + project.javadocConfig.getJars() + bootClasspath
81
- }
79
+ val classpath = runtimeConfiguration.getJars() + project.javadocConfig.getJars() + bootClasspath
82
80
83
- val sourcesForJava = sourceSets.flatMap {
84
- it.javaDirectories.map { it.absoluteFile } + projectSpecificSources(project)
85
- }
81
+ val sourcesForJava = sourceSets.flatMap {
82
+ it.javaDirectories.map { it.absoluteFile }
83
+ }
84
+
85
+ docStubs.configure {
86
+ classPath = project.files(classpath)
87
+ sources.set(project.provider { sourcesForJava })
88
+ }
86
89
87
- // this will become useful with the agp upgrade, as they're separate in 7.x+
90
+ docsTask.configure {
88
91
val sourcesForKotlin = emptyList<File >()
89
- val excludedFiles = emptyList<File >() + projectSpecificSuppressedFiles(project)
90
92
91
- dependencies.set(classpath)
92
- javaSources.set(sourcesForJava)
93
- kotlinSources.set(sourcesForKotlin)
93
+ val excludedFiles = if (! isKotlin) projectSpecificSuppressedFiles(project) else emptyList()
94
+ val fixedJavaSources = if (! isKotlin) listOf (project.docStubs) else sourcesForJava
95
+
96
+ javaSources.set(fixedJavaSources)
94
97
suppressedFiles.set(excludedFiles)
95
98
99
+ kotlinSources.set(sourcesForKotlin)
100
+ dependencies.set(classpath)
101
+
96
102
applyCommonConfigurations()
97
103
}
98
104
}
99
105
}
100
106
}
101
-
102
- // TODO(b/243534168): Remove when fixed
103
- private fun projectSpecificSources (project : Project ) =
104
- when (project.name) {
105
- " firebase-common" -> {
106
- project.project(" :firebase-firestore" ).files(" src/main/java/com/google/firebase" ).toList()
107
- }
108
- else -> emptyList()
109
- }
107
+ return docsTask
108
+ }
110
109
111
110
// TODO(b/243534168): Remove when fixed
112
111
private fun projectSpecificSuppressedFiles (project : Project ): List <File > =
113
112
when (project.name) {
114
113
" firebase-common" -> {
115
- val firestoreProject = project.project(" :firebase-firestore" )
116
- firestoreProject.files(" src/main/java/com/google/firebase/firestore" ).toList()
114
+ project.files(" ${project.docStubs} /com/google/firebase/firestore" ).toList()
117
115
}
118
116
" firebase-firestore" -> {
119
- project.files(" src/main/java /com/google/firebase/Timestamp.java" ).toList()
117
+ project.files(" ${project.docStubs} /com/google/firebase/Timestamp.java" ).toList()
120
118
}
121
119
else -> emptyList()
122
120
}
123
121
124
122
private fun GenerateDocumentationTask.applyCommonConfigurations () {
123
+ dependsOnAndMustRunAfter(" createFullJarRelease" )
124
+
125
125
val dackkaFile = project.provider { project.dackkaConfig.singleFile }
126
126
val dackkaOutputDirectory = File (project.buildDir, " dackkaDocumentation" )
127
127
0 commit comments