Modify merge contents of build.gradle into constant definitions

This commit is contained in:
2023-04-16 00:12:35 +08:00
parent 3e1d86a57c
commit f516f2de52
4 changed files with 69 additions and 42 deletions

View File

@@ -8,21 +8,43 @@ plugins {
} }
ext { ext {
devId = "0" android = [
devUser = "fankesyooni" compileSdk: 33,
userEmail = "qzmmcn@163.com" minSdk : 21,
groupId = "com.highcapable.yukireflection" targetSdk : 33
apiVersion = "1.0.0" ]
repoName = "YukiReflection" app = [
repoDescription = "An efficient Reflection API for the Android platform built in Kotlin." versionName: '1.0.0',
licenceName = "MIT License" versionCode: 1
licenceUrl = "https://github.com/fankes/YukiReflection/blob/master/LICENSE" ]
website = "https://github.com/fankes/YukiReflection" maven = [
githubConnection = "scm:git:git://github.com/path/to/repo.git" developer : [
githubDeveloperConnection = "scm:git:ssh://github.com/path/to/repo.git" id : '0',
githubUrl = "https://github.com/path/to/repo" user : 'fankesyooni',
ossName = "OSSRH" email: 'qzmmcn@163.com'
ossUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" ],
repository : [
groupId : 'com.highcapable.yukireflection',
apiVersion : [
name: '1.0.0',
code: 1
],
name : 'YukiReflection',
description: 'An efficient Reflection API for the Android platform built in Kotlin.',
website : 'https://github.com/fankes/YukiReflection',
licence : [
name: 'MIT License',
url : 'https://github.com/fankes/YukiReflection/blob/master/LICENSE'
]
],
configurations: [
githubConnection : 'scm:git:git://github.com/path/to/repo.git',
githubDeveloperConnection: 'scm:git:ssh://github.com/path/to/repo.git',
githubUrl : 'https://github.com/path/to/repo',
ossName : 'OSSRH',
ossUrl : 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
]
]
} }
/** /**

View File

@@ -5,16 +5,18 @@ plugins {
android { android {
namespace 'com.highcapable.yukireflection.demo_app' namespace 'com.highcapable.yukireflection.demo_app'
compileSdk 33 compileSdk rootProject.ext.android.compileSdk
defaultConfig { defaultConfig {
applicationId "com.highcapable.yukireflection.demo_app" applicationId 'com.highcapable.yukireflection.demo_app'
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" minSdk rootProject.ext.android.minSdk
targetSdk rootProject.ext.android.targetSdk
versionCode rootProject.ext.app.versionCode
versionName rootProject.ext.app.versionName
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
buildTypes { buildTypes {

View File

@@ -7,11 +7,14 @@ plugins {
android { android {
namespace 'com.highcapable.yukireflection' namespace 'com.highcapable.yukireflection'
compileSdk 33 compileSdk rootProject.ext.android.compileSdk
defaultConfig { defaultConfig {
minSdk 21 minSdk rootProject.ext.android.minSdk
targetSdk 33 targetSdk rootProject.ext.android.targetSdk
buildConfigField('String', 'API_VERSION_NAME', "\"${rootProject.ext.maven.repository.apiVersion.name}\"")
buildConfigField('int', 'API_VERSION_CODE', "${rootProject.ext.maven.repository.apiVersion.code}")
consumerProguardFiles 'consumer-rules.pro' consumerProguardFiles 'consumer-rules.pro'
} }
@@ -58,8 +61,8 @@ tasks.register('androidSourcesJar', Jar) {
from android.sourceSets.main.java.srcDirs from android.sourceSets.main.java.srcDirs
} }
group = rootProject.ext.groupId group = rootProject.ext.maven.repository.groupId
version = rootProject.ext.apiVersion version = rootProject.ext.maven.repository.apiVersion.name
publishing { publishing {
publications { publications {
@@ -68,34 +71,34 @@ publishing {
artifact "$buildDir/outputs/aar/${project.name}-release.aar" artifact "$buildDir/outputs/aar/${project.name}-release.aar"
artifact androidSourcesJar artifact androidSourcesJar
pom { pom {
name = rootProject.ext.repoName name = rootProject.ext.maven.repository.name
description = rootProject.ext.repoDescription description = rootProject.ext.maven.repository.description
url = rootProject.ext.website url = rootProject.ext.maven.repository.website
licenses { licenses {
license { license {
name = rootProject.ext.licenceName name = rootProject.ext.maven.repository.licence.name
url = rootProject.ext.licenceUrl url = rootProject.ext.maven.repository.licence.url
} }
} }
developers { developers {
developer { developer {
id = rootProject.ext.devId id = rootProject.ext.maven.developer.id
name = rootProject.ext.devUser name = rootProject.ext.maven.developer.user
email = rootProject.ext.userEmail email = rootProject.ext.maven.developer.email
} }
} }
scm { scm {
connection = rootProject.ext.githubConnection connection = rootProject.ext.maven.configurations.githubConnection
developerConnection = rootProject.ext.githubDeveloperConnection developerConnection = rootProject.ext.maven.configurations.githubDeveloperConnection
url = rootProject.ext.githubUrl url = rootProject.ext.maven.configurations.githubUrl
} }
} }
} }
} }
repositories { repositories {
maven { maven {
name = rootProject.ext.ossName name = rootProject.ext.maven.configurations.ossName
url = rootProject.ext.ossUrl url = rootProject.ext.maven.configurations.ossUrl
credentials { credentials {
def configs = getMavenCredentials(projectDir) def configs = getMavenCredentials(projectDir)
username = configs.username username = configs.username

View File

@@ -47,10 +47,10 @@ import java.lang.reflect.Method
object YukiReflection { object YukiReflection {
/** 获取当前 [YukiReflection] 的版本 */ /** 获取当前 [YukiReflection] 的版本 */
const val API_VERSION_NAME = "1.0.0" const val API_VERSION_NAME = BuildConfig.API_VERSION_NAME
/** 获取当前 [YukiReflection] 的版本号 */ /** 获取当前 [YukiReflection] 的版本号 */
const val API_VERSION_CODE = 1 const val API_VERSION_CODE = BuildConfig.API_VERSION_CODE
/** /**
* 配置 [YukiReflection] * 配置 [YukiReflection]