mirror of
https://github.com/HighCapable/YukiReflection.git
synced 2025-09-05 18:25:42 +08:00
chore: migrate build script from groovy to kts
- using SweetDependency, SweetProperty - using new maven publish function - update gradle and dependencies
This commit is contained in:
63
build.gradle
63
build.gradle
@@ -1,63 +0,0 @@
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
plugins {
|
||||
id 'com.android.application' version '7.4.1' apply false
|
||||
id 'com.android.library' version '7.4.1' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.20' apply false
|
||||
}
|
||||
|
||||
ext {
|
||||
android = [
|
||||
compileSdk: 33,
|
||||
minSdk : 21,
|
||||
targetSdk : 33
|
||||
]
|
||||
app = [
|
||||
versionName: 'universal',
|
||||
versionCode: 1
|
||||
]
|
||||
maven = [
|
||||
developer : [
|
||||
id : '0',
|
||||
user : 'fankesyooni',
|
||||
email: 'qzmmcn@163.com'
|
||||
],
|
||||
repository : [
|
||||
groupId : 'com.highcapable.yukireflection',
|
||||
apiVersion : [
|
||||
name: '1.0.2',
|
||||
code: 3
|
||||
],
|
||||
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'
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Maven 授权信息 - 用于 Maven 的提交
|
||||
* @param childProjectDir 子项目的目录
|
||||
* @return [Object]
|
||||
*/
|
||||
@SuppressWarnings('unused')
|
||||
static Object getMavenCredentials(File childProjectDir) {
|
||||
def slurper = new JsonSlurper()
|
||||
try {
|
||||
return slurper.parse(new File("${childProjectDir.getParent()}/.maven/credentials.json"))
|
||||
} catch (Throwable ignored) {
|
||||
return slurper.parseText('{"username":"-NEEDED-","password":"-NEEDED-"}')
|
||||
}
|
||||
}
|
5
build.gradle.kts
Normal file
5
build.gradle.kts
Normal file
@@ -0,0 +1,5 @@
|
||||
plugins {
|
||||
autowire(libs.plugins.android.application) apply false
|
||||
autowire(libs.plugins.kotlin.jvm) apply false
|
||||
autowire(libs.plugins.kotlin.android) apply false
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.highcapable.yukireflection.demo_app'
|
||||
compileSdk rootProject.ext.android.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'com.highcapable.yukireflection.demo_app'
|
||||
|
||||
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 {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
freeCompilerArgs = [
|
||||
'-Xno-param-assertions',
|
||||
'-Xno-call-assertions',
|
||||
'-Xno-receiver-assertions'
|
||||
]
|
||||
}
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':yukireflection')
|
||||
implementation 'androidx.core:core-ktx:1.10.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.8.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
}
|
@@ -1,23 +1,30 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Compiler Configuration
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
android.nonTransitiveRClass=true
|
||||
kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
kotlin.incremental.useClasspathSnapshot=true
|
||||
# Project Configuration
|
||||
project.name=YukiReflection
|
||||
project.description=An efficient Reflection API for Java and Android built in Kotlin.
|
||||
project.url=https://github.com/fankes/YukiReflection
|
||||
project.groupName=com.highcapable.yukireflection
|
||||
project.yukireflection-core.moduleName=api
|
||||
project.yukireflection-core.version="1.0.2"
|
||||
project.yukireflection-core.kotlin-optIn.YukiPrivateApi=${project.groupName}.annotation.YukiPrivateApi
|
||||
project.licence.name=MIT
|
||||
project.licence.url=https://github.com/fankes/YukiReflection/blob/master/LICENSE
|
||||
project.developer.id="0"
|
||||
project.developer.name=fankes
|
||||
project.developer.email=qzmmcn@163.com
|
||||
project.android.compileSdk=34
|
||||
project.android.minSdk=21
|
||||
project.android.targetSdk=34
|
||||
project.samples-demo-android.packageName=${project.groupName}.demo_app
|
||||
project.samples-demo-android.versionName=universal
|
||||
project.samples-demo-android.versionCode=1
|
||||
project.samples-demo-jvm.groupName=${project.groupName}.demo_jvm
|
||||
# Maven Publish Configuration
|
||||
maven.publish.scm.connection=scm:git:git://github.com/fankes/YukiReflection.git
|
||||
maven.publish.scm.developerConnection=scm:git:ssh://github.com/fankes/YukiReflection.git
|
||||
maven.publish.scm.url=https://github.com/fankes/YukiReflection
|
52
gradle/sweet-dependency/sweet-dependency-config.yaml
Normal file
52
gradle/sweet-dependency/sweet-dependency-config.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
preferences:
|
||||
autowire-on-sync-mode: UPDATE_OPTIONAL_DEPENDENCIES
|
||||
repositories-mode: FAIL_ON_PROJECT_REPOS
|
||||
|
||||
repositories:
|
||||
gradle-plugin-portal:
|
||||
scope: PLUGINS
|
||||
google:
|
||||
maven-central:
|
||||
|
||||
plugins:
|
||||
org.jetbrains.kotlin.jvm:
|
||||
alias: kotlin-jvm
|
||||
version: 1.9.10
|
||||
org.jetbrains.kotlin.android:
|
||||
alias: kotlin-android
|
||||
version-ref: kotlin-jvm
|
||||
org.jetbrains.compose:
|
||||
alias: kotlin-compose
|
||||
version: 1.5.1
|
||||
com.android.application:
|
||||
alias: android-application
|
||||
version: 8.1.1
|
||||
com.vanniktech.maven.publish:
|
||||
alias: maven-publish
|
||||
version: 0.25.3
|
||||
|
||||
libraries:
|
||||
org.jetbrains.compose.material3:
|
||||
material3-desktop:
|
||||
version: 1.5.1
|
||||
androidx.core:
|
||||
core-ktx:
|
||||
version: 1.10.0
|
||||
androidx.appcompat:
|
||||
appcompat:
|
||||
version: 1.6.1
|
||||
com.google.android.material:
|
||||
material:
|
||||
version: 1.8.0
|
||||
androidx.constraintlayout:
|
||||
constraintlayout:
|
||||
version: 2.1.4
|
||||
androidx.test.ext:
|
||||
junit:
|
||||
version: 1.1.5
|
||||
androidx.test.espresso:
|
||||
espresso-core:
|
||||
version: 3.5.1
|
||||
junit:
|
||||
junit:
|
||||
version: 4.13.2
|
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
||||
#Sat Jan 21 10:47:38 CST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStoreBase=GRADLE_USER_HOME
|
52
samples/demo-android/build.gradle.kts
Normal file
52
samples/demo-android/build.gradle.kts
Normal file
@@ -0,0 +1,52 @@
|
||||
plugins {
|
||||
autowire(libs.plugins.android.application)
|
||||
autowire(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = property.project.samples.demo.android.packageName
|
||||
compileSdk = property.project.android.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
applicationId = property.project.samples.demo.android.packageName
|
||||
minSdk = property.project.android.minSdk
|
||||
targetSdk = property.project.android.targetSdk
|
||||
versionName = property.project.samples.demo.android.versionName
|
||||
versionCode = property.project.samples.demo.android.versionCode
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xno-param-assertions",
|
||||
"-Xno-call-assertions",
|
||||
"-Xno-receiver-assertions"
|
||||
)
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
viewBinding = true
|
||||
}
|
||||
lint { checkReleaseBuilds = false }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.yukireflectionCore)
|
||||
implementation(androidx.core.core.ktx)
|
||||
implementation(androidx.appcompat.appcompat)
|
||||
implementation(com.google.android.material.material)
|
||||
implementation(androidx.constraintlayout.constraintlayout)
|
||||
testImplementation(junit.junit)
|
||||
androidTestImplementation(androidx.test.ext.junit)
|
||||
androidTestImplementation(androidx.test.espresso.espresso.core)
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
rootProject.name = "YukiReflection"
|
||||
include ':demo-app'
|
||||
include ':yukireflection'
|
27
settings.gradle.kts
Normal file
27
settings.gradle.kts
Normal file
@@ -0,0 +1,27 @@
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id("com.highcapable.sweetdependency") version "1.0.1"
|
||||
id("com.highcapable.sweetproperty") version "1.0.2"
|
||||
}
|
||||
sweetProperty {
|
||||
global {
|
||||
sourcesCode {
|
||||
includeKeys("^project\\..*\$".toRegex())
|
||||
isEnableRestrictedAccess = true
|
||||
}
|
||||
}
|
||||
rootProject { all { isEnable = false } }
|
||||
project("samples:demo-android") { sourcesCode { isEnable = false } }
|
||||
project("samples:demo-jvm") { sourcesCode { isEnable = false } }
|
||||
project("yukireflection-core") { sourcesCode { className = rootProject.name } }
|
||||
}
|
||||
rootProject.name = "YukiReflection"
|
||||
include(":samples:demo-android", ":samples:demo-jvm")
|
||||
include(":yukireflection-core")
|
67
yukireflection-core/build.gradle.kts
Normal file
67
yukireflection-core/build.gradle.kts
Normal file
@@ -0,0 +1,67 @@
|
||||
plugins {
|
||||
autowire(libs.plugins.kotlin.jvm)
|
||||
autowire(libs.plugins.maven.publish)
|
||||
}
|
||||
|
||||
group = property.project.groupName
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
all {
|
||||
languageSettings {
|
||||
optIn(property.project.yukireflection.core.kotlin.optIn.yukiPrivateApi)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
freeCompilerArgs = listOf(
|
||||
"-opt-in=${property.project.yukireflection.core.kotlin.optIn.yukiPrivateApi}",
|
||||
"-Xno-param-assertions",
|
||||
"-Xno-call-assertions",
|
||||
"-Xno-receiver-assertions"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(files("libs/android-34.jar"))
|
||||
}
|
||||
|
||||
mavenPublishing {
|
||||
coordinates(property.project.groupName, property.project.yukireflection.core.moduleName, property.project.yukireflection.core.version)
|
||||
pom {
|
||||
name = property.project.name
|
||||
description = property.project.description
|
||||
url = property.project.url
|
||||
licenses {
|
||||
license {
|
||||
name = property.project.licence.name
|
||||
url = property.project.licence.url
|
||||
distribution = property.project.licence.url
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = property.project.developer.id
|
||||
name = property.project.developer.name
|
||||
email = property.project.developer.email
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url = property.maven.publish.scm.url
|
||||
connection = property.maven.publish.scm.connection
|
||||
developerConnection = property.maven.publish.scm.developerConnection
|
||||
}
|
||||
}
|
||||
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.S01)
|
||||
signAllPublications()
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.highcapable.yukireflection'
|
||||
compileSdk rootProject.ext.android.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
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'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
freeCompilerArgs = [
|
||||
'-opt-in=com.highcapable.yukireflection.annotation.YukiPrivateApi',
|
||||
'-Xno-param-assertions',
|
||||
'-Xno-call-assertions',
|
||||
'-Xno-receiver-assertions'
|
||||
]
|
||||
}
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
publishing {
|
||||
singleVariant('release') {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin { sourceSets { all { languageSettings { optIn('com.highcapable.yukireflection.annotation.YukiPrivateApi') } } } }
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.core:core-ktx:1.10.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
}
|
||||
|
||||
tasks.register('androidSourcesJar', Jar) {
|
||||
archiveClassifier.set('sources')
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
|
||||
group = rootProject.ext.maven.repository.groupId
|
||||
version = rootProject.ext.maven.repository.apiVersion.name
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
artifactId = 'api'
|
||||
artifact "$buildDir/outputs/aar/${project.name}-release.aar"
|
||||
artifact androidSourcesJar
|
||||
pom {
|
||||
name = rootProject.ext.maven.repository.name
|
||||
description = rootProject.ext.maven.repository.description
|
||||
url = rootProject.ext.maven.repository.website
|
||||
licenses {
|
||||
license {
|
||||
name = rootProject.ext.maven.repository.licence.name
|
||||
url = rootProject.ext.maven.repository.licence.url
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = rootProject.ext.maven.developer.id
|
||||
name = rootProject.ext.maven.developer.user
|
||||
email = rootProject.ext.maven.developer.email
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = rootProject.ext.maven.configurations.githubConnection
|
||||
developerConnection = rootProject.ext.maven.configurations.githubDeveloperConnection
|
||||
url = rootProject.ext.maven.configurations.githubUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = rootProject.ext.maven.configurations.ossName
|
||||
url = rootProject.ext.maven.configurations.ossUrl
|
||||
credentials {
|
||||
def configs = getMavenCredentials(projectDir)
|
||||
username = configs.username
|
||||
password = configs.password
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing { sign publishing.publications }
|
Reference in New Issue
Block a user