Skip to content

Commit

Permalink
Add links to external classes in clients javadoc (#25998)
Browse files Browse the repository at this point in the history
The client sniffer depends on the low-level REST client, while the Java high-level REST client and the transport client depend on Elasticsearch itself. Javadoc are not that useful unless they have links to the Elasticsearch classes in the latter case, and to the low-level REST client in the sniffer javadoc. This commit adds those links.
  • Loading branch information
javanna committed Aug 17, 2017
1 parent 9f69187 commit a759f4a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import org.gradle.util.GradleVersion

import java.time.ZoneOffset
import java.time.ZonedDateTime

/**
* Encapsulates build configuration for elasticsearch projects.
*/
Expand Down Expand Up @@ -79,7 +78,7 @@ class BuildPlugin implements Plugin<Project> {
configureConfigurations(project)
project.ext.versions = VersionProperties.versions
configureCompile(project)
configureJavadocJar(project)
configureJavadoc(project)
configureSourcesJar(project)
configurePomGeneration(project)

Expand Down Expand Up @@ -289,7 +288,7 @@ class BuildPlugin implements Plugin<Project> {
project.configurations.provided.dependencies.all(disableTransitiveDeps)
}

/** Adds repositores used by ES dependencies */
/** Adds repositories used by ES dependencies */
static void configureRepositories(Project project) {
RepositoryHandler repos = project.repositories
if (System.getProperty("repos.mavenlocal") != null) {
Expand Down Expand Up @@ -454,6 +453,30 @@ class BuildPlugin implements Plugin<Project> {
}
}

static void configureJavadoc(Project project) {
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
project.afterEvaluate {
/*
* Order matters, the linksOffline for org.elasticsearch:elasticsearch must be the last one
* or all the links for the other packages (e.g org.elasticsearch.client) will point to core rather than their own artifacts
*/
Closure sortClosure = { a, b -> b.group <=> a.group }
Closure depJavadocClosure = { dep ->
if (dep.group != null && dep.group.startsWith('org.elasticsearch')) {
String substitution = project.ext.projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
if (substitution != null) {
project.javadoc.dependsOn substitution + ':javadoc'
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${project.project(substitution).buildDir}/docs/javadoc/"
}
}
}
project.configurations.compile.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
project.configurations.provided.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
}
configureJavadocJar(project)
}

/** Adds a javadocJar task to generate a jar containing javadocs. */
static void configureJavadocJar(Project project) {
Jar javadocJarTask = project.task('javadocJar', type: Jar)
Expand All @@ -473,7 +496,7 @@ class BuildPlugin implements Plugin<Project> {
project.assemble.dependsOn(sourcesJarTask)
}

/** Adds additional manifest info to jars, and adds source and javadoc jars */
/** Adds additional manifest info to jars */
static void configureJars(Project project) {
project.tasks.withType(Jar) { Jar jarTask ->
// we put all our distributable files under distributions
Expand Down
2 changes: 1 addition & 1 deletion client/sniffer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ thirdPartyAudit.excludes = [
//commons-logging provided dependencies
'javax.servlet.ServletContextEvent',
'javax.servlet.ServletContextListener'
]
]
2 changes: 1 addition & 1 deletion client/transport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ namingConventions {
testClass = 'com.carrotsearch.randomizedtesting.RandomizedTest'
//we don't have integration tests
skipIntegTestInDisguise = true
}
}
1 change: 0 additions & 1 deletion test/framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies {
compile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
compile "org.apache.lucene:lucene-test-framework:${versions.lucene}"
compile "org.apache.lucene:lucene-codecs:${versions.lucene}"
compile "org.elasticsearch.client:elasticsearch-rest-client:${version}"
compile "commons-logging:commons-logging:${versions.commonslogging}"
compile "commons-codec:commons-codec:${versions.commonscodec}"
compile "org.elasticsearch:securemock:${versions.securemock}"
Expand Down

0 comments on commit a759f4a

Please sign in to comment.