From 1309dfd44dfc71eac983919d068fec1e96cbd55d Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Thu, 17 Aug 2017 21:03:47 +0200 Subject: [PATCH] Add links to external classes in clients javadoc (#25998) 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. --- .../elasticsearch/gradle/BuildPlugin.groovy | 31 ++++++++++++++++--- client/sniffer/build.gradle | 2 +- client/transport/build.gradle | 2 +- test/framework/build.gradle | 1 - 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 4fa90853b16..906ebf4ce6f 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -48,7 +48,6 @@ import org.gradle.util.GradleVersion import java.time.ZoneOffset import java.time.ZonedDateTime - /** * Encapsulates build configuration for elasticsearch projects. */ @@ -79,7 +78,7 @@ class BuildPlugin implements Plugin { configureConfigurations(project) project.ext.versions = VersionProperties.versions configureCompile(project) - configureJavadocJar(project) + configureJavadoc(project) configureSourcesJar(project) configurePomGeneration(project) @@ -289,7 +288,7 @@ class BuildPlugin implements Plugin { 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) { @@ -454,6 +453,30 @@ class BuildPlugin implements Plugin { } } + 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) @@ -473,7 +496,7 @@ class BuildPlugin implements Plugin { 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 diff --git a/client/sniffer/build.gradle b/client/sniffer/build.gradle index a212bdd0f21..3b0512118ac 100644 --- a/client/sniffer/build.gradle +++ b/client/sniffer/build.gradle @@ -99,4 +99,4 @@ thirdPartyAudit.excludes = [ //commons-logging provided dependencies 'javax.servlet.ServletContextEvent', 'javax.servlet.ServletContextListener' -] +] \ No newline at end of file diff --git a/client/transport/build.gradle b/client/transport/build.gradle index b2edc9c8fcd..f09668ac6ac 100644 --- a/client/transport/build.gradle +++ b/client/transport/build.gradle @@ -54,4 +54,4 @@ namingConventions { testClass = 'com.carrotsearch.randomizedtesting.RandomizedTest' //we don't have integration tests skipIntegTestInDisguise = true -} +} \ No newline at end of file diff --git a/test/framework/build.gradle b/test/framework/build.gradle index cc132a9d718..09382763057 100644 --- a/test/framework/build.gradle +++ b/test/framework/build.gradle @@ -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}"