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