Skip to content

Commit

Permalink
Move common gradle setup to a setting file.
Browse files Browse the repository at this point in the history
This removes a lot of duplication from the module configuration,
avoids divergence, and makes sure that only the important differences
to the default are visible in each module file.

PiperOrigin-RevId: 318024823
  • Loading branch information
tonihei authored and christosts committed Jun 26, 2020
1 parent 7354623 commit 4138e28
Show file tree
Hide file tree
Showing 28 changed files with 67 additions and 439 deletions.
34 changes: 34 additions & 0 deletions common_library_config.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2020 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.

apply from: "$gradle.ext.exoplayerRoot/constants.gradle"
apply plugin: 'com.android.library'

android {
compileSdkVersion project.ext.compileSdkVersion

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions.unitTests.includeAndroidResources = true
}
3 changes: 3 additions & 0 deletions core_settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
def rootDir = gradle.ext.exoplayerRoot
if (!gradle.ext.has('exoplayerSettingsDir')) {
gradle.ext.exoplayerSettingsDir = rootDir
}
def modulePrefix = ':'
if (gradle.ext.has('exoplayerModulePrefix')) {
modulePrefix += gradle.ext.exoplayerModulePrefix
Expand Down
14 changes: 1 addition & 13 deletions extensions/av1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,10 @@
// 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: '../../constants.gradle'
apply plugin: 'com.android.library'
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt'

externalNativeBuild {
cmake {
// Debug CMake build type causes video frames to drop,
Expand Down
19 changes: 1 addition & 18 deletions extensions/cast/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +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: '../../constants.gradle'
apply plugin: 'com.android.library'

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
}

testOptions.unitTests.includeAndroidResources = true
}
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

dependencies {
api 'com.google.android.gms:play-services-cast-framework:18.1.0'
Expand Down
19 changes: 1 addition & 18 deletions extensions/cronet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +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: '../../constants.gradle'
apply plugin: 'com.android.library'

android {
compileSdkVersion project.ext.compileSdkVersion

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions.unitTests.includeAndroidResources = true
}
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

dependencies {
api "com.google.android.gms:play-services-cronet:17.0.0"
Expand Down
18 changes: 1 addition & 17 deletions extensions/ffmpeg/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,13 @@
// 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: '../../constants.gradle'
apply plugin: 'com.android.library'
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt'
}

sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
}

testOptions.unitTests.includeAndroidResources = true
}

dependencies {
Expand Down
19 changes: 1 addition & 18 deletions extensions/flac/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +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.
apply from: '../../constants.gradle'
apply plugin: 'com.android.library'
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

sourceSets {
main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
}
androidTest.assets.srcDir '../../testdata/src/test/assets/'
}

testOptions.unitTests.includeAndroidResources = true
}

dependencies {
Expand Down
19 changes: 2 additions & 17 deletions extensions/gvr/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,9 @@
// 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: '../../constants.gradle'
apply plugin: 'com.android.library'
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 19
targetSdkVersion project.ext.targetSdkVersion
}

testOptions.unitTests.includeAndroidResources = true
}
android.defaultConfig.minSdkVersion 19

dependencies {
implementation project(modulePrefix + 'library-core')
Expand Down
16 changes: 1 addition & 15 deletions extensions/ima/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,17 @@
// 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: '../../constants.gradle'
apply plugin: 'com.android.library'
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
// Enable multidex for androidTests.
multiDexEnabled true
}

sourceSets {
androidTest.assets.srcDir '../../testdata/src/test/assets/'
}

testOptions.unitTests.includeAndroidResources = true
}

dependencies {
Expand Down
19 changes: 1 addition & 18 deletions extensions/jobdispatcher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply from: '../../constants.gradle'
apply plugin: 'com.android.library'

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
}

testOptions.unitTests.includeAndroidResources = true
}
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

dependencies {
implementation project(modulePrefix + 'library-core')
Expand Down
19 changes: 2 additions & 17 deletions extensions/leanback/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,9 @@
// 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: '../../constants.gradle'
apply plugin: 'com.android.library'
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 17
targetSdkVersion project.ext.targetSdkVersion
}

testOptions.unitTests.includeAndroidResources = true
}
android.defaultConfig.minSdkVersion 17

dependencies {
implementation project(modulePrefix + 'library-core')
Expand Down
19 changes: 1 addition & 18 deletions extensions/mediasession/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +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: '../../constants.gradle'
apply plugin: 'com.android.library'

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
}

testOptions.unitTests.includeAndroidResources = true
}
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

dependencies {
implementation project(modulePrefix + 'library-core')
Expand Down
20 changes: 1 addition & 19 deletions extensions/okhttp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +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: '../../constants.gradle'
apply plugin: 'com.android.library'

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt'
}

testOptions.unitTests.includeAndroidResources = true
}
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

dependencies {
implementation project(modulePrefix + 'library-core')
Expand Down
19 changes: 1 addition & 18 deletions extensions/opus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +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.
apply from: '../../constants.gradle'
apply plugin: 'com.android.library'
apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle"

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

sourceSets {
main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
}
androidTest.assets.srcDir '../../testdata/src/test/assets/'
}

testOptions.unitTests.includeAndroidResources = true
}

dependencies {
Expand Down
Loading

0 comments on commit 4138e28

Please sign in to comment.