Skip to content

Commit f54c5e8

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

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.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

@@ -138,7 +146,9 @@ jar {
138146
}
139147

140148
javadoc {
149+
dependsOn compileScala
141150
source += project(":elasticsearch-hadoop-mr").sourceSets.main.allJava
151+
source += "$buildDir/generated/java"
142152
classpath += files(project(":elasticsearch-hadoop-mr").sourceSets.main.compileClasspath)
143153
}
144154

@@ -164,3 +174,12 @@ configurations.all { Configuration conf ->
164174

165175
conf.exclude group: "org.mortbay.jetty"
166176
}
177+
178+
tasks.withType(ScalaCompile) {
179+
scalaCompileOptions.with {
180+
additionalParameters = [
181+
"-Xplugin:" + configurations.scalaCompilerPlugin.asPath,
182+
"-P:genjavadoc:out=$buildDir/generated/java".toString()
183+
]
184+
}
185+
}

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.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

@@ -152,7 +160,9 @@ jar {
152160
}
153161

154162
javadoc {
163+
dependsOn compileScala
155164
source += project(":elasticsearch-hadoop-mr").sourceSets.main.allJava
165+
source += "$buildDir/generated/java"
156166
classpath += files(project(":elasticsearch-hadoop-mr").sourceSets.main.compileClasspath)
157167
}
158168

@@ -163,3 +173,12 @@ sourcesJar {
163173
scaladoc {
164174
title = "${rootProject.description} ${version} API"
165175
}
176+
177+
tasks.withType(ScalaCompile) {
178+
scalaCompileOptions.with {
179+
additionalParameters = [
180+
"-Xplugin:" + configurations.scalaCompilerPlugin.asPath,
181+
"-P:genjavadoc:out=$buildDir/generated/java".toString()
182+
]
183+
}
184+
}

0 commit comments

Comments
 (0)