From 2a8eb5a2a11b8e51120e3aca3884c95c4c144e29 Mon Sep 17 00:00:00 2001 From: olly Date: Tue, 27 Jun 2017 07:23:02 -0700 Subject: [PATCH] Make it easier to use ExoPlayer modules in other projects It's currently difficult to use ExoPlayer modules in other gradle projects because they rely on constants and dependencies defined in our own top level gradle file. This change moves the constants into a separate file referenced directly from each module. It also removes the need for the top level gradle file to declare a dependency on com.novoda:bintray-release. This is now only needed if "exoplayerPublishEnabled = true" is specified. Issue: #2851 Issue: #2974 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160272072 --- build.gradle | 24 +----------------------- demo/build.gradle | 1 + extensions/cronet/build.gradle | 1 + extensions/ffmpeg/build.gradle | 1 + extensions/flac/build.gradle | 1 + extensions/gvr/build.gradle | 1 + extensions/ima/build.gradle | 1 + extensions/okhttp/build.gradle | 1 + extensions/opus/build.gradle | 1 + extensions/vp9/build.gradle | 1 + library/all/build.gradle | 1 + library/core/build.gradle | 1 + library/dash/build.gradle | 1 + library/hls/build.gradle | 1 + library/smoothstreaming/build.gradle | 1 + library/ui/build.gradle | 1 + playbacktests/build.gradle | 1 + publish.gradle | 28 ++++++++++++++++++---------- testutils/build.gradle | 1 + version_constants.gradle | 28 ++++++++++++++++++++++++++++ 20 files changed, 64 insertions(+), 33 deletions(-) create mode 100644 version_constants.gradle diff --git a/build.gradle b/build.gradle index 4f18e7c801..981bab596c 100644 --- a/build.gradle +++ b/build.gradle @@ -33,23 +33,7 @@ allprojects { jcenter() } 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 by the library requires API level 16 or greater. - minSdkVersion = 9 - compileSdkVersion = 25 - targetSdkVersion = 25 - buildToolsVersion = '25' - testSupportLibraryVersion = '0.5' - supportLibraryVersion = '25.3.1' - dexmakerVersion = '1.2' - mockitoVersion = '1.9.5' - releaseRepoName = getBintrayRepo() - releaseUserOrg = 'google' - releaseGroupId = 'com.google.android.exoplayer' - releaseVersion = 'r2.4.2' - releaseWebsite = 'https://github.com/google/ExoPlayer' + exoplayerPublishEnabled = true } if (it.hasProperty('externalBuildDir')) { if (!new File(externalBuildDir).isAbsolute()) { @@ -59,10 +43,4 @@ allprojects { } } -def getBintrayRepo() { - boolean publicRepo = hasProperty('publicRepo') && - property('publicRepo').toBoolean() - return publicRepo ? 'exoplayer' : 'exoplayer-test' -} - apply from: 'javadoc_combined.gradle' diff --git a/demo/build.gradle b/demo/build.gradle index 939c5ac93d..4d930b8a78 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -11,6 +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 plugin: 'com.android.application' android { diff --git a/extensions/cronet/build.gradle b/extensions/cronet/build.gradle index 5611817b2e..199cee2a71 100644 --- a/extensions/cronet/build.gradle +++ b/extensions/cronet/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/extensions/ffmpeg/build.gradle b/extensions/ffmpeg/build.gradle index 0eddd017a4..57e1c25bc0 100644 --- a/extensions/ffmpeg/build.gradle +++ b/extensions/ffmpeg/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/extensions/flac/build.gradle b/extensions/flac/build.gradle index 4a6b8e0e5a..ebe5d1d796 100644 --- a/extensions/flac/build.gradle +++ b/extensions/flac/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/extensions/gvr/build.gradle b/extensions/gvr/build.gradle index e15c8b1ad8..d21912a686 100644 --- a/extensions/gvr/build.gradle +++ b/extensions/gvr/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/extensions/ima/build.gradle b/extensions/ima/build.gradle index 4ba26cc244..90ca98ab84 100644 --- a/extensions/ima/build.gradle +++ b/extensions/ima/build.gradle @@ -1,3 +1,4 @@ +apply from: '../../version_constants.gradle' apply plugin: 'com.android.library' android { diff --git a/extensions/okhttp/build.gradle b/extensions/okhttp/build.gradle index f47f1a8556..7f3f3d2e1a 100644 --- a/extensions/okhttp/build.gradle +++ b/extensions/okhttp/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/extensions/opus/build.gradle b/extensions/opus/build.gradle index 31d5450fdd..7c86d994d9 100644 --- a/extensions/opus/build.gradle +++ b/extensions/opus/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/extensions/vp9/build.gradle b/extensions/vp9/build.gradle index 5068586a4a..8f2947439b 100644 --- a/extensions/vp9/build.gradle +++ b/extensions/vp9/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/library/all/build.gradle b/library/all/build.gradle index 63943ada77..270d92ce33 100644 --- a/library/all/build.gradle +++ b/library/all/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/library/core/build.gradle b/library/core/build.gradle index ad1c150fe7..5d9ece71b6 100644 --- a/library/core/build.gradle +++ b/library/core/build.gradle @@ -12,6 +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' android { compileSdkVersion project.ext.compileSdkVersion diff --git a/library/dash/build.gradle b/library/dash/build.gradle index 36d3edfbae..e1598f783f 100644 --- a/library/dash/build.gradle +++ b/library/dash/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/library/hls/build.gradle b/library/hls/build.gradle index 47b5758b1d..140dafc237 100644 --- a/library/hls/build.gradle +++ b/library/hls/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/library/smoothstreaming/build.gradle b/library/smoothstreaming/build.gradle index 28ebd74758..dd51dc13aa 100644 --- a/library/smoothstreaming/build.gradle +++ b/library/smoothstreaming/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/library/ui/build.gradle b/library/ui/build.gradle index 96dcd52655..be600ec126 100644 --- a/library/ui/build.gradle +++ b/library/ui/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/playbacktests/build.gradle b/playbacktests/build.gradle index 199077f2b2..217d913853 100644 --- a/playbacktests/build.gradle +++ b/playbacktests/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/publish.gradle b/publish.gradle index 17214959ab..ca1a2cfd8b 100644 --- a/publish.gradle +++ b/publish.gradle @@ -11,14 +11,22 @@ // 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 plugin: 'bintray-release' - -publish { - artifactId = releaseArtifact - description = releaseDescription - repoName = releaseRepoName - userOrg = releaseUserOrg - groupId = releaseGroupId - version = releaseVersion - website = releaseWebsite +if (project.ext.has("exoplayerPublishEnabled") + && project.ext.exoplayerPublishEnabled) { + apply plugin: 'bintray-release' + publish { + artifactId = releaseArtifact + description = releaseDescription + version = releaseVersion + repoName = getBintrayRepo() + userOrg = 'google' + groupId = 'com.google.android.exoplayer' + website = 'https://github.com/google/ExoPlayer' + } +} + +def getBintrayRepo() { + boolean publicRepo = hasProperty('publicRepo') && + property('publicRepo').toBoolean() + return publicRepo ? 'exoplayer' : 'exoplayer-test' } diff --git a/testutils/build.gradle b/testutils/build.gradle index 5fea76f9c3..801bd36298 100644 --- a/testutils/build.gradle +++ b/testutils/build.gradle @@ -11,6 +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 plugin: 'com.android.library' android { diff --git a/version_constants.gradle b/version_constants.gradle new file mode 100644 index 0000000000..9f69263c9e --- /dev/null +++ b/version_constants.gradle @@ -0,0 +1,28 @@ +// 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. +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 + // by the library requires API level 16 or greater. + minSdkVersion = 9 + compileSdkVersion = 25 + targetSdkVersion = 25 + buildToolsVersion = '25' + testSupportLibraryVersion = '0.5' + supportLibraryVersion = '25.3.1' + dexmakerVersion = '1.2' + mockitoVersion = '1.9.5' + releaseVersion = 'r2.4.2' +}