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 {
devId = "0"
devUser = "fankesyooni"
userEmail = "qzmmcn@163.com"
groupId = "com.highcapable.yukireflection"
apiVersion = "1.0.0"
repoName = "YukiReflection"
repoDescription = "An efficient Reflection API for the Android platform built in Kotlin."
licenceName = "MIT License"
licenceUrl = "https://github.com/fankes/YukiReflection/blob/master/LICENSE"
website = "https://github.com/fankes/YukiReflection"
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/"
android = [
compileSdk: 33,
minSdk : 21,
targetSdk : 33
]
app = [
versionName: '1.0.0',
versionCode: 1
]
maven = [
developer : [
id : '0',
user : 'fankesyooni',
email: 'qzmmcn@163.com'
],
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 {
namespace 'com.highcapable.yukireflection.demo_app'
compileSdk 33
compileSdk rootProject.ext.android.compileSdk
defaultConfig {
applicationId "com.highcapable.yukireflection.demo_app"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
applicationId 'com.highcapable.yukireflection.demo_app'
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 {

View File

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

View File

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