From 4a59c7cf409a3c9caf01217eeba74adb41ad30d2 Mon Sep 17 00:00:00 2001 From: olly Date: Tue, 27 Jun 2017 08:27:36 -0700 Subject: [PATCH] Make it easier to use ExoPlayer modules in other projects II With this change, it becomes possible to depend on ExoPlayer locally in settings.gradle by doing: gradle.ext.exoplayerRoot = 'path/to/exoplayer/root' apply from: new File(gradle.ext.exoplayerRoot, 'core_settings.gradle') You can optionally add a prefix onto ExoPlayer's module names by adding: gradle.ext.exoplayerModulePrefix = 'prefix' Issue: #2851 Issue: #2974 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160277967 --- version_constants.gradle => constants.gradle | 6 ++- core_settings.gradle | 54 ++++++++++++++++++++ demo/build.gradle | 22 ++++---- extensions/cronet/build.gradle | 6 +-- extensions/ffmpeg/build.gradle | 4 +- extensions/flac/build.gradle | 6 +-- extensions/gvr/build.gradle | 4 +- extensions/ima/build.gradle | 6 +-- extensions/okhttp/build.gradle | 4 +- extensions/opus/build.gradle | 4 +- extensions/vp9/build.gradle | 4 +- library/all/build.gradle | 12 ++--- library/core/build.gradle | 2 +- library/dash/build.gradle | 6 +-- library/hls/build.gradle | 4 +- library/smoothstreaming/build.gradle | 6 +-- library/ui/build.gradle | 4 +- playbacktests/build.gradle | 10 ++-- settings.gradle | 46 +++++------------ testutils/build.gradle | 4 +- 20 files changed, 125 insertions(+), 89 deletions(-) rename version_constants.gradle => constants.gradle (88%) create mode 100644 core_settings.gradle diff --git a/version_constants.gradle b/constants.gradle similarity index 88% rename from version_constants.gradle rename to constants.gradle index 9f69263c9e..95221a106f 100644 --- a/version_constants.gradle +++ b/constants.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -ext { +project.ext { // Important: ExoPlayer specifies a minSdkVersion of 9 because various // components provided by the library may be of use on older devices. // However, please note that the core media playback functionality provided @@ -25,4 +25,8 @@ ext { dexmakerVersion = '1.2' mockitoVersion = '1.9.5' releaseVersion = 'r2.4.2' + modulePrefix = ':'; + if (gradle.ext.has('exoplayerModulePrefix')) { + modulePrefix += gradle.ext.exoplayerModulePrefix + } } diff --git a/core_settings.gradle b/core_settings.gradle new file mode 100644 index 0000000000..abf5422b04 --- /dev/null +++ b/core_settings.gradle @@ -0,0 +1,54 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +def rootDir = gradle.ext.exoplayerRoot +def modulePrefix = ':' +if (gradle.ext.has('exoplayerModulePrefix')) { + modulePrefix += gradle.ext.exoplayerModulePrefix +} + +include modulePrefix + 'library' +include modulePrefix + 'library-core' +include modulePrefix + 'library-dash' +include modulePrefix + 'library-hls' +include modulePrefix + 'library-smoothstreaming' +include modulePrefix + 'library-ui' +include modulePrefix + 'testutils' +include modulePrefix + 'extension-ffmpeg' +include modulePrefix + 'extension-flac' +include modulePrefix + 'extension-gvr' +include modulePrefix + 'extension-ima' +include modulePrefix + 'extension-okhttp' +include modulePrefix + 'extension-opus' +include modulePrefix + 'extension-vp9' + +project(modulePrefix + 'library').projectDir = new File(rootDir, 'library/all') +project(modulePrefix + 'library-core').projectDir = new File(rootDir, 'library/core') +project(modulePrefix + 'library-dash').projectDir = new File(rootDir, 'library/dash') +project(modulePrefix + 'library-hls').projectDir = new File(rootDir, 'library/hls') +project(modulePrefix + 'library-smoothstreaming').projectDir = new File(rootDir, 'library/smoothstreaming') +project(modulePrefix + 'library-ui').projectDir = new File(rootDir, 'library/ui') +project(modulePrefix + 'testutils').projectDir = new File(rootDir, 'testutils') +project(modulePrefix + 'extension-ffmpeg').projectDir = new File(rootDir, 'extensions/ffmpeg') +project(modulePrefix + 'extension-flac').projectDir = new File(rootDir, 'extensions/flac') +project(modulePrefix + 'extension-gvr').projectDir = new File(rootDir, 'extensions/gvr') +project(modulePrefix + 'extension-ima').projectDir = new File(rootDir, 'extensions/ima') +project(modulePrefix + 'extension-okhttp').projectDir = new File(rootDir, 'extensions/okhttp') +project(modulePrefix + 'extension-opus').projectDir = new File(rootDir, 'extensions/opus') +project(modulePrefix + 'extension-vp9').projectDir = new File(rootDir, 'extensions/vp9') + +if (gradle.ext.has('exoplayerIncludeCronetExtension') + && gradle.ext.exoplayerIncludeCronetExtension) { + include modulePrefix + 'extension-cronet' + project(modulePrefix + 'extension-cronet').projectDir = new File(rootDir, 'extensions/cronet') +} diff --git a/demo/build.gradle b/demo/build.gradle index 4d930b8a78..7eea25478f 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../version_constants.gradle' +apply from: '../constants.gradle' apply plugin: 'com.android.application' android { @@ -46,14 +46,14 @@ android { } dependencies { - compile project(':library-core') - compile project(':library-dash') - compile project(':library-hls') - compile project(':library-smoothstreaming') - compile project(':library-ui') - withExtensionsCompile project(path: ':extension-ffmpeg') - withExtensionsCompile project(path: ':extension-flac') - withExtensionsCompile project(path: ':extension-ima') - withExtensionsCompile project(path: ':extension-opus') - withExtensionsCompile project(path: ':extension-vp9') + compile project(modulePrefix + 'library-core') + compile project(modulePrefix + 'library-dash') + compile project(modulePrefix + 'library-hls') + compile project(modulePrefix + 'library-smoothstreaming') + compile project(modulePrefix + 'library-ui') + withExtensionsCompile project(path: modulePrefix + 'extension-ffmpeg') + withExtensionsCompile project(path: modulePrefix + 'extension-flac') + withExtensionsCompile project(path: modulePrefix + 'extension-ima') + withExtensionsCompile project(path: modulePrefix + 'extension-opus') + withExtensionsCompile project(path: modulePrefix + 'extension-vp9') } diff --git a/extensions/cronet/build.gradle b/extensions/cronet/build.gradle index 199cee2a71..930a53c7c5 100644 --- a/extensions/cronet/build.gradle +++ b/extensions/cronet/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -30,11 +30,11 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile files('libs/cronet_api.jar') compile files('libs/cronet_impl_common_java.jar') compile files('libs/cronet_impl_native_java.jar') - androidTestCompile project(':library') + androidTestCompile project(modulePrefix + 'library') androidTestCompile 'com.google.dexmaker:dexmaker:' + dexmakerVersion androidTestCompile 'com.google.dexmaker:dexmaker-mockito:' + dexmakerVersion androidTestCompile 'org.mockito:mockito-core:' + mockitoVersion diff --git a/extensions/ffmpeg/build.gradle b/extensions/ffmpeg/build.gradle index 57e1c25bc0..9820818f3e 100644 --- a/extensions/ffmpeg/build.gradle +++ b/extensions/ffmpeg/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,7 +31,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') } ext { diff --git a/extensions/flac/build.gradle b/extensions/flac/build.gradle index ebe5d1d796..4d840d34ac 100644 --- a/extensions/flac/build.gradle +++ b/extensions/flac/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,8 +31,8 @@ android { } dependencies { - compile project(':library-core') - androidTestCompile project(':testutils') + compile project(modulePrefix + 'library-core') + androidTestCompile project(modulePrefix + 'testutils') } ext { diff --git a/extensions/gvr/build.gradle b/extensions/gvr/build.gradle index d21912a686..66665576bb 100644 --- a/extensions/gvr/build.gradle +++ b/extensions/gvr/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -25,7 +25,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile 'com.google.vr:sdk-audio:1.60.1' } diff --git a/extensions/ima/build.gradle b/extensions/ima/build.gradle index 90ca98ab84..3f95fcd414 100644 --- a/extensions/ima/build.gradle +++ b/extensions/ima/build.gradle @@ -1,4 +1,4 @@ -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -13,7 +13,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile 'com.android.support:support-annotations:' + supportLibraryVersion compile 'com.google.ads.interactivemedia.v3:interactivemedia:3.6.0' compile 'com.google.android.gms:play-services-ads:10.2.4' @@ -28,7 +28,7 @@ dependencies { // will become unnecessary when the support-v4 dependency in the chain above // has been updated to 24.2.0 or later. compile 'com.android.support:support-v4:' + supportLibraryVersion - androidTestCompile project(':library') + androidTestCompile project(modulePrefix + 'library') androidTestCompile 'com.google.dexmaker:dexmaker:' + dexmakerVersion androidTestCompile 'com.google.dexmaker:dexmaker-mockito:' + dexmakerVersion androidTestCompile 'org.mockito:mockito-core:' + mockitoVersion diff --git a/extensions/okhttp/build.gradle b/extensions/okhttp/build.gradle index 7f3f3d2e1a..0aba07d118 100644 --- a/extensions/okhttp/build.gradle +++ b/extensions/okhttp/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -30,7 +30,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile('com.squareup.okhttp3:okhttp:3.6.0') { exclude group: 'org.json' } diff --git a/extensions/opus/build.gradle b/extensions/opus/build.gradle index 7c86d994d9..41b428070f 100644 --- a/extensions/opus/build.gradle +++ b/extensions/opus/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,7 +31,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') } ext { diff --git a/extensions/vp9/build.gradle b/extensions/vp9/build.gradle index 8f2947439b..de6dc65f74 100644 --- a/extensions/vp9/build.gradle +++ b/extensions/vp9/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,7 +31,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') } ext { diff --git a/library/all/build.gradle b/library/all/build.gradle index 270d92ce33..79ed9c747b 100644 --- a/library/all/build.gradle +++ b/library/all/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -25,11 +25,11 @@ android { } dependencies { - compile project(':library-core') - compile project(':library-dash') - compile project(':library-hls') - compile project(':library-smoothstreaming') - compile project(':library-ui') + compile project(modulePrefix + 'library-core') + compile project(modulePrefix + 'library-dash') + compile project(modulePrefix + 'library-hls') + compile project(modulePrefix + 'library-smoothstreaming') + compile project(modulePrefix + 'library-ui') } ext { diff --git a/library/core/build.gradle b/library/core/build.gradle index 5d9ece71b6..65a7353607 100644 --- a/library/core/build.gradle +++ b/library/core/build.gradle @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. apply plugin: 'com.android.library' -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' android { compileSdkVersion project.ext.compileSdkVersion diff --git a/library/dash/build.gradle b/library/dash/build.gradle index e1598f783f..aa8031467e 100644 --- a/library/dash/build.gradle +++ b/library/dash/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,10 +31,10 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile 'com.android.support:support-annotations:' + supportLibraryVersion compile 'com.android.support:support-core-utils:' + supportLibraryVersion - androidTestCompile project(':testutils') + androidTestCompile project(modulePrefix + 'testutils') androidTestCompile 'com.google.dexmaker:dexmaker:' + dexmakerVersion androidTestCompile 'com.google.dexmaker:dexmaker-mockito:' + dexmakerVersion androidTestCompile 'org.mockito:mockito-core:' + mockitoVersion diff --git a/library/hls/build.gradle b/library/hls/build.gradle index 140dafc237..77680569f0 100644 --- a/library/hls/build.gradle +++ b/library/hls/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,7 +31,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile 'com.android.support:support-annotations:' + supportLibraryVersion androidTestCompile 'com.google.dexmaker:dexmaker:' + dexmakerVersion androidTestCompile 'com.google.dexmaker:dexmaker-mockito:' + dexmakerVersion diff --git a/library/smoothstreaming/build.gradle b/library/smoothstreaming/build.gradle index dd51dc13aa..b5f918075f 100644 --- a/library/smoothstreaming/build.gradle +++ b/library/smoothstreaming/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,9 +31,9 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile 'com.android.support:support-annotations:' + supportLibraryVersion - androidTestCompile project(':testutils') + androidTestCompile project(modulePrefix + 'testutils') androidTestCompile 'com.google.dexmaker:dexmaker:' + dexmakerVersion androidTestCompile 'com.google.dexmaker:dexmaker-mockito:' + dexmakerVersion androidTestCompile 'org.mockito:mockito-core:' + mockitoVersion diff --git a/library/ui/build.gradle b/library/ui/build.gradle index be600ec126..c036bc9819 100644 --- a/library/ui/build.gradle +++ b/library/ui/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../../version_constants.gradle' +apply from: '../../constants.gradle' apply plugin: 'com.android.library' android { @@ -31,7 +31,7 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile 'com.android.support:support-annotations:' + supportLibraryVersion } diff --git a/playbacktests/build.gradle b/playbacktests/build.gradle index 217d913853..6cd56868f9 100644 --- a/playbacktests/build.gradle +++ b/playbacktests/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../version_constants.gradle' +apply from: '../constants.gradle' apply plugin: 'com.android.library' android { @@ -25,8 +25,8 @@ android { } dependencies { - androidTestCompile project(':library-core') - androidTestCompile project(':library-dash') - androidTestCompile project(':library-hls') - androidTestCompile project(':testutils') + androidTestCompile project(modulePrefix + 'library-core') + androidTestCompile project(modulePrefix + 'library-dash') + androidTestCompile project(modulePrefix + 'library-hls') + androidTestCompile project(modulePrefix + 'testutils') } diff --git a/settings.gradle b/settings.gradle index d50cb9d3dd..fb31055f5e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,38 +11,16 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -include ':library' -include ':library-core' -include ':library-dash' -include ':library-hls' -include ':library-smoothstreaming' -include ':library-ui' -include ':testutils' -include ':demo' -include ':playbacktests' -include ':extension-ffmpeg' -include ':extension-flac' -include ':extension-gvr' -include ':extension-ima' -include ':extension-okhttp' -include ':extension-opus' -include ':extension-vp9' -// Uncomment the following line to use the Cronet Extension. -// include ':extension-cronet' +gradle.ext.exoplayerRoot = settingsDir -project(':library').projectDir = new File(settingsDir, 'library/all') -project(':library-core').projectDir = new File(settingsDir, 'library/core') -project(':library-dash').projectDir = new File(settingsDir, 'library/dash') -project(':library-hls').projectDir = new File(settingsDir, 'library/hls') -project(':library-smoothstreaming').projectDir = new File(settingsDir, 'library/smoothstreaming') -project(':library-ui').projectDir = new File(settingsDir, 'library/ui') -project(':extension-ffmpeg').projectDir = new File(settingsDir, 'extensions/ffmpeg') -project(':extension-flac').projectDir = new File(settingsDir, 'extensions/flac') -project(':extension-gvr').projectDir = new File(settingsDir, 'extensions/gvr') -project(':extension-ima').projectDir = new File(settingsDir, 'extensions/ima') -project(':extension-okhttp').projectDir = new File(settingsDir, 'extensions/okhttp') -project(':extension-opus').projectDir = new File(settingsDir, 'extensions/opus') -project(':extension-vp9').projectDir = new File(settingsDir, 'extensions/vp9') -// Uncomment the following line to use the Cronet Extension. -// See extensions/cronet/README.md for details. -// project(':extension-cronet').projectDir = new File(settingsDir, 'extensions/cronet') +def modulePrefix = ':' +if (gradle.ext.has('exoplayerModulePrefix')) { + modulePrefix += gradle.ext.exoplayerModulePrefix +} + +include modulePrefix + 'demo' +include modulePrefix + 'playbacktests' +project(modulePrefix + 'demo').projectDir = new File(rootDir, 'demo') +project(modulePrefix + 'playbacktests').projectDir = new File(rootDir, 'playbacktests') + +apply from: 'core_settings.gradle' diff --git a/testutils/build.gradle b/testutils/build.gradle index 801bd36298..db8462b1fd 100644 --- a/testutils/build.gradle +++ b/testutils/build.gradle @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -apply from: '../version_constants.gradle' +apply from: '../constants.gradle' apply plugin: 'com.android.library' android { @@ -25,6 +25,6 @@ android { } dependencies { - compile project(':library-core') + compile project(modulePrefix + 'library-core') compile 'org.mockito:mockito-core:' + mockitoVersion }