|
18 | 18 | */
|
19 | 19 | package org.elasticsearch.gradle
|
20 | 20 |
|
21 |
| - |
22 | 21 | import groovy.transform.CompileStatic
|
23 | 22 | import org.apache.commons.io.IOUtils
|
24 | 23 | import org.elasticsearch.gradle.info.BuildParams
|
@@ -51,7 +50,6 @@ import org.gradle.api.execution.TaskActionListener
|
51 | 50 | import org.gradle.api.plugins.ExtraPropertiesExtension
|
52 | 51 | import org.gradle.api.plugins.JavaPlugin
|
53 | 52 | import org.gradle.api.tasks.testing.Test
|
54 |
| -import org.gradle.authentication.http.HttpHeaderAuthentication |
55 | 53 | import org.gradle.util.GradleVersion
|
56 | 54 |
|
57 | 55 | import java.nio.charset.StandardCharsets
|
@@ -93,7 +91,6 @@ class BuildPlugin implements Plugin<Project> {
|
93 | 91 |
|
94 | 92 | project.getTasks().register("buildResources", ExportElasticsearchBuildResourcesTask)
|
95 | 93 |
|
96 |
| - configureRepositories(project) |
97 | 94 | project.extensions.getByType(ExtraPropertiesExtension).set('versions', VersionProperties.versions)
|
98 | 95 | PrecommitTasks.create(project, true)
|
99 | 96 | configureFips140(project)
|
@@ -159,122 +156,6 @@ class BuildPlugin implements Plugin<Project> {
|
159 | 156 | }
|
160 | 157 | }
|
161 | 158 |
|
162 |
| - /** |
163 |
| - * Makes dependencies non-transitive. |
164 |
| - * |
165 |
| - * Gradle allows setting all dependencies as non-transitive very easily. |
166 |
| - * Sadly this mechanism does not translate into maven pom generation. In order |
167 |
| - * to effectively make the pom act as if it has no transitive dependencies, |
168 |
| - * we must exclude each transitive dependency of each direct dependency. |
169 |
| - * |
170 |
| - * Determining the transitive deps of a dependency which has been resolved as |
171 |
| - * non-transitive is difficult because the process of resolving removes the |
172 |
| - * transitive deps. To sidestep this issue, we create a configuration per |
173 |
| - * direct dependency version. This specially named and unique configuration |
174 |
| - * will contain all of the transitive dependencies of this particular |
175 |
| - * dependency. We can then use this configuration during pom generation |
176 |
| - * to iterate the transitive dependencies and add excludes. |
177 |
| - */ |
178 |
| - static void configureConfigurations(Project project) { |
179 |
| - // we want to test compileOnly deps! |
180 |
| - project.configurations.getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME).extendsFrom(project.configurations.getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME)) |
181 |
| - |
182 |
| - // we are not shipping these jars, we act like dumb consumers of these things |
183 |
| - if (project.path.startsWith(':test:fixtures') || project.path == ':build-tools') { |
184 |
| - return |
185 |
| - } |
186 |
| - // fail on any conflicting dependency versions |
187 |
| - project.configurations.all({ Configuration configuration -> |
188 |
| - if (configuration.name.endsWith('Fixture')) { |
189 |
| - // just a self contained test-fixture configuration, likely transitive and hellacious |
190 |
| - return |
191 |
| - } |
192 |
| - configuration.resolutionStrategy { |
193 |
| - failOnVersionConflict() |
194 |
| - } |
195 |
| - }) |
196 |
| - |
197 |
| - // force all dependencies added directly to compile/testCompile to be non-transitive, except for ES itself |
198 |
| - Closure disableTransitiveDeps = { Dependency dep -> |
199 |
| - if (dep instanceof ModuleDependency && !(dep instanceof ProjectDependency) |
200 |
| - && dep.group.startsWith('org.elasticsearch') == false) { |
201 |
| - dep.transitive = false |
202 |
| - } |
203 |
| - } |
204 |
| - |
205 |
| - project.configurations.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME).dependencies.all(disableTransitiveDeps) |
206 |
| - project.configurations.getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME).dependencies.all(disableTransitiveDeps) |
207 |
| - project.configurations.getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME).dependencies.all(disableTransitiveDeps) |
208 |
| - project.configurations.getByName(JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME).dependencies.all(disableTransitiveDeps) |
209 |
| - } |
210 |
| - |
211 |
| - /** Adds repositories used by ES dependencies */ |
212 |
| - static void configureRepositories(Project project) { |
213 |
| - project.getRepositories().all { repository -> |
214 |
| - if (repository instanceof MavenArtifactRepository) { |
215 |
| - final MavenArtifactRepository maven = (MavenArtifactRepository) repository |
216 |
| - assertRepositoryURIIsSecure(maven.name, project.path, maven.getUrl()) |
217 |
| - repository.getArtifactUrls().each { uri -> assertRepositoryURIIsSecure(maven.name, project.path, uri) } |
218 |
| - } else if (repository instanceof IvyArtifactRepository) { |
219 |
| - final IvyArtifactRepository ivy = (IvyArtifactRepository) repository |
220 |
| - assertRepositoryURIIsSecure(ivy.name, project.path, ivy.getUrl()) |
221 |
| - } |
222 |
| - } |
223 |
| - RepositoryHandler repos = project.repositories |
224 |
| - if (System.getProperty('repos.mavenLocal') != null) { |
225 |
| - // with -Drepos.mavenLocal=true we can force checking the local .m2 repo which is |
226 |
| - // useful for development ie. bwc tests where we install stuff in the local repository |
227 |
| - // such that we don't have to pass hardcoded files to gradle |
228 |
| - repos.mavenLocal() |
229 |
| - } |
230 |
| - repos.jcenter() |
231 |
| - repos.ivy { IvyArtifactRepository repo -> |
232 |
| - repo.name = 'elasticsearch' |
233 |
| - repo.url = 'https://artifacts.elastic.co/downloads' |
234 |
| - repo.patternLayout { IvyPatternRepositoryLayout layout -> |
235 |
| - layout.artifact 'elasticsearch/[module]-[revision](-[classifier]).[ext]' |
236 |
| - } |
237 |
| - // this header is not a credential but we hack the capability to send this header to avoid polluting our download stats |
238 |
| - repo.credentials(HttpHeaderCredentials, { HttpHeaderCredentials creds -> |
239 |
| - creds.name = 'X-Elastic-No-KPI' |
240 |
| - creds.value = '1' |
241 |
| - } as Action<HttpHeaderCredentials>) |
242 |
| - repo.authentication.create('header', HttpHeaderAuthentication) |
243 |
| - } |
244 |
| - repos.maven { MavenArtifactRepository repo -> |
245 |
| - repo.name = 'elastic' |
246 |
| - repo.url = 'https://artifacts.elastic.co/maven' |
247 |
| - } |
248 |
| - String luceneVersion = VersionProperties.lucene |
249 |
| - if (luceneVersion.contains('-snapshot')) { |
250 |
| - // extract the revision number from the version with a regex matcher |
251 |
| - List<String> matches = (luceneVersion =~ /\w+-snapshot-([a-z0-9]+)/).getAt(0) as List<String> |
252 |
| - String revision = matches.get(1) |
253 |
| - MavenArtifactRepository luceneRepo = repos.maven { MavenArtifactRepository repo -> |
254 |
| - repo.name = 'lucene-snapshots' |
255 |
| - repo.url = "https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/${revision}" |
256 |
| - } |
257 |
| - repos.exclusiveContent { ExclusiveContentRepository exclusiveRepo -> |
258 |
| - exclusiveRepo.filter { |
259 |
| - it.includeVersionByRegex(/org\.apache\.lucene/, '.*', ".*-snapshot-${revision}") |
260 |
| - } |
261 |
| - exclusiveRepo.forRepositories(luceneRepo) |
262 |
| - } |
263 |
| - } |
264 |
| - } |
265 |
| - |
266 |
| - static void assertRepositoryURIIsSecure(final String repositoryName, final String projectPath, final URI uri) { |
267 |
| - if (uri != null && ["file", "https", "s3"].contains(uri.getScheme()) == false) { |
268 |
| - final String message = String.format( |
269 |
| - Locale.ROOT, |
270 |
| - "repository [%s] on project with path [%s] is not using a secure protocol for artifacts on [%s]", |
271 |
| - repositoryName, |
272 |
| - projectPath, |
273 |
| - uri.toURL()) |
274 |
| - throw new GradleException(message) |
275 |
| - } |
276 |
| - } |
277 |
| - |
278 | 159 | private static class TestFailureReportingPlugin implements Plugin<Project> {
|
279 | 160 | @Override
|
280 | 161 | void apply(Project project) {
|
|
0 commit comments