Skip to content

Commit eb750dd

Browse files
authored
[7.x] Add scala docs to javadocs (#1368) (#1382)
This commit introduces a 3rd party plugin to co-locate scala docs with java docs. https://github.com/lightbend/genjavadoc Fixes: #1363
1 parent fdec21a commit eb750dd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

spark/sql-13/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ variants {
1212
targetVersions '2.10.7', '2.11.12'
1313
}
1414

15+
configurations {
16+
scalaCompilerPlugin {
17+
defaultDependencies { dependencies ->
18+
dependencies.add(project.dependencies.create( "com.typesafe.genjavadoc:genjavadoc-plugin_${scalaVersion}:0.13"))
19+
}
20+
}
21+
}
22+
1523
println "Compiled using Scala ${project.ext.scalaMajorVersion} [${project.ext.scalaVersion}]"
1624
String sparkVersion = spark13Version
1725

@@ -111,7 +119,9 @@ jar {
111119
}
112120

113121
javadoc {
122+
dependsOn compileScala
114123
source += project(":elasticsearch-hadoop-mr").sourceSets.main.allJava
124+
source += "$buildDir/generated/java"
115125
classpath += files(project(":elasticsearch-hadoop-mr").sourceSets.main.compileClasspath)
116126
}
117127

@@ -137,3 +147,12 @@ configurations.all { Configuration conf ->
137147

138148
conf.exclude group: "org.mortbay.jetty"
139149
}
150+
151+
tasks.withType(ScalaCompile) {
152+
scalaCompileOptions.with {
153+
additionalParameters = [
154+
"-Xplugin:" + configurations.scalaCompilerPlugin.asPath,
155+
"-P:genjavadoc:out=$buildDir/generated/java".toString()
156+
]
157+
}
158+
}

spark/sql-20/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ variants {
1212
targetVersions '2.10.7', '2.11.12'
1313
}
1414

15+
configurations {
16+
scalaCompilerPlugin {
17+
defaultDependencies { dependencies ->
18+
dependencies.add(project.dependencies.create( "com.typesafe.genjavadoc:genjavadoc-plugin_${scalaVersion}:0.13"))
19+
}
20+
}
21+
}
22+
1523
println "Compiled using Scala ${project.ext.scalaMajorVersion} [${project.ext.scalaVersion}]"
1624
String sparkVersion = spark20Version
1725

@@ -124,7 +132,9 @@ jar {
124132
}
125133

126134
javadoc {
135+
dependsOn compileScala
127136
source += project(":elasticsearch-hadoop-mr").sourceSets.main.allJava
137+
source += "$buildDir/generated/java"
128138
classpath += files(project(":elasticsearch-hadoop-mr").sourceSets.main.compileClasspath)
129139
}
130140

@@ -135,3 +145,12 @@ sourcesJar {
135145
scaladoc {
136146
title = "${rootProject.description} ${version} API"
137147
}
148+
149+
tasks.withType(ScalaCompile) {
150+
scalaCompileOptions.with {
151+
additionalParameters = [
152+
"-Xplugin:" + configurations.scalaCompilerPlugin.asPath,
153+
"-P:genjavadoc:out=$buildDir/generated/java".toString()
154+
]
155+
}
156+
}

0 commit comments

Comments
 (0)