Skip to content

Commit 9e3f098

Browse files
committed
docs: Describe transitive Selenium dependencies management
1 parent a90d718 commit 9e3f098

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ dependencies {
8787
}
8888
```
8989

90+
### How to pin Selenium dependencies?
91+
92+
Appium Java Client declares Selenium dependencies using open version range which is handled in differently by different
93+
build tools. Sometimes users may want to pin used Selenium dependencies for [various reasons](https://github.com/appium/java-client/issues/1823).
94+
You can find samples how it can be achieved using [Maven](docs/transitive-dependencies-management.md#maven) or
95+
[Gradle](docs/transitive-dependencies-management.md#gradle) in the docs.
96+
9097
## Drivers Support
9198

9299
Appium java client has dedicated classes to support the following Appium drivers:
@@ -235,4 +242,4 @@ Visit [CHANGELOG.md](CHANGELOG.md) to see the full list of changes between versi
235242

236243
Run a test using
237244

238-
> gradle clean -Dtest.single=IOSAlertTest test
245+
> gradle clean -Dtest.single=IOSAlertTest test
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Maven
2+
3+
Maven downloads dependency of [the latest version](https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges)
4+
matching the declared range by default, in other words whenever new versions of Selenium 4 libraries are published
5+
they are pulled transitively as Appium Java Client dependencies at the first project (re)build automatically.
6+
7+
In order to pin Selenium dependencies they should be declared in `pom.xml` in the following way:
8+
9+
```xml
10+
<dependencies>
11+
<dependency>
12+
<groupId>io.appium</groupId>
13+
<artifactId>java-client</artifactId>
14+
<version>X.Y.Z</version>
15+
<exclusions>
16+
<exclusion>
17+
<groupId>org.seleniumhq.selenium</groupId>
18+
<artifactId>selenium-api</artifactId>
19+
</exclusion>
20+
<exclusion>
21+
<groupId>org.seleniumhq.selenium</groupId>
22+
<artifactId>selenium-remote-driver</artifactId>
23+
</exclusion>
24+
<exclusion>
25+
<groupId>org.seleniumhq.selenium</groupId>
26+
<artifactId>selenium-support</artifactId>
27+
</exclusion>
28+
</exclusions>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.seleniumhq.selenium</groupId>
32+
<artifactId>selenium-api</artifactId>
33+
<version>A.B.C</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.seleniumhq.selenium</groupId>
37+
<artifactId>selenium-remote-driver</artifactId>
38+
<version>A.B.C</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.seleniumhq.selenium</groupId>
42+
<artifactId>selenium-support</artifactId>
43+
<version>A.B.C</version>
44+
</dependency>
45+
</dependencies>
46+
```
47+
48+
# Gradle
49+
50+
Gradle uses [Module Metadata](https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html)
51+
to perform improved dependency resolution whenever it is available. Gradle Module Metadata for Appium Java Client is
52+
published automatically with every release and is available on Maven Central.
53+
54+
Appium Java Client declares [preferred](https://docs.gradle.org/current/userguide/rich_versions.html#rich-version-constraints)
55+
Selenium dependencies version which is equal to the lowest boundary in the version range, i.e. the lowest compatible
56+
Selenium dependencies are pulled by Gradle by default. It's strictly recommended to do not use versions lower than the
57+
range boundary, because unresolvable compilation and runtime errors may occur.
58+
59+
In order to use newer Selenium dependencies they should be explicitly added to Gradle build script (`build.gradle`):
60+
61+
```gradle
62+
dependencies {
63+
implementation('io.appium:java-client:X.Y.Z')
64+
implementation('org.seleniumhq.selenium:selenium-api:A.B.C')
65+
implementation('org.seleniumhq.selenium:selenium-remote-driver:A.B.C')
66+
implementation('org.seleniumhq.selenium:selenium-support:A.B.C')
67+
}
68+
```

0 commit comments

Comments
 (0)