Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
Fix core_settings.gradle to not assume exoplayerRoot is absolute
Browse files Browse the repository at this point in the history
Gradle warns against passing a relative path to `new File(String)`:
https://docs.gradle.org/current/userguide/working_with_files.html#sec:single_file_paths

This change fixes all usages of `exoplayerRoot` to pass it to Gradle's
`Project.file()` first, which returns an absolute `File`.

To reproduce the problem in Issue: google#8927:
1. Checkout ExoPlayer git project, to e.g. `~/ExoPlayer/exoplayer-git`
2. Create a new Android Studio project in e.g. `~/AndroidStudioProjects/exoplayer-test`
3. Edit the new project's `settings.gradle` file as described in
   https:/google/ExoPlayer/blob/release-v2/README.md
   using a relative path for `exoplayerRoot`:
   ```
   gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
   ```
4. In a shell:
   ```bash
   $ cd ~/AndroidStudioProjects/exoplayer-test/app
   $ ../gradlew build
   ```

(Step 4 is important, it seems running `./gradlew` from the project root
doesn't trigger the relative path problem)

This change fixes the problem, and also works with `exoplayerRoot` as a
`File` or `Path` object. `String`, `File` and `Path` all work with relative or
absolute paths:
```
gradle.ext.exoplayerRoot = '/home/ibaker/ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = new File('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = new File('../../ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('../../ExoPlayer/exoplayer-git')
```

Note: The Path versions above require importing `java.nio.file.Paths`
and changing the `apply from:` line in the project's settings.gradle
file to something like:
```
apply from: file(gradle.ext.exoplayerRoot.resolve('core_settings.gradle'))
```
It's assumed that a project wanting to pass a `Path` will make these
changes.

Issue: google#8927
PiperOrigin-RevId: 374421627
  • Loading branch information
icbaker authored and Jacob Walton committed Jun 15, 2021
1 parent ae3120e commit 7c8ac31
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
* Core Library:
* Add `needsReconfiguration` API to the `MediaCodecAdapter` interface.
* Add `fastForward` and `rewind` methods to `Player`.
* Fix gradle config to allow specifying a relative path for
`exoplayerRoot` when [depending on ExoPlayer locally](README.md#locally)
([#8927](https:/google/ExoPlayer/issues/8927)).
* Extractors:
* Add support for MPEG-H 3D Audio in MP4 extractors
([#8860](https:/google/ExoPlayer/pull/8860)).
* Remove deprecated symbols:
* Remove `Player.getPlaybackError`. Use `Player.getPlayerError` instead.
* Remove `Player.getCurrentTag`. Use `Player.getCurrentMediaItem` and
Expand Down Expand Up @@ -105,6 +111,8 @@
* GL demo app:
* Fix texture transformation to avoid green bars shown on some videos
([#8992](https:/google/ExoPlayer/issues/8992)).
* Add `PendingIntent.FLAG_IMMUTABLE` flag to BroadcastReceiver to support
Android 12.

### 2.14.0 (2021-05-13)

Expand Down

0 comments on commit 7c8ac31

Please sign in to comment.