1414 * limitations under the License.
1515 */
1616
17+ import com.android.build.gradle.internal.tasks.factory.dependsOn
1718import com.github.jk1.license.filter.DependencyFilter
1819import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
1920import com.github.jk1.license.filter.LicenseBundleNormalizer
@@ -169,7 +170,6 @@ dependencies {
169170}
170171
171172// Dependency check
172-
173173dependencyCheck {
174174 formats = listOf (" XML" , " HTML" )
175175 nvd.apiKey = System .getenv(" NVD_API_KEY" ) ? : properties[" nvdApiKey" ]?.toString() ? : " "
@@ -180,34 +180,53 @@ dependencyCheck {
180180// Dokka generation
181181dokka {
182182 dokkaSourceSets.configureEach {
183+ dokkaPublications.javadoc {
184+ outputDirectory.set(rootProject.file(" docs/javadoc" ))
185+ }
183186 dokkaPublications.html {
184- outputDirectory.set(rootProject.file(" docs" ))
187+ outputDirectory.set(rootProject.file(" docs/html " ))
185188 }
186189 externalDocumentationLinks.register(" android" ) {
187190 url(" https://developer.android.com/reference" )
188191 packageListUrl(" https://developer.android.com/reference/kotlin/package-list" )
189192 }
190- externalDocumentationLinks.register(" java" ) {
191- url(" https://docs.oracle.com/en/java/javase/17/docs/api/" )
192- packageListUrl(" https://docs.oracle.com/en/java/javase/17/docs/api/allpackages-index.html" )
193- }
194193 }
195194}
196195
197- val dokkaHtmlJar by tasks.registering(Jar ::class ) {
198- group = " documentation"
196+ val dokkaGenerateJavadocJar by tasks.registering(Jar ::class ) {
197+ group = " dokka"
198+ dependsOn(tasks.dokkaGeneratePublicationJavadoc)
199+ from(tasks.dokkaGeneratePublicationJavadoc.flatMap { it.outputDirectory })
200+ archiveClassifier.set(" javadoc" )
201+ description = " Assembles a JAR containing the Javadoc-style documentation generated by Dokka."
202+ }
203+
204+ val dokkaGenerateHtmlJar by tasks.registering(Jar ::class ) {
205+ group = " dokka"
199206 dependsOn(tasks.dokkaGeneratePublicationHtml)
200207 from(tasks.dokkaGeneratePublicationHtml.flatMap { it.outputDirectory })
201208 archiveClassifier.set(" html-docs" )
202209 description = " Assembles a JAR containing the HTML documentation generated by Dokka."
203210}
204211
205- val dokkaJavadocJar by tasks.registering(Jar ::class ) {
206- group = " documentation"
207- dependsOn(tasks.dokkaGeneratePublicationJavadoc)
208- from(tasks.dokkaGeneratePublicationJavadoc.flatMap { it.outputDirectory })
209- archiveClassifier.set(" javadoc" )
210- description = " Assembles a JAR containing the Javadoc-style documentation generated by Dokka."
212+ val dokkaCleanJavadoc by tasks.registering(Delete ::class ) {
213+ group = " dokka"
214+ delete = setOf (rootProject.file(" docs/javadoc" ))
215+ description = " It removes the documentation generated by Dokka."
216+ }
217+
218+ val dokkaCleanHtml by tasks.registering(Delete ::class ) {
219+ group = " dokka"
220+ delete = setOf (rootProject.file(" docs/html" ))
221+ description = " It removes the documentation generated by Dokka."
222+ }
223+
224+ tasks.dokkaGeneratePublicationJavadoc.dependsOn(dokkaCleanJavadoc)
225+ tasks.dokkaGeneratePublicationHtml.dependsOn(dokkaCleanHtml)
226+
227+ val dokkaClean by tasks.registering {
228+ group = " dokka"
229+ dependsOn(dokkaCleanJavadoc, dokkaCleanHtml)
211230}
212231
213232// Third-party licenses report
@@ -236,8 +255,8 @@ tasks.generateLicenseReport.configure {
236255// Build documentation and license report
237256tasks.register<Task >(" buildDocumentation" ) {
238257 group = " documentation"
239- dependsOn(" dokkaGfm " , " generateLicenseReport" )
240- description = " Aggregates all documentation tasks (Dokka GFM , License Report)."
258+ dependsOn(" dokkaGenerate " , " generateLicenseReport" )
259+ description = " Aggregates all documentation tasks (Dokka, License Report)."
241260}
242261tasks.assemble.configure {
243262 finalizedBy(" buildDocumentation" )
0 commit comments