plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
id 'maven-publish'
}
android {
compileSdk 32
defaultConfig {
minSdk 21
targetSdk 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
api 'com.android.billingclient:billing:4.0.0'
api 'com.android.billingclient:billing-ktx:4.0.0'
api 'com.squareup.retrofit2:retrofit:2.9.0'
//支持Gson解析json数据
api 'com.squareup.retrofit2:converter-gson:2.9.0'
api 'com.squareup.retrofit2:converter-scalars:2.9.0'
//支持RxJava返回类型
api "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
api "io.reactivex.rxjava3:rxjava:3.1.5"
api "io.reactivex.rxjava3:rxandroid:3.0.0"
}
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
def versionName = "1.0.3-SNAPSHOT"
def SNAPSHOT_REPOSITORY_URL = "xxxx/repository/maven-snapshots/"
def RELEASE_REPOSITORY_URL = "http://xxxxx/repository/maven-releases/"
afterEvaluate {
publishing {
publications {
Production(MavenPublication) {
// 使用方引用 implementation 'ai.ut.android:billing:1.0.0'
from components.release
groupId = "ai.ut.android"
artifactId = "billing"
version = versionName
// 上传source,这样使用放可以看到方法注释
artifact generateSourcesJar
}
}
repositories {
// 定义一个 maven 仓库
maven {
allowInsecureProtocol = true
// 可以有且仅有一个仓库不指定 name 属性,会隐式设置为 Maven
// 根据 versionName 来判断仓库地址
url = versionName.endsWith('SNAPSHOT') ? SNAPSHOT_REPOSITORY_URL : RELEASE_REPOSITORY_URL
// 仓库用户名密码
credentials {
username = "XXX"
password = "XXXX"
}
}
}
}
}
网友评论