Skip to content

Commit 02df4b6

Browse files
committed
Update dependencies and API spec links generation
1 parent 75feae5 commit 02df4b6

File tree

2 files changed

+52
-5
lines changed

2 files changed

+52
-5
lines changed

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ allprojects {
2424
(File(project.rootDir, "config/version.txt").readText().trim() + "-SNAPSHOT")
2525

2626
repositories {
27+
maven {
28+
name = "Elastic-Snapshots"
29+
url = uri("https://snapshots.elastic.co/maven/")
30+
}
2731
mavenCentral()
2832
}
2933

java-client/build.gradle.kts

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ tasks.withType<Jar> {
6868
}
6969
}
7070

71+
tasks.withType<Javadoc> {
72+
val opt = options as StandardJavadocDocletOptions
73+
// Gradle calls javadoc with a list of file and not a path. This prevents doc-files from being copied.
74+
opt.addStringOption("sourcepath", project.projectDir.path + "/src/main/java")
75+
opt.docFilesSubDirs(true)
76+
77+
doLast {
78+
// Javadoc adds its decoration to html doc files, including quite some JS. This slows down the api spec
79+
// redirector that doesn't need it. So overwrite the target file with the original one.
80+
val specFile = "co/elastic/clients/elasticsearch/doc-files/api-spec.html"
81+
val source = File(project.projectDir, "src/main/java/" + specFile)
82+
val target = File(project.projectDir, "build/docs/javadoc/" + specFile)
83+
source.copyTo(target, overwrite = true)
84+
}
85+
}
86+
7187
publishing {
7288
repositories {
7389
maven {
@@ -87,9 +103,9 @@ publishing {
87103
create<MavenPublication>("maven") {
88104
from(components["java"])
89105
pom {
90-
name.set("Elasticsearch Java Client")
106+
name.set("Elasticsearch Java API Client")
91107
artifactId = "elasticsearch-java"
92-
description.set("Next-gen Elasticsearch Java Client")
108+
description.set("Elasticsearch Java API Client")
93109
url.set("https://github.com/elastic/elasticsearch-java/")
94110
licenses {
95111
license {
@@ -109,14 +125,41 @@ publishing {
109125
developerConnection.set("scm:git:ssh://git@github.com:elastic/elasticsearch-java.git")
110126
url.set("https://github.com/elastic/elasticsearch-java/")
111127
}
128+
129+
withXml {
130+
// Set the version of dependencies of the org.elasticsearch.client group to the one that we are building.
131+
// Since the unified release process releases everything at once, this ensures all published artifacts depend
132+
// on the exact same version. This assumes of course that the binary API and the behavior of these dependencies
133+
// are the same as the one used in the dependency section below.
134+
val xPathFactory = javax.xml.xpath.XPathFactory.newInstance()
135+
val depSelector = xPathFactory.newXPath()
136+
.compile("/project/dependencies/dependency[groupId/text() = 'org.elasticsearch.client']")
137+
val versionSelector = xPathFactory.newXPath().compile("version")
138+
139+
var foundVersion = false;
140+
141+
val deps = depSelector.evaluate(asElement().ownerDocument, javax.xml.xpath.XPathConstants.NODESET)
142+
as org.w3c.dom.NodeList
143+
144+
for (i in 0 until deps.length) {
145+
val dep = deps.item(i)
146+
val version = versionSelector.evaluate(dep, javax.xml.xpath.XPathConstants.NODE) as org.w3c.dom.Element
147+
foundVersion = true;
148+
version.textContent = project.version.toString()
149+
}
150+
151+
if (!foundVersion) {
152+
throw GradleException("Could not find a 'org.elasticsearch.client' to update dependency version in the POM.")
153+
}
154+
}
112155
}
113156
}
114157
}
115158
}
116159

117160
dependencies {
118-
val elasticsearchVersion = "7.15.0"
119-
val jacksonVersion = "2.12.0"
161+
val elasticsearchVersion = "7.17.0-SNAPSHOT"
162+
val jacksonVersion = "2.13.1"
120163

121164
// Apache 2.0
122165
// https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low.html
@@ -153,7 +196,7 @@ dependencies {
153196

154197
// EPL-1.0
155198
// https://junit.org/junit4/
156-
testImplementation("junit", "junit" , "4.12")
199+
testImplementation("junit", "junit" , "4.13.2")
157200

158201
// MIT
159202
// https://github.com/classgraph/classgraph

0 commit comments

Comments
 (0)