-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove buildResources from BuildPlugin (#57482)
The shared buildResources task is a catch all for resources needing to be copied from the build-tools jar at runtime. Utilizing this for all resources causes any tasks using resources from this to be triggered on any changes to any of those files. This commit creates separate export tasks per usage, and removes the buildResources task.
- Loading branch information
Showing
6 changed files
with
53 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 13 additions & 25 deletions
38
buildSrc/src/testKit/elasticsearch-build-resources/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,26 @@ | ||
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask | ||
|
||
plugins { | ||
id 'elasticsearch.build' | ||
id 'base' | ||
id 'elasticsearch.global-build-info' | ||
} | ||
|
||
ext.licenseFile = file("$buildDir/dummy/license") | ||
ext.noticeFile = file("$buildDir/dummy/notice") | ||
|
||
buildResources { | ||
File buildResourcesDir = new File(project.getBuildDir(), 'build-tools-exported') | ||
TaskProvider buildResourcesTask = tasks.register('buildResources', ExportElasticsearchBuildResourcesTask) { | ||
outputDir = buildResourcesDir | ||
copy 'checkstyle_suppressions.xml' | ||
copy 'checkstyle.xml' | ||
} | ||
|
||
tasks.register("sampleCopyAll", Sync) { | ||
tasks.register("sampleCopy", Sync) { | ||
/** Note: no explicit dependency. This works with tasks that use the Provider API a.k.a "Lazy Configuration" **/ | ||
from buildResources | ||
into "$buildDir/sampleCopyAll" | ||
} | ||
|
||
tasks.register("sample") { | ||
// This does not work, task dependencies can't be providers | ||
// dependsOn buildResources.resource('minimumRuntimeVersion') | ||
// Nor does this, despite https://github.com/gradle/gradle/issues/3811 | ||
// dependsOn buildResources.outputDir | ||
// for now it's just | ||
dependsOn buildResources | ||
// we have to reference it at configuration time in order to be picked up | ||
ext.checkstyle_suppressions = buildResources.copy('checkstyle_suppressions.xml') | ||
doLast { | ||
println "This task is using ${file(checkstyle_suppressions)}" | ||
} | ||
from buildResourcesTask | ||
into "$buildDir/sampleCopy" | ||
} | ||
|
||
tasks.register("noConfigAfterExecution") { | ||
dependsOn buildResources | ||
dependsOn buildResourcesTask | ||
doLast { | ||
println "This should cause an error because we are refferencing " + | ||
"${buildResources.copy('checkstyle_suppressions.xml')} after the `buildResources` task has ran." | ||
buildResourcesTask.get().copy('foo') | ||
} | ||
} |