react-native-appmetrica/android/build.gradle

166 lines
5.2 KiB
Groovy
Raw Normal View History

2020-06-08 22:14:06 +03:00
/*
* Version for React Native
* © 2020 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/
// android/build.gradle
// based on:
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
def DEFAULT_COMPILE_SDK_VERSION = 30
def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2'
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 30
2020-06-08 22:14:06 +03:00
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
2020-06-08 22:14:06 +03:00
buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
if (project == rootProject) {
repositories {
google()
2022-07-05 17:25:19 +03:00
jcenter()
2022-07-05 17:04:04 +03:00
mavenCentral()
2020-06-08 22:14:06 +03:00
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
2020-06-08 22:14:06 +03:00
}
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
2020-06-08 22:14:06 +03:00
android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
2022-07-22 16:56:02 +03:00
maven {
2020-06-08 22:14:06 +03:00
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
2022-07-22 16:56:02 +03:00
url("$rootDir/../node_modules/react-native/android")
2020-06-08 22:14:06 +03:00
}
2022-07-22 16:56:02 +03:00
maven {
2020-06-08 22:14:06 +03:00
// Android JSC is installed from npm
2022-07-22 16:56:02 +03:00
url("$rootDir/../node_modules/jsc-android/dist")
2020-06-08 22:14:06 +03:00
}
2022-07-22 16:56:02 +03:00
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
2020-06-08 22:14:06 +03:00
}
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.yandex.android:mobmetricalib:5.0.0'
implementation 'com.android.installreferrer:installreferrer:2.2'
2020-06-08 22:14:06 +03:00
}
def configureReactNativePom(def pom) {
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.yandex.metrica.plugin.reactnative"
description packageJson.description
url packageJson.repository.baseUrl
licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}
developers {
developer {
id packageJson.author.username
name packageJson.author.name
}
}
}
}
afterEvaluate { project ->
// some Gradle build hooks ref:
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
project.getConfigurations().getByName('implementation').setCanBeResolved(true)
2022-08-03 20:03:44 +03:00
// To do понять почему не компилит с этой сторокой и нужна ли она вообще.
// classpath += files(project.getConfigurations().getByName('implementation').asList())
2020-06-08 22:14:06 +03:00
include '**/*.java'
}
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
archiveClassifier = 'javadoc'
2020-06-08 22:14:06 +03:00
from androidJavadoc.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}
android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir
}
}
artifacts {
archives androidSourcesJar
archives androidJavadocJar
}
publishing {
repositories {
maven {
url = uri("${rootProject.projectDir}/maven-repo")
}
2020-06-08 22:14:06 +03:00
}
}
}