Skip to content

Commit 2171b24

Browse files
committed
Hack around gradle issues with configurations and project context
1 parent ad9140f commit 2171b24

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

distribution/docker/build.gradle

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131
ossDockerSource project(path: ":distribution:archives:oss-linux-tar")
3232
}
3333

34-
ext.expansions = { Architecture architecture, boolean oss, boolean ubi, boolean local ->
34+
ext.expansions = { Architecture architecture, boolean oss, boolean ubi, boolean local, Project p ->
3535
String classifier
3636
if (local || ubi) {
3737
switch (architecture) {
@@ -82,7 +82,7 @@ RUN curl --retry 8 -S -L \\
8282
'license' : oss ? 'Apache-2.0' : 'Elastic-License',
8383
'source_elasticsearch': sourceElasticsearch,
8484
'version' : VersionProperties.elasticsearch,
85-
'version_hash' : ubi ? getChecksum(configurations.dockerSource.singleFile) : ''
85+
'version_hash' : ubi ? getChecksum(p.configurations.dockerSource.singleFile) : ''
8686
]
8787
}
8888

@@ -122,9 +122,9 @@ private static String taskName(final String prefix, final Architecture architect
122122
}
123123

124124
project.ext {
125-
dockerBuildContext = { Architecture architecture, boolean oss, boolean ubi, boolean local ->
125+
dockerBuildContext = { Architecture architecture, boolean oss, boolean ubi, boolean local, Project p ->
126126
copySpec {
127-
final Map<String,String> varExpansions = expansions(architecture, oss, ubi, local)
127+
final Map<String,String> varExpansions = expansions(architecture, oss, ubi, local, p)
128128
final Path projectDir = project.projectDir.toPath()
129129

130130
if (ubi) {
@@ -164,12 +164,12 @@ project.ext {
164164

165165
void addCopyDockerContextTask(final Architecture architecture, final boolean oss) {
166166
task(taskName("copy", architecture, oss, "DockerContext"), type: Sync) {
167-
expansions(architecture, oss, false, true).findAll { it.key != 'build_date' }.each { k, v ->
167+
expansions(architecture, oss, false, true, project).findAll { it.key != 'build_date' }.each { k, v ->
168168
inputs.property(k, { v.toString() })
169169
}
170170
into buildPath(architecture, oss)
171171

172-
with dockerBuildContext(architecture, oss, false, true)
172+
with dockerBuildContext(architecture, oss, false, true, project)
173173

174174
if (architecture == Architecture.AARCH64) {
175175
if (oss) {
@@ -300,6 +300,16 @@ if (tasks.findByName("composePull")) {
300300
* that they can be easily reloaded, for example into a VM for distribution testing
301301
*/
302302
subprojects { Project subProject ->
303+
if (subProject.name.endsWith('-context')) {
304+
configurations {
305+
dockerSource
306+
}
307+
308+
dependencies {
309+
dockerSource project(path: ":distribution:archives:linux-tar")
310+
}
311+
}
312+
303313
if (subProject.name.endsWith('-export')) {
304314
apply plugin: 'distribution'
305315

distribution/docker/docker-build-context/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ task buildDockerBuildContext(type: Tar) {
66
archiveClassifier = "docker-build-context"
77
archiveBaseName = "elasticsearch"
88
// Non-local builds don't need to specify an architecture.
9-
with dockerBuildContext(null, false, false, false)
9+
with dockerBuildContext(null, false, false, false, project)
1010
}
1111

1212
assemble.dependsOn buildDockerBuildContext

distribution/docker/oss-docker-build-context/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ task buildOssDockerBuildContext(type: Tar) {
66
archiveClassifier = "docker-build-context"
77
archiveBaseName = "elasticsearch-oss"
88
// Non-local builds don't need to specify an architecture.
9-
with dockerBuildContext(null, true, false, false)
9+
with dockerBuildContext(null, true, false, false, project)
1010
}
1111

1212
assemble.dependsOn buildOssDockerBuildContext

distribution/docker/ubi-docker-build-context/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ task buildUbiDockerBuildContext(type: Tar) {
77
compression = Compression.GZIP
88
archiveClassifier = "docker-build-context"
99
archiveBaseName = "elasticsearch-ubi8"
10-
with dockerBuildContext(Architecture.X64, false, true, false)
10+
with dockerBuildContext(Architecture.X64, false, true, false, project)
1111
}
1212

1313
assemble.dependsOn buildUbiDockerBuildContext

0 commit comments

Comments
 (0)