Skip to content

Commit 9b93713

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

File tree

2 files changed

+86
-11
lines changed

2 files changed

+86
-11
lines changed

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ This is the Java language bindings for writing Appium Tests that conform to [Web
88

99
## v8 Migration
1010

11-
Since version 8 Appium Java Client had several major changes, which might require to
11+
Since version 8 Appium Java Client had several major changes, which might require to
1212
update your client code. Make sure to follow the [v7 to v8 Migration Guide](https://github.com/appium/java-client/blob/master/docs/v7-to-v8-migration-guide.md)
1313
in order to streamline the migration process.
1414

1515
## Add Appium java client to your test framework
1616

1717
### Stable
1818

19-
#### Maven
19+
#### Maven
2020

2121
Add the following to pom.xml:
2222

@@ -57,19 +57,19 @@ Add the following to pom.xml:
5757
```
5858

5959
Add the dependency:
60-
60+
6161
```xml
6262
<dependency>
6363
<groupId>com.github.appium</groupId>
6464
<artifactId>java-client</artifactId>
6565
<version>latest commit ID from master branch</version>
6666
</dependency>
67-
```
67+
```
6868

6969
#### Gradle
7070

7171
Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:
72-
72+
7373
```groovy
7474
allprojects {
7575
repositories {
@@ -80,13 +80,20 @@ allprojects {
8080
```
8181

8282
Add the dependency:
83-
83+
8484
```groovy
8585
dependencies {
8686
implementation 'com.github.appium:java-client:latest commit id from master branch'
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:
@@ -98,7 +105,7 @@ Appium java client has dedicated classes to support the following Appium drivers
98105
- [Gecko](https://github.com/appium/appium-geckodriver): [GeckoDriver](src/main/java/io/appium/java_client/gecko/GeckoDriver.java)
99106
- [Mac2](https://github.com/appium/appium-mac2-driver): [Mac2Driver](src/main/java/io/appium/java_client/mac/Mac2Driver.java)
100107

101-
To automate other platforms that are not listed above you could use
108+
To automate other platforms that are not listed above you could use
102109
[AppiumDriver](src/main/java/io/appium/java_client/AppiumDriver.java) or its custom derivatives.
103110

104111
Appium java client is built on top of Selenium and implements same interfaces that the foundation
@@ -197,7 +204,7 @@ try {
197204

198205
Check the corresponding driver's READMEs to know the list of capabilities and features it supports.
199206

200-
You could find much more code examples by checking client's
207+
You could find much more code examples by checking client's
201208
[unit and integration tests](src/test/java/io/appium/java_client).
202209

203210
## Troubleshooting
@@ -207,7 +214,7 @@ You could find much more code examples by checking client's
207214
Appium Java client uses reflective access to private members of other modules
208215
to ensure proper functionality of several features, like Page Object model.
209216
If you get a runtime exception and `InaccessibleObjectException` is present in
210-
the stacktrace, and your Java runtime is at version 16 or higher, then consider following
217+
the stacktrace, and your Java runtime is at version 16 or higher, then consider following
211218
[Oracle's tutorial](https://docs.oracle.com/en/java/javase/16/migrate/migrating-jdk-8-later-jdk-releases.html#GUID-7BB28E4D-99B3-4078-BDC4-FC24180CE82B)
212219
and/or checking [existing issues](https://github.com/appium/java-client/search?q=InaccessibleObjectException&type=issues)
213220
for possible solutions. Basically, the idea there would be to explicitly allow
@@ -223,9 +230,9 @@ framework code rather than run separately by a script or manually. Depending
223230
on the way the server process is started it may or may not inherit the currently
224231
active shell environment. That is why you may still receive errors about variables
225232
presence even though these variables ar actually defined for your command line interpreter.
226-
Again, there is no universal solution to that, as there are many ways to spin up a new
233+
Again, there is no universal solution to that, as there are many ways to spin up a new
227234
server process. Consider checking the [Appium Environment Troubleshooting](docs/environment.md)
228-
document for more information on how to debug and fix process environment issues.
235+
document for more information on how to debug and fix process environment issues.
229236

230237
## Changelog
231238

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)