1- // android/build.gradle
1+ apply plugin : ' com. android.library '
22
33def safeExtGet (prop , fallback ) {
44 rootProject. ext. has(prop) ? rootProject. ext. get(prop) : fallback
55}
66
7- buildscript {
8- // The Android Gradle plugin is only required when opening the android folder stand-alone.
9- // This avoids unnecessary downloads and potential conflicts when the library is included as a
10- // module dependency in an application project.
11- if (project == rootProject) {
12- repositories {
13- google()
14- jcenter()
15- }
16- dependencies {
17- classpath ' com.android.tools.build:gradle:3.5.3'
18- }
19- }
20- }
21-
22- apply plugin : ' com.android.library'
23- apply plugin : ' maven'
24-
25- // Matches values in recent template from React Native 0.63
26- // https://github.com/facebook/react-native/blob/0.63-stable/template/android/build.gradle#L5-L9
27- def DEFAULT_COMPILE_SDK_VERSION = 29
28- def DEFAULT_BUILD_TOOLS_VERSION = " 29.0.2"
29- def DEFAULT_MIN_SDK_VERSION = 21
30- def DEFAULT_TARGET_SDK_VERSION = 29
31-
327android {
33- compileSdkVersion safeExtGet(' compileSdkVersion' , DEFAULT_COMPILE_SDK_VERSION )
34- buildToolsVersion safeExtGet(' buildToolsVersion' , DEFAULT_BUILD_TOOLS_VERSION )
35- defaultConfig {
36- minSdkVersion safeExtGet(' minSdkVersion' , DEFAULT_MIN_SDK_VERSION )
37- targetSdkVersion safeExtGet(' targetSdkVersion' , DEFAULT_TARGET_SDK_VERSION )
38- versionCode 1
39- versionName " 1.0"
40- }
41- lintOptions {
42- abortOnError false
43- }
44- }
8+ compileSdkVersion safeExtGet(' compileSdkVersion' , 29 )
459
46- repositories {
47- mavenLocal()
48- maven {
49- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
50- url " $rootDir /../node_modules/react-native/android"
51- }
52- maven {
53- // Android JSC is installed from npm
54- url " $rootDir /../node_modules/jsc-android/dist"
10+ defaultConfig {
11+ minSdkVersion safeExtGet(' minSdkVersion' , 21 )
12+ targetSdkVersion safeExtGet(' targetSdkVersion' , 29 )
5513 }
56- google()
57- jcenter()
5814}
5915
6016dependencies {
61- // ref:
62- // https://github.com/facebook/react-native/blob/0.61-stable/template/android/app/build.gradle#L192
6317 // noinspection GradleDynamicVersion
6418 implementation ' com.facebook.react:react-native:+' // From node_modules
65- }
66-
67- def configureReactNativePom (def pom ) {
68- // noinspection UnnecessaryQualifiedReference
69- def packageJson = new groovy.json.JsonSlurper (). parseText(file(' ../package.json' ). text)
70-
71- pom. project {
72- name packageJson. title
73- artifactId packageJson. name
74- version = packageJson. version
75- group = " com.asterinet.react.tcpsocket"
76- description packageJson. description
77- url packageJson. repository. baseUrl
78-
79- licenses {
80- license {
81- name packageJson. license
82- url packageJson. repository. baseUrl + ' /blob/master/' + packageJson. licenseFilename
83- distribution ' repo'
84- }
85- }
86-
87- developers {
88- developer {
89- id packageJson. author. username
90- name packageJson. author. name
91- }
92- }
93- }
94- }
95-
96- afterEvaluate { project ->
97- // some Gradle build hooks ref:
98- // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
99- task androidJavadoc(type : Javadoc ) {
100- source = android. sourceSets. main. java. srcDirs
101- classpath + = files(android. bootClasspath)
102- classpath + = files(project. getConfigurations(). getByName(' compile' ). asList())
103- include ' **/*.java'
104- }
105-
106- task androidJavadocJar(type : Jar , dependsOn : androidJavadoc) {
107- classifier = ' javadoc'
108- from androidJavadoc. destinationDir
109- }
110-
111- task androidSourcesJar(type : Jar ) {
112- classifier = ' sources'
113- from android. sourceSets. main. java. srcDirs
114- include ' **/*.java'
115- }
116-
117- android. libraryVariants. all { variant ->
118- def name = variant. name. capitalize()
119- task " jar${ name} " (type : Jar , dependsOn : variant. javaCompileProvider. get()) {
120- from variant. javaCompileProvider. get(). destinationDir
121- }
122- }
123-
124- artifacts {
125- archives androidSourcesJar
126- archives androidJavadocJar
127- }
128-
129- task installArchives(type : Upload ) {
130- configuration = configurations. archives
131- repositories. mavenDeployer {
132- // Deploy to react-native-event-bridge/maven, ready to publish to npm
133- repository url : " file://${ projectDir} /../android/maven"
134- configureReactNativePom pom
135- }
136- }
137- }
19+ }
0 commit comments