1
- apply plugin : ' com.android.library'
2
-
3
- def safeExtGet (prop , fallback ) {
4
- rootProject. ext. has(prop) ? rootProject. ext. get(prop) : fallback
5
- }
6
-
7
- repositories {
8
- mavenCentral()
9
- jcenter()
10
- google()
11
- }
12
-
13
- buildscript {
14
- repositories {
15
- jcenter()
16
- google()
17
- }
18
- dependencies {
19
- classpath ' com.android.tools.build:gradle:4.0.1'
20
- }
21
- }
22
-
23
- android {
24
- compileSdkVersion safeExtGet(' compileSdkVersion' , 30 )
25
- buildToolsVersion safeExtGet(' buildToolsVersion' , ' 28.0.3' )
26
- defaultConfig {
27
- minSdkVersion safeExtGet(' minSdkVersion' , 16 )
28
- targetSdkVersion safeExtGet(' targetSdkVersion' , 30 )
29
- versionCode 1
30
- versionName " 1.0"
31
- }
32
- buildTypes {
33
- release {
34
- minifyEnabled false
35
- proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
36
- }
37
- }
38
- productFlavors {
39
- }
40
- }
41
-
42
- dependencies {
43
- implementation " com.facebook.react:react-native:${ safeExtGet('reactNativeVersion', '+')} "
44
- implementation ' com.squareup.okhttp3:okhttp:+'
45
- implementation ' com.squareup.okhttp3:logging-interceptor:+'
46
- implementation ' com.squareup.okhttp3:okhttp-urlconnection:+'
47
- // {ReactNativeBlobUtil_PRE_0.28_DEPDENDENCY}
48
- }
1
+ apply plugin : ' com.android.library'
2
+ apply plugin : ' maven'
3
+
4
+ def safeExtGet (prop , fallback ) {
5
+ rootProject. ext. has(prop) ? rootProject. ext. get(prop) : fallback
6
+ }
7
+
8
+ repositories {
9
+ mavenCentral()
10
+ mavenLocal()
11
+ maven {
12
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
13
+ url " $rootDir /../node_modules/react-native/android"
14
+ }
15
+ maven {
16
+ // Android JSC is installed from npm
17
+ url " $rootDir /../node_modules/jsc-android/dist"
18
+ }
19
+ google()
20
+ }
21
+
22
+ buildscript {
23
+ // The Android Gradle plugin is only required when opening the android folder stand-alone.
24
+ // This avoids unnecessary downloads and potential conflicts when the library is included as a
25
+ // module dependency in an application project.
26
+ // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
27
+ if (project == rootProject) {
28
+ repositories {
29
+ google()
30
+ mavenCentral()
31
+ }
32
+ dependencies {
33
+ classpath ' com.android.tools.build:gradle:4.1.0'
34
+ }
35
+ }
36
+ }
37
+
38
+ android {
39
+ compileSdkVersion safeExtGet(' compileSdkVersion' , 30 )
40
+ buildToolsVersion safeExtGet(' buildToolsVersion' , ' 28.0.3' )
41
+ defaultConfig {
42
+ minSdkVersion safeExtGet(' minSdkVersion' , 16 )
43
+ targetSdkVersion safeExtGet(' targetSdkVersion' , 30 )
44
+ versionCode 1
45
+ versionName " 1.0"
46
+ }
47
+ buildTypes {
48
+ release {
49
+ minifyEnabled false
50
+ proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
51
+ }
52
+ }
53
+ productFlavors {
54
+ }
55
+ }
56
+
57
+ dependencies {
58
+ implementation " com.facebook.react:react-native:${ safeExtGet('reactNativeVersion', '+')} "
59
+ implementation ' com.squareup.okhttp3:okhttp:+'
60
+ implementation ' com.squareup.okhttp3:logging-interceptor:+'
61
+ implementation ' com.squareup.okhttp3:okhttp-urlconnection:+'
62
+ // {ReactNativeBlobUtil_PRE_0.28_DEPDENDENCY}
63
+ }
64
+
65
+ def configureReactNativePom (def pom ) {
66
+ def packageJson = new groovy.json.JsonSlurper (). parseText(file(' ../package.json' ). text)
67
+
68
+ pom. project {
69
+ name packageJson. title
70
+ artifactId packageJson. name
71
+ version = packageJson. version
72
+ group = " com.ReactNativeBlobUtil"
73
+ description packageJson. description
74
+ url packageJson. repository. baseUrl
75
+
76
+ licenses {
77
+ license {
78
+ name packageJson. license
79
+ url packageJson. repository. baseUrl + ' /blob/master/' + packageJson. licenseFilename
80
+ distribution ' repo'
81
+ }
82
+ }
83
+
84
+ developers {
85
+ developer {
86
+ id packageJson. author. username
87
+ name packageJson. author. name
88
+ }
89
+ }
90
+ }
91
+ }
92
+
93
+ afterEvaluate { project ->
94
+ // some Gradle build hooks ref:
95
+ // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
96
+ task androidJavadoc(type : Javadoc ) {
97
+ source = android. sourceSets. main. java. srcDirs
98
+ classpath + = files(android. bootClasspath)
99
+ classpath + = files(project. getConfigurations(). getByName(' compile' ). asList())
100
+ include ' **/*.java'
101
+ }
102
+
103
+ task androidJavadocJar(type : Jar , dependsOn : androidJavadoc) {
104
+ classifier = ' javadoc'
105
+ from androidJavadoc. destinationDir
106
+ }
107
+
108
+ task androidSourcesJar(type : Jar ) {
109
+ classifier = ' sources'
110
+ from android. sourceSets. main. java. srcDirs
111
+ include ' **/*.java'
112
+ }
113
+
114
+ android. libraryVariants. all { variant ->
115
+ def name = variant. name. capitalize()
116
+ def javaCompileTask = variant. javaCompileProvider. get()
117
+
118
+ task " jar${ name} " (type : Jar , dependsOn : javaCompileTask) {
119
+ from javaCompileTask. destinationDir
120
+ }
121
+ }
122
+
123
+ artifacts {
124
+ archives androidSourcesJar
125
+ archives androidJavadocJar
126
+ }
127
+
128
+ task installArchives(type : Upload ) {
129
+ configuration = configurations. archives
130
+ repositories. mavenDeployer {
131
+ // Deploy to react-native-event-bridge/maven, ready to publish to npm
132
+ repository url : " file://${ projectDir} /../android/maven"
133
+ configureReactNativePom pom
134
+ }
135
+ }
136
+ }
0 commit comments