You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: BUILDING.md
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,6 +97,70 @@ will have the `origin` attribute been set to `Generated by Gradle`.
97
97
> If you want to add a level of verification you can manually confirm the checksum (e.g. by looking it up on the website of the library)
98
98
> Please replace the content of the `origin` attribute by `official site` in that case.
99
99
100
+
##### Handling transitive dependencies
101
+
102
+
Dependency management is a critical aspect of maintaining a secure and reliable build system, requiring explicit control over what we rely on. The Elasticsearch build mainly uses component metadata rules declared in the `ComponentMetadataRulesPlugin`
103
+
plugin to manage transitive dependencies and avoid version conflicts.
104
+
This approach ensures we have explicit control over all dependencies used in the build.
105
+
106
+
###### General Guidelines
107
+
108
+
1.**Avoid unused transitive dependencies** - Dependencies that are not actually used by our code should be excluded to reduce the attack surface and avoid potential conflicts.
109
+
110
+
2.**Prefer versions declared in `build-tools-internal/version.properties`** - All dependency versions should be centrally managed in this file to ensure consistency across the entire build.
111
+
112
+
3.**Libraries required to compile our code should be direct dependencies** - If we directly use a library in our source code, it should be declared as a direct dependency rather than relying on it being transitively available.
113
+
114
+
###### Component Metadata Rules
115
+
116
+
We use two main types of component metadata rules at this point to manage transitive dependencies:
117
+
118
+
-**`ExcludeAllTransitivesRule`** - Excludes all transitive dependencies for libraries where we want complete control over dependencies or the transitive dependencies are unused.
119
+
120
+
-**`ExcludeOtherGroupsTransitiveRule`** - Excludes transitive dependencies that don't belong to the same group as the direct dependency, while keeping same-group dependencies.
121
+
-
122
+
-**`ExcludeByGroup`** - Excludes transitive dependencies that match a specific groupId while keeping all other transitive dependencies with different groupIds.
123
+
124
+
Examples from the `ComponentMetadataRulesPlugin`:
125
+
126
+
```gradle
127
+
// Exclude all transitives - used when transitive deps are unused or problematic
Copy file name to clipboardExpand all lines: build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/transport/AbstractTransportVersionFuncTest.groovy
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -152,7 +152,11 @@ class AbstractTransportVersionFuncTest extends AbstractGradleFuncTest {
Copy file name to clipboardExpand all lines: build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaModulePathPlugin.java
0 commit comments