Skip to content

Commit b4e7bc6

Browse files
committed
[Gradle] Use variant aware resolution for deps on hfds-fixture
1 parent 8fce15d commit b4e7bc6

File tree

5 files changed

+46
-16
lines changed

5 files changed

+46
-16
lines changed

plugins/repository-hdfs/build.gradle

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,36 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
10+
1111
import org.elasticsearch.gradle.OS
12+
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
1213

1314
apply plugin: 'elasticsearch.internal-java-rest-test'
1415
apply plugin: 'elasticsearch.internal-yaml-rest-test'
1516

1617
esplugin {
1718
description = 'The HDFS repository plugin adds support for Hadoop Distributed File-System (HDFS) repositories.'
18-
classname ='org.elasticsearch.repositories.hdfs.HdfsPlugin'
19+
classname = 'org.elasticsearch.repositories.hdfs.HdfsPlugin'
1920
}
2021

2122
versions << [
2223
'hadoop': '3.4.1'
2324
]
2425

2526
def patched = Attribute.of('patched', Boolean)
27+
def hdfsVersionAttr = Attribute.of('hdfs.major.version', Integer)
2628

2729
configurations {
28-
hdfsFixture2
29-
hdfsFixture3
30+
hdfsFixture2 {
31+
attributes {
32+
attribute(hdfsVersionAttr, 2)
33+
}
34+
}
35+
hdfsFixture3 {
36+
attributes {
37+
attribute(hdfsVersionAttr, 3)
38+
}
39+
}
3040
compileClasspath {
3141
attributes {
3242
attribute(patched, true)
@@ -82,8 +92,8 @@ dependencies {
8292
yamlRestTestRuntimeOnly "commons-cli:commons-cli:1.5.0"
8393
yamlRestTestRuntimeOnly "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
8494

85-
hdfsFixture2 project(path: ':test:fixtures:hdfs-fixture', configuration: 'shadowedHdfs2')
86-
hdfsFixture3 project(path: ':test:fixtures:hdfs-fixture', configuration: 'shadow')
95+
hdfsFixture2 project(':test:fixtures:hdfs-fixture')
96+
hdfsFixture3 project(':test:fixtures:hdfs-fixture')
8797

8898
attributesSchema {
8999
attribute(patched)

test/fixtures/hdfs-fixture/build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
1515

1616
def hdfs2patched = Attribute.of('hdfs2-patched', Boolean)
1717
def hdfs3patched = Attribute.of('hdfs3-patched', Boolean)
18+
def hdfsVersionAttr = Attribute.of('hdfs.major.version', Integer)
19+
1820
configurations {
1921
hdfs2 {
2022
attributes {
@@ -26,7 +28,16 @@ configurations {
2628
attribute(hdfs3patched, true)
2729
}
2830
}
29-
consumable("shadowedHdfs2")
31+
consumable("shadowedHdfs2") {
32+
attributes {
33+
attribute(hdfsVersionAttr, 2)
34+
}
35+
}
36+
consumable("shadowedHdfs3") {
37+
attributes {
38+
attribute(hdfsVersionAttr, 3)
39+
}
40+
}
3041
}
3142

3243
dependencies {
@@ -165,4 +176,5 @@ tasks.withType(ShadowJar).configureEach {
165176

166177
artifacts {
167178
shadowedHdfs2(hdfs2Jar)
179+
shadowedHdfs3(tasks.named("shadowJar"))
168180
}

test/fixtures/krb5kdc-fixture/build.gradle

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ configurations {
2525
all {
2626
exclude group: 'org.hamcrest', module: 'hamcrest-core'
2727
}
28-
krb5ConfHdfsFile {
29-
canBeConsumed = true
30-
canBeResolved = false
31-
}
32-
krb5KeytabsHdfsDir {
33-
canBeConsumed = true
34-
canBeResolved = false
35-
}
3628
}
3729

3830
dependencies {

x-pack/plugin/searchable-snapshots/qa/hdfs/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ apply plugin: 'elasticsearch.internal-java-rest-test'
99
apply plugin: 'elasticsearch.rest-resources'
1010
apply plugin: 'elasticsearch.internal-available-ports'
1111

12+
configurations {
13+
javaRestTestRuntimeClasspath {
14+
attributes {
15+
attribute(Attribute.of('hdfs.major.version', Integer), 3)
16+
}
17+
}
18+
}
19+
1220
dependencies {
1321
clusterPlugins project(':plugins:repository-hdfs')
1422
javaRestTestImplementation(testArtifact(project(xpackModule('searchable-snapshots'))))

x-pack/plugin/snapshot-repo-test-kit/qa/hdfs/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
apply plugin: 'elasticsearch.internal-java-rest-test'
99
apply plugin: 'elasticsearch.rest-resources'
1010

11+
configurations {
12+
javaRestTestRuntimeClasspath {
13+
attributes {
14+
attribute(Attribute.of('hdfs.major.version', Integer), 3)
15+
}
16+
}
17+
}
18+
1119
dependencies {
1220
javaRestTestImplementation testArtifact(project(xpackModule('snapshot-repo-test-kit')))
1321
javaRestTestCompileOnly project(path: ':test:fixtures:hdfs-fixture')
14-
javaRestTestRuntimeOnly project(path: ':test:fixtures:hdfs-fixture', configuration:"shadow")
22+
javaRestTestRuntimeOnly project(path: ':test:fixtures:hdfs-fixture', configuration: "shadow")
1523
javaRestTestImplementation project(':test:fixtures:krb5kdc-fixture')
1624
javaRestTestImplementation "org.slf4j:slf4j-api:${versions.slf4j}"
1725
javaRestTestImplementation "org.slf4j:slf4j-simple:${versions.slf4j}"

0 commit comments

Comments
 (0)