|
35 | 35 | import org.gradle.api.credentials.HttpHeaderCredentials;
|
36 | 36 | import org.gradle.api.file.FileTree;
|
37 | 37 | import org.gradle.api.plugins.ExtraPropertiesExtension;
|
38 |
| -import org.gradle.api.tasks.Copy; |
| 38 | +import org.gradle.api.tasks.Sync; |
39 | 39 | import org.gradle.api.tasks.TaskProvider;
|
40 | 40 | import org.gradle.authentication.http.HttpHeaderAuthentication;
|
41 | 41 |
|
|
54 | 54 | */
|
55 | 55 | public class DistributionDownloadPlugin implements Plugin<Project> {
|
56 | 56 |
|
57 |
| - private static final String FAKE_GROUP = "elasticsearch-distribution"; |
| 57 | + private static final String FAKE_IVY_GROUP = "elasticsearch-distribution"; |
58 | 58 | private static final String DOWNLOAD_REPO_NAME = "elasticsearch-downloads";
|
59 | 59 |
|
60 | 60 | private BwcVersions bwcVersions;
|
61 | 61 | private NamedDomainObjectContainer<ElasticsearchDistribution> distributionsContainer;
|
62 | 62 |
|
63 | 63 | @Override
|
64 | 64 | public void apply(Project project) {
|
65 |
| - distributionsContainer = project.container(ElasticsearchDistribution.class, name -> new ElasticsearchDistribution(name, project)); |
| 65 | + distributionsContainer = project.container(ElasticsearchDistribution.class, name -> { |
| 66 | + Configuration fileConfiguration = project.getConfigurations().create("es_distro_file_" + name); |
| 67 | + Configuration extractedConfiguration = project.getConfigurations().create("es_distro_extracted_" + name); |
| 68 | + return new ElasticsearchDistribution(name, project.getObjects(), fileConfiguration, extractedConfiguration); |
| 69 | + }); |
66 | 70 | project.getExtensions().add("elasticsearch_distributions", distributionsContainer);
|
67 | 71 |
|
68 | 72 | setupDownloadServiceRepo(project);
|
@@ -112,18 +116,16 @@ private void setupRootDownload(Project rootProject, ElasticsearchDistribution di
|
112 | 116 | String extractedConfigName = "extracted_" + downloadConfigName;
|
113 | 117 | final Configuration downloadConfig = configurations.create(downloadConfigName);
|
114 | 118 | configurations.create(extractedConfigName);
|
115 |
| - Object distroDep = dependencyNotation(rootProject, distribution); |
116 |
| - rootProject.getDependencies().add(downloadConfigName, distroDep); |
| 119 | + rootProject.getDependencies().add(downloadConfigName, dependencyNotation(rootProject, distribution)); |
117 | 120 |
|
118 | 121 | // add task for extraction, delaying resolving config until runtime
|
119 | 122 | if (distribution.getType() == Type.ARCHIVE || distribution.getType() == Type.INTEG_TEST_ZIP) {
|
120 | 123 | Supplier<File> archiveGetter = downloadConfig::getSingleFile;
|
121 | 124 | String extractDir = rootProject.getBuildDir().toPath().resolve("elasticsearch-distros").resolve(extractedConfigName).toString();
|
122 |
| - TaskProvider<Copy> extractTask = rootProject.getTasks().register(extractTaskName, Copy.class, copyTask -> { |
123 |
| - copyTask.dependsOn(downloadConfig); |
124 |
| - copyTask.doFirst(t -> rootProject.delete(extractDir)); |
125 |
| - copyTask.into(extractDir); |
126 |
| - copyTask.from((Callable<FileTree>)() -> { |
| 125 | + TaskProvider<Sync> extractTask = rootProject.getTasks().register(extractTaskName, Sync.class, syncTask -> { |
| 126 | + syncTask.dependsOn(downloadConfig); |
| 127 | + syncTask.into(extractDir); |
| 128 | + syncTask.from((Callable<FileTree>)() -> { |
127 | 129 | File archiveFile = archiveGetter.get();
|
128 | 130 | String archivePath = archiveFile.toString();
|
129 | 131 | if (archivePath.endsWith(".zip")) {
|
@@ -155,12 +157,12 @@ private static void setupDownloadServiceRepo(Project project) {
|
155 | 157 | });
|
156 | 158 | ivyRepo.getAuthentication().create("header", HttpHeaderAuthentication.class);
|
157 | 159 | ivyRepo.patternLayout(layout -> layout.artifact("/downloads/elasticsearch/[module]-[revision](-[classifier]).[ext]"));
|
158 |
| - ivyRepo.content(content -> content.includeGroup(FAKE_GROUP)); |
| 160 | + ivyRepo.content(content -> content.includeGroup(FAKE_IVY_GROUP)); |
159 | 161 | });
|
160 | 162 | project.getRepositories().all(repo -> {
|
161 | 163 | if (repo.getName().equals(DOWNLOAD_REPO_NAME) == false) {
|
162 | 164 | // all other repos should ignore the special group name
|
163 |
| - repo.content(content -> content.excludeGroup(FAKE_GROUP)); |
| 165 | + repo.content(content -> content.excludeGroup(FAKE_IVY_GROUP)); |
164 | 166 | }
|
165 | 167 | });
|
166 | 168 | // TODO: need maven repo just for integ-test-zip, but only in external cases
|
@@ -199,7 +201,7 @@ private Object dependencyNotation(Project project, ElasticsearchDistribution dis
|
199 | 201 | extension = distribution.getPlatform() == Platform.WINDOWS ? "zip" : "tar.gz";
|
200 | 202 | classifier = distribution.getPlatform() + "-" + classifier;
|
201 | 203 | }
|
202 |
| - return FAKE_GROUP + ":elasticsearch" + (distribution.getFlavor() == Flavor.OSS ? "-oss:" : ":") |
| 204 | + return FAKE_IVY_GROUP + ":elasticsearch" + (distribution.getFlavor() == Flavor.OSS ? "-oss:" : ":") |
203 | 205 | + distribution.getVersion() + ":" + classifier + "@" + extension;
|
204 | 206 | }
|
205 | 207 |
|
|
0 commit comments