1
- import org.jetbrains.dokka.gradle.DokkaTask
2
- import org.jetbrains.dokka.gradle.DokkaTaskPartial
3
- import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4
1
import java.net.URL
5
2
import java.time.OffsetDateTime
6
3
import java.time.format.DateTimeFormatter
7
4
5
+ import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
6
+ import org.jetbrains.dokka.gradle.DokkaTask
7
+ import org.jetbrains.dokka.gradle.DokkaTaskPartial
8
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
9
+
8
10
plugins {
9
11
with (Plugins ) {
10
12
id(" org.ajoberstar.grgit" ) version GRGIT
@@ -70,47 +72,27 @@ subprojects {
70
72
}
71
73
}
72
74
75
+ val actualJavaVersion = if (JAVA_VERSION <= 10 ) " 1.$JAVA_VERSION " else " $JAVA_VERSION "
76
+
73
77
configure<JavaPluginExtension > {
74
- sourceCompatibility = JavaVersion .valueOf(" VERSION_$JAVA_VERSION " )
78
+ sourceCompatibility = JavaVersion .valueOf(
79
+ " VERSION_${actualJavaVersion.replace(" ." , " _" )} "
80
+ )
75
81
targetCompatibility = sourceCompatibility
76
82
}
77
83
78
84
tasks {
79
- withType<Test > {
80
- useJUnitPlatform()
81
- }
82
-
83
85
withType<JavaCompile > {
84
- options.release.set(JAVA_VERSION )
86
+ sourceCompatibility = actualJavaVersion
87
+ targetCompatibility = actualJavaVersion
85
88
}
86
89
87
90
withType<KotlinCompile > {
88
- kotlinOptions.jvmTarget = " $JAVA_VERSION "
91
+ kotlinOptions.jvmTarget = actualJavaVersion
89
92
}
90
93
91
- withType<DokkaTaskPartial >().configureEach {
92
- dokkaSourceSets.configureEach {
93
- displayName.set(" ${Coordinates .name} /${project.name} on ${Coordinates .gitHost} " )
94
-
95
- skipDeprecated.set(false )
96
- includeNonPublic.set(false )
97
- skipEmptyPackages.set(true )
98
- reportUndocumented.set(true )
99
- suppressObviousFunctions.set(true )
100
-
101
- // Link the source to the documentation
102
- sourceLink {
103
- localDirectory.set(file(" src" ))
104
- remoteUrl.set(URL (" ${Coordinates .gitUrl} /tree/${Coordinates .mainGitBranch} /${project.name} /src" ))
105
- }
106
-
107
- /* *
108
- * @see config.Dokka.externalDocumentations
109
- */
110
- config.Dokka .externalDocumentations.forEach {
111
- externalDocumentationLink { url.set(URL (it)) }
112
- }
113
- }
94
+ withType<Test > {
95
+ useJUnitPlatform()
114
96
}
115
97
116
98
withType<Jar > {
@@ -126,26 +108,27 @@ subprojects {
126
108
127
109
with (Coordinates ) {
128
110
manifest.attributes(
129
- " Name" to group.replace(" ." , " /" ) + " /" ,
111
+ " Name" to group.replace(" ." , " /" ) + " /" + project.name + " / " ,
130
112
131
113
" Created-By" to " $javaVersion ($javaVendor $javaVmVersion )" ,
132
114
" Build-Date" to buildDate,
133
115
" Build-Time" to buildTime,
134
116
" Build-Revision" to buildRevision,
135
117
136
- " Specification-Title" to " $name : ${ project.name} " ,
118
+ " Specification-Title" to project.name,
137
119
" Specification-Version" to prettyProjectVersion,
138
120
" Specification-Vendor" to vendor,
139
121
140
- " Implementation-Title" to project.name,
122
+ " Implementation-Title" to " $name - ${ project.name} " ,
141
123
" Implementation-Version" to buildRevision,
142
124
" Implementation-Vendor" to vendor,
143
125
144
- " Bundle-Name" to name,
145
- " Bundle-Description" to description,
126
+ " Bundle-Name" to " $name -${project.name} " ,
127
+ // the README.md file always contains the module description on its 3rd line.
128
+ " Bundle-Description" to projectDir.resolve(" README.md" ).readLines()[2 ],
146
129
" Bundle-DocURL" to gitUrl,
147
130
" Bundle-Vendor" to vendor,
148
- " Bundle-SymbolicName" to " $group .$name " ,
131
+ " Bundle-SymbolicName" to " $group .${project. name} " ,
149
132
)
150
133
}
151
134
@@ -162,6 +145,43 @@ subprojects {
162
145
from(" LICENSE" )
163
146
}
164
147
148
+ withType<DokkaTask >().configureEach {
149
+ moduleName.set(" ${Coordinates .name} -${project.name} " )
150
+ }
151
+
152
+ withType<DokkaTaskPartial >().configureEach {
153
+ moduleName.set(project.name)
154
+
155
+ dokkaSourceSets.configureEach {
156
+ includes.from(projectDir.resolve(" README.md" ))
157
+
158
+ displayName.set(" ${Coordinates .name} /${moduleName.get()} on ${Coordinates .gitHost} " )
159
+
160
+ skipDeprecated.set(false )
161
+ includeNonPublic.set(false )
162
+ skipEmptyPackages.set(true )
163
+ reportUndocumented.set(true )
164
+ suppressObviousFunctions.set(true )
165
+
166
+ // Link the source to the documentation
167
+ sourceLink {
168
+ localDirectory.set(file(" src" ))
169
+ remoteUrl.set(
170
+ URL (
171
+ " ${Coordinates .gitUrl} /tree/${Coordinates .mainGitBranch} /${project.name} /src"
172
+ )
173
+ )
174
+ }
175
+
176
+ /* *
177
+ * @see config.Dokka.externalDocumentations
178
+ */
179
+ config.Dokka .externalDocumentations.forEach {
180
+ externalDocumentationLink { url.set(URL (it)) }
181
+ }
182
+ }
183
+ }
184
+
165
185
// The Javadoc artifact, containing the Dokka output and the LICENSE file.
166
186
create(" javadocJar" , Jar ::class ) {
167
187
group = " build"
@@ -227,30 +247,16 @@ subprojects {
227
247
}
228
248
}
229
249
230
- afterEvaluate {
231
- tasks.dokkaHtmlMultiModule {
232
- val moduleFile = File (
233
- projectDir,
234
- " MODULE.temp.${java.util.UUID .randomUUID()} .md"
235
- )
236
-
237
- // In order to have a description on the rendered docs, we have to have
238
- // a file with the # Module thingy in it. That's what we're
239
- // automagically creating and deleting here.
240
- run {
241
- doFirst {
242
- moduleFile.deleteOnExit()
243
- moduleFile.writeText(
244
- " # ${Coordinates .name} \n ${Coordinates .description} "
245
- )
246
- }
247
-
248
- doLast { moduleFile.delete() }
249
- }
250
-
251
- moduleName.set(Coordinates .name)
252
- includes.from(moduleFile.path)
250
+ tasks.withType<DokkaMultiModuleTask >().configureEach {
251
+ val moduleFile = File (
252
+ temporaryDir,
253
+ " MODULE.${java.util.UUID .randomUUID()} .md"
254
+ ).apply {
255
+ writeText(" # ${Coordinates .name} by ${Coordinates .vendor} \n ${Coordinates .description} \n <a href=\" ${Coordinates .gitUrl} \" >Source</a>" )
253
256
}
257
+
258
+ moduleName.set(Coordinates .name)
259
+ includes.from(moduleFile)
254
260
}
255
261
256
262
// Configure publishing to Maven Central
@@ -262,8 +268,7 @@ nexusPublishing.repositories.sonatype {
262
268
)
263
269
)
264
270
265
- // Skip this step if environment variables NEXUS_USERNAME or NEXUS_PASSWORD
266
- // aren't set.
271
+ // Skip this step if environment variables NEXUS_USERNAME or NEXUS_PASSWORD aren't set.
267
272
username.set(properties[" NEXUS_USERNAME" ] as ? String ? : return @sonatype)
268
273
password.set(properties[" NEXUS_PASSWORD" ] as ? String ? : return @sonatype)
269
274
}
0 commit comments