-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request firofame#32 from cristianoccazinsp/gradle-cleanup
Cleanup gradle file
- Loading branch information
Showing
1 changed file
with
5 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,28 @@ | ||
// android/build.gradle | ||
|
||
// based on: | ||
// | ||
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle | ||
|
||
def DEFAULT_COMPILE_SDK_VERSION = 29 | ||
def DEFAULT_BUILD_TOOLS_VERSION = '29.0.3' | ||
def DEFAULT_MIN_SDK_VERSION = 16 | ||
def DEFAULT_TARGET_SDK_VERSION = 29 | ||
|
||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'maven-publish' | ||
|
||
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() | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:4.1.0' | ||
} | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) | ||
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) | ||
minSdkVersion safeExtGet('minSdkVersion', 16) | ||
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
repositories { | ||
// ref: https://www.baeldung.com/maven-local-repository | ||
mavenLocal() | ||
repositories{ | ||
mavenCentral() | ||
maven { | ||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
url "$rootDir/../node_modules/react-native/android" | ||
} | ||
maven { | ||
// Android JSC is installed from npm | ||
url "$rootDir/../node_modules/jsc-android/dist" | ||
} | ||
google() | ||
} | ||
|
||
dependencies { | ||
//noinspection GradleDynamicVersion | ||
implementation 'com.facebook.react:react-native:+' // From node_modules | ||
} | ||
|
||
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.reactlibrary.compassheading" | ||
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) | ||
classpath += files(project.getConfigurations().getByName('compile').asList()) | ||
include '**/*.java' | ||
} | ||
|
||
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { | ||
classifier = 'javadoc' | ||
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 | ||
} | ||
|
||
// task installArchives(type: Upload) { | ||
// configuration = configurations.archives | ||
// repositories.maven { | ||
// // Deploy to react-native-event-bridge/maven, ready to publish to npm | ||
// repository url: "file://${projectDir}/../android/maven" | ||
// configureReactNativePom pom | ||
// } | ||
// } | ||
} | ||
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" | ||
} |