blob: dd34e310657c7d6d52e405384596c640e1d73670 [file] [log] [blame]
/*
* Copyright (C) 2021 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.
*/
plugins {
id 'com.android.application' apply false
id 'com.android.library'
}
def buildTest = gradle.startParameter.taskNames.join(' ').contains('connectedAndroidTest')
buildDir="../../out_paddleboat"
android {
namespace 'com.google.android.games.paddleboat'
defaultConfig {
minSdkVersion 19
compileSdkVersion 31
targetSdkVersion 35
versionCode 1
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
externalNativeBuild {
cmake {
def cmakeArgs = []
if (project.hasProperty("stl")) {
cmakeArgs << ('-DANDROID_STL='+ project.stl)
} else {
cmakeArgs << ('-DANDROID_STL=c++_shared')
}
if(buildTest) {
cmakeArgs << ("-DBUILD_TEST=ON")
}
arguments(*cmakeArgs)
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
version "3.18.1+"
}
}
buildFeatures {
prefabPublishing true
prefab true
}
prefab {
paddleboat {
name "paddleboat"
headers "src/main/cpp/include"
}
paddleboat_static {
name "paddleboat_static"
headers "src/main/cpp/include"
}
if(buildTest) {
paddleboat_test {
name "paddleboat_test"
headers "src/main/cpp/include"
}
}
}
// If we don't include this line the created .aar contains the c++ std lib
// at <.aar_file>/jni/<abi>/libc++_shared.so. When we have multiple
// libraries containing libc++_shared.so the linker complains because it
// can't choose between them. Because we use prefab we don't need to
// contents of the <.aar_file>/jni/* folder so we can just exclude it here
// to prevent the jni folder from being created.
packagingOptions {
if(buildTest) {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
} else {
exclude("**.so")
}
}
}
dependencies {
implementation "androidx.annotation:annotation:1.3.0"
if(buildTest) {
implementation 'androidx.test.ext:junit-gtest:1.0.0-alpha01'
implementation 'com.android.ndk.thirdparty:googletest:1.11.0-beta-1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
}
repositories {
google()
mavenCentral()
}