plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'maven-publish' id 'kotlin-kapt' } def versionCode = 1 def versionName = "0.0.1.011" android { namespace 'cn.org.bjca.trust.push' compileSdk 33 defaultConfig { minSdk 24 targetSdk 33 buildConfigField("int", "versionCode", "${versionCode}") buildConfigField("String", "versionName", "\"${versionName}\"") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" multiDexEnabled true } buildTypes { debug { // 开启混淆 minifyEnabled false // Zipalign压缩优化 zipAlignEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } release { // 开启混淆 minifyEnabled true // Zipalign压缩优化 zipAlignEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { jvmTarget = '11' } publishing { multipleVariants { withSourcesJar() withJavadocJar() allVariants() } } } dependencies { compileOnly fileTree(dir: 'libs',includes: ['*.jar','*.aar']) implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.5.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' //数据库相关 implementation("androidx.room:room-runtime:2.5.0") kapt("androidx.room:room-compiler:2.5.0") // implementation("androidx.room:room-ktx:2.5.0") //添加mqtt 2个包 implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5' implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1' //网络请求 implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' api 'com.squareup.okhttp3:logging-interceptor:4.9.1' implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1' //Dagger implementation 'com.google.dagger:hilt-android:2.40.5' kapt 'com.google.dagger:hilt-android-compiler:2.40.5' //Coroutine api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" api "androidx.lifecycle:lifecycle-runtime-ktx:2.5.0-alpha05" //gson api 'com.google.code.gson:gson:2.9.0' // 小米推送 // implementation (name: 'MiPush_SDK_Client_5_3_0-C_3rd', ext: 'aar') // 华为推送 implementation 'com.huawei.hms:push:6.9.0.300' } // 这个是把源码打入aar包中的任务 task sourceJar(type: Jar) { archiveClassifier.set('sources') from android.sourceSets.main.java.srcDirs } /** * 上传aar到仓库 */ afterEvaluate { publishing { publications { release(MavenPublication) { groupId = 'cn.org.bjca.trus' artifactId = 'push' version = versionName // 这里除了有debug 还有release from components.release // 运行任务,把源码打进去 // artifact sourceJar } } // 添加仓库地址 repositories { maven { allowInsecureProtocol(true) name = "xuqm" url = mavenXuqm.mavenUrl credentials { username(mavenXuqm.username) password(mavenXuqm.password) } } maven { allowInsecureProtocol(true) name = "szyx" url = mavenSzyx.mavenUrl credentials { username(mavenSzyx.username) password(mavenSzyx.password) } } } } }