/
GradleDokkaSourceSetBuilder.kt
209 lines (164 loc) · 7.13 KB
/
GradleDokkaSourceSetBuilder.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package org.jetbrains.dokka.gradle
import groovy.lang.Closure
import org.gradle.api.*
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.*
import org.gradle.kotlin.dsl.listProperty
import org.gradle.kotlin.dsl.setProperty
import org.jetbrains.dokka.*
import java.io.File
import java.net.URL
open class GradleDokkaSourceSetBuilder(
@Transient @get:Input val name: String,
@Transient @get:Internal internal val project: Project,
@Transient @get:Internal internal val sourceSetIdFactory: NamedDomainObjectFactory<DokkaSourceSetID>,
) : DokkaConfigurationBuilder<DokkaSourceSetImpl> {
@Input
val sourceSetID: DokkaSourceSetID = sourceSetIdFactory.create(name)
@Input
val suppress: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(false)
@Classpath
@Optional
val classpath: ConfigurableFileCollection = project.files()
@Input
@Optional
val displayName: Property<String?> = project.objects.safeProperty()
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
val sourceRoots: ConfigurableFileCollection = project.objects.fileCollection()
@Input
val dependentSourceSets: SetProperty<DokkaSourceSetID> = project.objects.setProperty<DokkaSourceSetID>()
.convention(emptySet())
@InputFiles
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
val samples: ConfigurableFileCollection = project.files()
@InputFiles
@Optional
@PathSensitive(PathSensitivity.RELATIVE)
val includes: ConfigurableFileCollection = project.files()
@Input
val includeNonPublic: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(DokkaDefaults.includeNonPublic)
@Input
val documentedVisibilities: SetProperty<DokkaConfiguration.Visibility> = project.objects.setProperty<DokkaConfiguration.Visibility>()
.convention(DokkaDefaults.documentedVisibilities)
@Input
val reportUndocumented: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(DokkaDefaults.reportUndocumented)
@Input
val skipEmptyPackages: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(DokkaDefaults.skipEmptyPackages)
@Input
val skipDeprecated: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(DokkaDefaults.skipDeprecated)
@Input
val suppressGeneratedFiles: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(true)
@Input
val jdkVersion: Property<Int> = project.objects.safeProperty<Int>()
.safeConvention(DokkaDefaults.jdkVersion)
@Nested
val sourceLinks: SetProperty<GradleSourceLinkBuilder> = project.objects.setProperty<GradleSourceLinkBuilder>()
.convention(emptySet())
@Nested
val perPackageOptions: ListProperty<GradlePackageOptionsBuilder> =
project.objects.listProperty<GradlePackageOptionsBuilder>()
.convention(emptyList())
@Nested
val externalDocumentationLinks: SetProperty<GradleExternalDocumentationLinkBuilder> =
project.objects.setProperty<GradleExternalDocumentationLinkBuilder>()
.convention(emptySet())
@Input
@Optional
val languageVersion: Property<String?> = project.objects.safeProperty()
@Input
@Optional
val apiVersion: Property<String?> = project.objects.safeProperty()
@Input
val noStdlibLink: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(DokkaDefaults.noStdlibLink)
@Input
val noJdkLink: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(DokkaDefaults.noJdkLink)
@Input
val noAndroidSdkLink: Property<Boolean> = project.objects.safeProperty<Boolean>()
.safeConvention(false)
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
val suppressedFiles: ConfigurableFileCollection = project.files()
@Input
@Optional
val platform: Property<Platform> = project.objects.safeProperty<Platform>()
.safeConvention(Platform.DEFAULT)
fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = sourceSetIdFactory.create(sourceSetName)
fun dependsOn(sourceSet: SourceSet) {
dependsOn(DokkaSourceSetID(sourceSet.name))
}
fun dependsOn(sourceSet: GradleDokkaSourceSetBuilder) {
dependsOn(sourceSet.sourceSetID)
}
fun dependsOn(sourceSet: DokkaConfiguration.DokkaSourceSet) {
dependsOn(sourceSet.sourceSetID)
}
fun dependsOn(sourceSetName: String) {
dependsOn(DokkaSourceSetID(sourceSetName))
}
fun dependsOn(sourceSetID: DokkaSourceSetID) {
dependentSourceSets.add(sourceSetID)
}
fun sourceRoot(file: File) {
sourceRoots.from(file)
}
fun sourceRoot(path: String) {
sourceRoot(project.file(path))
}
@Suppress("DEPRECATION") // TODO [beresnev] ConfigureUtil will be removed in Gradle 8
fun sourceLink(c: Closure<in GradleSourceLinkBuilder>) {
val configured = org.gradle.util.ConfigureUtil.configure(c, GradleSourceLinkBuilder(project))
sourceLinks.add(configured)
}
fun sourceLink(action: Action<in GradleSourceLinkBuilder>) {
val sourceLink = GradleSourceLinkBuilder(project)
action.execute(sourceLink)
sourceLinks.add(sourceLink)
}
@Suppress("DEPRECATION") // TODO [beresnev] ConfigureUtil will be removed in Gradle 8
fun perPackageOption(c: Closure<in GradlePackageOptionsBuilder>) {
val configured = org.gradle.util.ConfigureUtil.configure(c, GradlePackageOptionsBuilder(project))
perPackageOptions.add(configured)
}
fun perPackageOption(action: Action<in GradlePackageOptionsBuilder>) {
val option = GradlePackageOptionsBuilder(project)
action.execute(option)
perPackageOptions.add(option)
}
@Suppress("DEPRECATION") // TODO [beresnev] ConfigureUtil will be removed in Gradle 8
fun externalDocumentationLink(c: Closure<in GradleExternalDocumentationLinkBuilder>) {
val link = org.gradle.util.ConfigureUtil.configure(c, GradleExternalDocumentationLinkBuilder(project))
externalDocumentationLinks.add(link)
}
fun externalDocumentationLink(action: Action<in GradleExternalDocumentationLinkBuilder>) {
val link = GradleExternalDocumentationLinkBuilder(project)
action.execute(link)
externalDocumentationLinks.add(link)
}
fun externalDocumentationLink(url: String, packageListUrl: String? = null) {
externalDocumentationLink(URL(url), packageListUrl = packageListUrl?.let(::URL))
}
fun externalDocumentationLink(url: URL, packageListUrl: URL? = null) {
externalDocumentationLinks.add(
GradleExternalDocumentationLinkBuilder(project).apply {
this.url by url
if (packageListUrl != null) {
this.packageListUrl by packageListUrl
}
}
)
}
override fun build(): DokkaSourceSetImpl = toDokkaSourceSetImpl()
}