-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor build configs (build.gradle, Podfile) (#305)
* Refactor android build.gradle to use ext values https://github.com/callstack/react-native-builder-bob/blob/main/packages/create-react-native-library/templates/kotlin-library/android/build.gradle * Set kakao_sdk_version as predefined or user specified version * Fix gradle properties file * Add mark for $KakaoSDKVersion testing * Remove jcenter deps. * Remove unused comment * Move iOS default version settings to podspec * Add feature to docs * Rollback RNKakaoLogins_kakaoSdkVersion to 2.9.0
- Loading branch information
Showing
7 changed files
with
158 additions
and
58 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
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
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
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,60 +1,142 @@ | ||
buildscript { | ||
ext { | ||
gradleVersion = '4.1.0' | ||
kotlinVersion = '1.3.41' | ||
} | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
// Buildscript is evaluated before everything else so we can't use getExtOrDefault | ||
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNKakaoLogins_kotlinVersion'] | ||
def gradle_version = rootProject.ext.has('gradleVersion') ? rootProject.ext.get('gradleVersion') : project.properties['RNKakaoLogins_gradleVersion'] | ||
|
||
dependencies { | ||
classpath("com.android.tools.build:gradle:$gradleVersion") | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" | ||
} | ||
} | ||
repositories { | ||
google() | ||
mavenCentral() | ||
|
||
maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' } | ||
} | ||
|
||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
dependencies { | ||
classpath "com.android.tools.build:gradle:$gradle_version" | ||
// noinspection DifferentKotlinGradleVersion | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion safeExtGet('compileSdkVersion', 29) | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet('minSdkVersion', 19) | ||
targetSdkVersion safeExtGet('targetSdkVersion', 29) | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
def getExtOrDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNKakaoLogins_' + name] | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
def getExtOrIntegerDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RNKakaoLogins_' + name]).toInteger() | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
android { | ||
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') | ||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
lintOptions { | ||
disable 'GradleCompatible' | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
repositories { | ||
maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' } | ||
mavenCentral() | ||
google() | ||
|
||
maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' } | ||
|
||
|
||
def found = false | ||
def defaultDir = null | ||
def androidSourcesName = 'React Native sources' | ||
|
||
if (rootProject.ext.has('reactNativeAndroidRoot')) { | ||
defaultDir = rootProject.ext.get('reactNativeAndroidRoot') | ||
} else { | ||
defaultDir = new File( | ||
projectDir, | ||
'/../../../node_modules/react-native/android' | ||
) | ||
} | ||
|
||
if (defaultDir.exists()) { | ||
maven { | ||
url defaultDir.toString() | ||
name androidSourcesName | ||
} | ||
|
||
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}") | ||
found = true | ||
} else { | ||
def parentDir = rootProject.projectDir | ||
|
||
1.upto(5, { | ||
if (found) return true | ||
parentDir = parentDir.parentFile | ||
|
||
def androidSourcesDir = new File( | ||
parentDir, | ||
'node_modules/react-native' | ||
) | ||
|
||
def androidPrebuiltBinaryDir = new File( | ||
parentDir, | ||
'node_modules/react-native/android' | ||
) | ||
|
||
if (androidPrebuiltBinaryDir.exists()) { | ||
maven { | ||
url androidPrebuiltBinaryDir.toString() | ||
name androidSourcesName | ||
} | ||
|
||
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}") | ||
found = true | ||
} else if (androidSourcesDir.exists()) { | ||
maven { | ||
url androidSourcesDir.toString() | ||
name androidSourcesName | ||
} | ||
|
||
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}") | ||
found = true | ||
} | ||
}) | ||
} | ||
|
||
if (!found) { | ||
throw new GradleException( | ||
"${project.name}: unable to locate React Native android sources. " + | ||
"Ensure you have you installed React Native as a dependency in your project and try again." | ||
) | ||
} | ||
} | ||
|
||
def kotlin_version = getExtOrDefault('kotlinVersion') | ||
def kakao_sdk_version = getExtOrDefault('kakaoSdkVersion') | ||
|
||
dependencies { | ||
implementation 'com.facebook.react:react-native:+' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${project.ext.kotlinVersion}" | ||
implementation "com.kakao.sdk:v2-user:2.9.0" | ||
implementation "com.kakao.sdk:v2-talk:2.9.0" | ||
implementation "com.kakao.sdk:v2-story:2.9.0" | ||
} | ||
// noinspection GradleDynamicVersion | ||
api 'com.facebook.react:react-native:+' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
|
||
// Kakao | ||
implementation "com.kakao.sdk:v2-user:$kakao_sdk_version" // 카카오 로그인 | ||
implementation "com.kakao.sdk:v2-talk:$kakao_sdk_version" // 친구, 메시지(카카오톡) | ||
implementation "com.kakao.sdk:v2-story:$kakao_sdk_version" // 카카오 스토리 | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RNKakaoLogins_kotlinVersion=1.3.50 | ||
RNKakaoLogins_compileSdkVersion=31 | ||
RNKakaoLogins_targetSdkVersion=31 | ||
RNKakaoLogins_kakaoSdkVersion=2.9.0 | ||
RNKakaoLogins_gradleVersion=4.1.0 |
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
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 |
---|---|---|
|
@@ -48,4 +48,4 @@ | |
"prettier": "^2.4.1", | ||
"typescript": "^4.4.4" | ||
} | ||
} | ||
} |