-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathforbidden-dependencies.gradle
38 lines (34 loc) · 1.21 KB
/
forbidden-dependencies.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
// we do not want any of these dependencies on the compilation classpath
// because they could then be used within OpenSearch
List<String> FORBIDDEN_DEPENDENCIES = [
'guava'
]
Closure checkDeps = { Configuration configuration ->
configuration.resolutionStrategy.eachDependency {
String artifactName = it.target.name
if (FORBIDDEN_DEPENDENCIES.contains(artifactName)) {
throw new GradleException("Dependency '${artifactName}' on configuration '${configuration.name}' is not allowed. " +
"If it is needed as a transitive depenency, try adding it to the runtime classpath")
}
}
}
subprojects {
if (project.path.startsWith(':test:fixtures:') || project.path.equals(':build-tools')) {
// fixtures are allowed to use whatever dependencies they want...
return
}
pluginManager.withPlugin('java') {
checkDeps(configurations.compileClasspath)
checkDeps(configurations.testCompileClasspath)
}
}