build(deps): 升级 Gradle 与 Kotlin 及依赖配置
This commit is contained in:
140
app/build.gradle
140
app/build.gradle
@@ -1,86 +1,87 @@
|
|||||||
apply plugin: 'com.android.application'
|
plugins {
|
||||||
apply plugin: 'kotlin-android'
|
id 'com.android.application'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
id 'org.jetbrains.kotlin.android'
|
||||||
apply plugin: 'kotlin-kapt'
|
id 'kotlin-kapt'
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.arialyy.simple"
|
applicationId "com.arialyy.simple"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
|
||||||
|
|
||||||
signingConfigs {
|
|
||||||
release {
|
|
||||||
storeFile file("lyy.keystore")
|
|
||||||
storePassword "123456"
|
|
||||||
keyAlias "key0"
|
|
||||||
keyPassword "123456"
|
|
||||||
v2SigningEnabled false
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
signingConfigs {
|
||||||
debug {
|
release {
|
||||||
debuggable true
|
storeFile file("lyy.keystore")
|
||||||
minifyEnabled false //混淆
|
storePassword "123456"
|
||||||
|
keyAlias "key0"
|
||||||
|
keyPassword "123456"
|
||||||
|
v2SigningEnabled false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
release {
|
|
||||||
zipAlignEnabled true
|
buildTypes {
|
||||||
minifyEnabled true
|
debug {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
debuggable true
|
||||||
signingConfig signingConfigs.release
|
minifyEnabled false //混淆
|
||||||
|
}
|
||||||
|
release {
|
||||||
|
zipAlignEnabled true
|
||||||
|
minifyEnabled true
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
signingConfig signingConfigs.release
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
dataBinding {
|
dataBinding {
|
||||||
enabled = true
|
enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
||||||
merge 'META-INF/services/com.arialyy.aria.core.inf.IUtil'
|
merge 'META-INF/services/com.arialyy.aria.core.inf.IUtil'
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
abortOnError false
|
abortOnError false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
|
||||||
|
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation 'com.google.android.material:material:1.0.0'
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}"
|
||||||
api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
|
||||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||||
implementation 'com.pddstudio:highlightjs-android:1.5.0'
|
implementation 'com.pddstudio:highlightjs-android:1.5.0'
|
||||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||||
implementation project(':AppFrame')
|
implementation project(':AppFrame')
|
||||||
|
|
||||||
// aria
|
// aria
|
||||||
kapt project(':AriaCompiler')
|
kapt project(':AriaCompiler')
|
||||||
implementation project(':Aria')
|
implementation project(':Aria')
|
||||||
implementation project(':M3U8Component')
|
implementation project(':M3U8Component')
|
||||||
implementation project(':FtpComponent')
|
implementation project(':FtpComponent')
|
||||||
implementation project(path: ':AriaAnnotations')
|
implementation project(path: ':AriaAnnotations')
|
||||||
implementation project(path: ':SFtpComponent')
|
implementation project(path: ':SFtpComponent')
|
||||||
|
|
||||||
|
|
||||||
// implementation 'com.arialyy.aria:core:3.8.12'
|
// implementation 'com.arialyy.aria:core:3.8.12'
|
||||||
@@ -89,8 +90,9 @@ dependencies {
|
|||||||
// implementation 'com.arialyy.aria:sftpComponent:3.8.12' // 如果需要使用ftp,请增加该组件
|
// implementation 'com.arialyy.aria:sftpComponent:3.8.12' // 如果需要使用ftp,请增加该组件
|
||||||
// implementation 'com.arialyy.aria:m3u8Component:3.8.12' // 如果需要使用m3u8下载功能,请增加该组件
|
// implementation 'com.arialyy.aria:m3u8Component:3.8.12' // 如果需要使用m3u8下载功能,请增加该组件
|
||||||
|
|
||||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|||||||
134
build.gradle
134
build.gradle
@@ -1,79 +1,93 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
// ext.kotlin_version = '1.3.20'
|
ext.kotlin_version = '2.4.0'
|
||||||
ext.kotlin_version = '1.4.30'
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
maven { url 'https://jitpack.io' }
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://maven.google.com' }
|
||||||
}
|
maven { url 'https://developer.huawei.com/repo/' }
|
||||||
dependencies {
|
maven { url 'https://developer.hihonor.com/repo' }
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||||
// classpath 'com.novoda:bintray-release:0.9.1'
|
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
|
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||||
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.30" // kotlin 文档引擎
|
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||||
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
|
}
|
||||||
// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
dependencies {
|
||||||
// in the individual module build.gradle files
|
classpath 'com.android.tools.build:gradle:8.13.2'
|
||||||
}
|
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
|
||||||
|
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.30" // kotlin 文档引擎
|
||||||
|
// classpath 'com.novoda:bintray-release:0.9.1'
|
||||||
|
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
|
||||||
|
// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
maven { url 'https://jitpack.io' }
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://maven.google.com' }
|
||||||
}
|
maven { url 'https://developer.huawei.com/repo/' }
|
||||||
|
maven { url 'https://developer.hihonor.com/repo' }
|
||||||
tasks.withType(Javadoc) {
|
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||||
options {
|
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||||
encoding "UTF-8"
|
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||||
charSet 'UTF-8'
|
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||||
links "http://docs.oracle.com/javase/7/docs/api"
|
}
|
||||||
|
|
||||||
|
tasks.withType(Javadoc) {
|
||||||
|
options {
|
||||||
|
encoding "UTF-8"
|
||||||
|
charSet 'UTF-8'
|
||||||
|
links "http://docs.oracle.com/javase/7/docs/api"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
versionCode = 390
|
versionCode = 390
|
||||||
versionName = '3.8.16-beta-1'
|
versionName = '3.8.16-beta-1'
|
||||||
userOrg = 'arialyy'
|
userOrg = 'arialyy'
|
||||||
groupId = 'com.arialyy.aria'
|
groupId = 'com.arialyy.aria'
|
||||||
publishVersion = versionName
|
publishVersion = versionName
|
||||||
// publishVersion = '1.0.4' //FTP插件
|
// publishVersion = '1.0.4' //FTP插件
|
||||||
repoName='maven'
|
repoName = 'maven'
|
||||||
// repoName='aria'
|
// repoName='aria'
|
||||||
|
|
||||||
desc = 'android 下载框架'
|
desc = 'android 下载框架'
|
||||||
website = 'https://github.com/AriaLyy/Aria'
|
website = 'https://github.com/AriaLyy/Aria'
|
||||||
licences = ['Apache-2.0']
|
licences = ['Apache-2.0']
|
||||||
|
|
||||||
// mavenCentral
|
// mavenCentral
|
||||||
mavenVersion = '3.8.16'
|
mavenVersion = '3.8.16'
|
||||||
mavenCentralGroupId = 'me.laoyuyu.aria'
|
mavenCentralGroupId = 'me.laoyuyu.aria'
|
||||||
mavenCentralUserID = 'laoyuyu'
|
mavenCentralUserID = 'laoyuyu'
|
||||||
mavenCentralUserName = 'laoyuyu'
|
mavenCentralUserName = 'laoyuyu'
|
||||||
mavenCentralEmail = '511455842@qq.com'
|
mavenCentralEmail = '511455842@qq.com'
|
||||||
mavenCentralLicences = 'Apache-2.0'
|
mavenCentralLicences = 'Apache-2.0'
|
||||||
mavenCentralLicencesURL = 'https://www.apache.org/licenses/LICENSE-2.0'
|
mavenCentralLicencesURL = 'https://www.apache.org/licenses/LICENSE-2.0'
|
||||||
mavenCentralConnection = 'scm:git:github.com/AriaLyy/Aria.git'
|
mavenCentralConnection = 'scm:git:github.com/AriaLyy/Aria.git'
|
||||||
mavenCentralDeveloperConnection = 'scm:git:ssh://github.com/AriaLyy/Aria.git'
|
mavenCentralDeveloperConnection = 'scm:git:ssh://github.com/AriaLyy/Aria.git'
|
||||||
mavenCentralTreeURL = 'https://github.com/AriaLyy/KeepassA/tree/master'
|
mavenCentralTreeURL = 'https://github.com/AriaLyy/KeepassA/tree/master'
|
||||||
|
|
||||||
compileSdkVersion = 28
|
compileSdkVersion = 28
|
||||||
supportLibVersion = "27.1.1"
|
supportLibVersion = "27.1.1"
|
||||||
buildToolsVersion = "29.0.2"
|
buildToolsVersion = "29.0.2"
|
||||||
targetSdkVersion = 28
|
targetSdkVersion = 28
|
||||||
lifecycleVersion = "1.1.1"
|
lifecycleVersion = "1.1.1"
|
||||||
minSdkVersion = 15
|
minSdkVersion = 15
|
||||||
|
|
||||||
// 以下是androidX
|
// 以下是androidX
|
||||||
XAppcompatVersion = "1.1.0"
|
XAppcompatVersion = "1.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,32 +2,32 @@ apply plugin: 'maven-publish'
|
|||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
PUBLISH_GROUP_ID = rootProject.ext.mavenCentralGroupId
|
PUBLISH_GROUP_ID = rootProject.ext.mavenCentralGroupId
|
||||||
PUBLISH_VERSION = rootProject.ext.mavenVersion
|
PUBLISH_VERSION = rootProject.ext.mavenVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//编译groovy代码时采用 UTF-8
|
//编译groovy代码时采用 UTF-8
|
||||||
tasks.withType(GroovyCompile) {
|
tasks.withType(GroovyCompile) {
|
||||||
groovyOptions.encoding = "UTF-8"
|
groovyOptions.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
//编译JAVA文件时采用UTF-8
|
//编译JAVA文件时采用UTF-8
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
|
|
||||||
// java doc 采用utf-8
|
// java doc 采用utf-8
|
||||||
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Javadoc.html#org.gradle.api.tasks.javadoc.Javadoc:options
|
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Javadoc.html#org.gradle.api.tasks.javadoc.Javadoc:options
|
||||||
tasks.withType(Javadoc) {
|
tasks.withType(Javadoc) {
|
||||||
if(JavaVersion.current().isJava9Compatible()) {
|
if (JavaVersion.current().isJava9Compatible()) {
|
||||||
options.addBooleanOption('html5', true)
|
options.addBooleanOption('html5', true)
|
||||||
}
|
}
|
||||||
options {
|
options {
|
||||||
encoding "UTF-8"
|
encoding "UTF-8"
|
||||||
charSet 'UTF-8'
|
charSet 'UTF-8'
|
||||||
links "http://docs.oracle.com/javase/7/docs/api"
|
links "http://docs.oracle.com/javase/7/docs/api"
|
||||||
addStringOption('Xdoclint:none', '-quiet') // 忽略检查@params 和 @return
|
addStringOption('Xdoclint:none', '-quiet') // 忽略检查@params 和 @return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext["signing.keyId"] = ''
|
ext["signing.keyId"] = ''
|
||||||
@@ -38,192 +38,192 @@ ext["ossrhPassword"] = ''
|
|||||||
|
|
||||||
File secretPropsFile = project.rootProject.file('local.properties')
|
File secretPropsFile = project.rootProject.file('local.properties')
|
||||||
if (secretPropsFile.exists()) {
|
if (secretPropsFile.exists()) {
|
||||||
println "Found secret props file, loading props"
|
println "Found secret props file, loading props"
|
||||||
Properties p = new Properties()
|
Properties p = new Properties()
|
||||||
p.load(new FileInputStream(secretPropsFile))
|
p.load(new FileInputStream(secretPropsFile))
|
||||||
p.each { name, value ->
|
p.each { name, value ->
|
||||||
ext[name] = value
|
ext[name] = value
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println "No props file, loading env vars"
|
println "No props file, loading env vars"
|
||||||
}
|
}
|
||||||
|
|
||||||
static def localMavenRepo() {
|
static def localMavenRepo() {
|
||||||
'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
|
'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
|
||||||
}
|
}
|
||||||
|
|
||||||
def getReleaseRepositoryUrl() {
|
def getReleaseRepositoryUrl() {
|
||||||
return isLocal() ? localMavenRepo()
|
return isLocal() ? localMavenRepo()
|
||||||
: hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
|
: hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
|
||||||
: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
|
: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
|
||||||
}
|
}
|
||||||
|
|
||||||
def getSnapshotRepositoryUrl() {
|
def getSnapshotRepositoryUrl() {
|
||||||
return isLocal() ? localMavenRepo()
|
return isLocal() ? localMavenRepo()
|
||||||
: hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
|
: hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
|
||||||
: 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
: 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
||||||
}
|
}
|
||||||
|
|
||||||
def isLocal(){
|
def isLocal() {
|
||||||
return ISLOCAL == 'true'
|
return ISLOCAL == 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate { project ->
|
afterEvaluate { project ->
|
||||||
if (isLocal()) {
|
if (isLocal()) {
|
||||||
println("上传到本地仓库")
|
println("上传到本地仓库")
|
||||||
} else {
|
} else {
|
||||||
println("上传到中央仓库")
|
println("上传到中央仓库")
|
||||||
}
|
|
||||||
publishing {
|
|
||||||
def isAndroidProject = project.plugins.hasPlugin('com.android.application') || project.
|
|
||||||
plugins.
|
|
||||||
hasPlugin('com.android.library')
|
|
||||||
publications {
|
|
||||||
release(MavenPublication) {
|
|
||||||
// groupId 等信息
|
|
||||||
groupId PUBLISH_GROUP_ID
|
|
||||||
artifactId PUBLISH_ARTIFACT_ID
|
|
||||||
version PUBLISH_VERSION
|
|
||||||
|
|
||||||
if (isAndroidProject) {
|
|
||||||
// 移除R文件,移除BuildConfig文件
|
|
||||||
generateReleaseBuildConfig.enabled = false
|
|
||||||
generateDebugBuildConfig.enabled = false
|
|
||||||
generateReleaseResValues.enabled = false
|
|
||||||
generateDebugResValues.enabled = false
|
|
||||||
// 使用了这个组件,就不需要自己aar、pom.withxml了
|
|
||||||
from components.release
|
|
||||||
|
|
||||||
def variants = project.android.libraryVariants.findAll {
|
|
||||||
it.buildType.name.equalsIgnoreCase('debug')
|
|
||||||
}
|
|
||||||
|
|
||||||
def getAndroidSdkDirectory = project.android.sdkDirectory
|
|
||||||
|
|
||||||
def getAndroidJar = "${getAndroidSdkDirectory}/platforms/${project.android.compileSdkVersion}/android.jar"
|
|
||||||
|
|
||||||
task androidJavadocs(type: Javadoc, dependsOn: assembleDebug) {
|
|
||||||
println("开始打包aar")
|
|
||||||
source = variants.collect { it.getJavaCompileProvider().get().source }
|
|
||||||
classpath = files(
|
|
||||||
getAndroidJar,
|
|
||||||
project.file("build/intermediates/classes/debug")
|
|
||||||
)
|
|
||||||
doFirst {
|
|
||||||
classpath += files(variants.collect { it.javaCompile.classpath.files })
|
|
||||||
}
|
|
||||||
options {
|
|
||||||
links("http://docs.oracle.com/javase/7/docs/api/")
|
|
||||||
linksOffline("http://d.android.com/reference",
|
|
||||||
"${getAndroidSdkDirectory}/docs/reference")
|
|
||||||
encoding "UTF-8"
|
|
||||||
charSet 'UTF-8'
|
|
||||||
addStringOption('Xdoclint:none', '-quiet') // 忽略检查@params 和 @return
|
|
||||||
}
|
|
||||||
|
|
||||||
exclude '**/R.java'
|
|
||||||
exclude "**/BuildConfig.class"
|
|
||||||
}
|
|
||||||
|
|
||||||
def cleanJavadocTask = task("cleanJavadocTask", type: Delete) {
|
|
||||||
delete androidJavadocs.destinationDir
|
|
||||||
} as Task
|
|
||||||
project.clean.dependsOn(cleanJavadocTask)
|
|
||||||
|
|
||||||
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
from androidJavadocs.destinationDir
|
|
||||||
baseName "${JAR_PREFIX}${project.name}"
|
|
||||||
}
|
|
||||||
|
|
||||||
task androidSourcesJar(type: Jar) {
|
|
||||||
classifier = 'sources'
|
|
||||||
from project.android.sourceSets.main.java.source
|
|
||||||
baseName "${JAR_PREFIX}${project.name}"
|
|
||||||
|
|
||||||
exclude "**/R.class"
|
|
||||||
exclude "**/BuildConfig.class"
|
|
||||||
}
|
|
||||||
|
|
||||||
task androidLibraryJar(type: Jar, dependsOn: compileDebugJavaWithJavac
|
|
||||||
/* == variant.javaCompile */) {
|
|
||||||
// java 编译后的 class文件, build/intermediates/classes/debug/
|
|
||||||
from compileDebugJavaWithJavac.destinationDir
|
|
||||||
// kotlin 编译后的 class文件
|
|
||||||
from 'build/tmp/kotlin-classes/debug/'
|
|
||||||
// 指定需要被打包成 jar 的文件夹
|
|
||||||
// include('libs/**')
|
|
||||||
exclude '**/R.class'
|
|
||||||
exclude '**/R$*.class'
|
|
||||||
exclude "**/BuildConfig.class"
|
|
||||||
baseName "${JAR_PREFIX}${project.name}-cache"
|
|
||||||
}
|
|
||||||
|
|
||||||
artifact androidLibraryJar
|
|
||||||
artifact androidSourcesJar
|
|
||||||
artifact androidJavadocsJar
|
|
||||||
|
|
||||||
} else if (project.plugins.hasPlugin('java')) {
|
|
||||||
from components.java
|
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
classifier = 'sources'
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocsJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
artifact sourcesJar
|
|
||||||
artifact javadocsJar
|
|
||||||
}
|
|
||||||
|
|
||||||
pom {
|
|
||||||
name = PUBLISH_ARTIFACT_ID
|
|
||||||
description = rootProject.ext.desc
|
|
||||||
url = rootProject.ext.website
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
//协议类型,一般默认Apache License2.0的话不用改:
|
|
||||||
name = rootProject.ext.mavenCentralLicences
|
|
||||||
url = rootProject.ext.mavenCentralLicencesURL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id = rootProject.ext.mavenCentralUserID
|
|
||||||
name = rootProject.ext.mavenCentralUserName
|
|
||||||
email = rootProject.ext.mavenCentralEmail
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scm {
|
|
||||||
//修改成你的Git地址:
|
|
||||||
connection = rootProject.ext.mavenCentralConnection
|
|
||||||
developerConnection = rootProject.ext.mavenCentralDeveloperConnection
|
|
||||||
//分支地址:
|
|
||||||
url = rootProject.ext.mavenCentralTreeURL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
repositories {
|
publishing {
|
||||||
maven {
|
def isAndroidProject = project.plugins.hasPlugin('com.android.application') || project.
|
||||||
name = "mavencentral"
|
plugins.
|
||||||
|
hasPlugin('com.android.library')
|
||||||
|
publications {
|
||||||
|
release(MavenPublication) {
|
||||||
|
// groupId 等信息
|
||||||
|
groupId PUBLISH_GROUP_ID
|
||||||
|
artifactId PUBLISH_ARTIFACT_ID
|
||||||
|
version PUBLISH_VERSION
|
||||||
|
|
||||||
def releasesRepoUrl = getReleaseRepositoryUrl()
|
if (isAndroidProject) {
|
||||||
def snapshotsRepoUrl = getSnapshotRepositoryUrl()
|
// 移除R文件,移除BuildConfig文件
|
||||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
generateReleaseBuildConfig.enabled = false
|
||||||
|
generateDebugBuildConfig.enabled = false
|
||||||
|
generateReleaseResValues.enabled = false
|
||||||
|
generateDebugResValues.enabled = false
|
||||||
|
// 使用了这个组件,就不需要自己aar、pom.withxml了
|
||||||
|
from components.release
|
||||||
|
|
||||||
credentials {
|
def variants = project.android.libraryVariants.findAll {
|
||||||
username ossrhUsername
|
it.buildType.name.equalsIgnoreCase('debug')
|
||||||
password ossrhPassword
|
}
|
||||||
|
|
||||||
|
def getAndroidSdkDirectory = project.android.sdkDirectory
|
||||||
|
|
||||||
|
def getAndroidJar = "${getAndroidSdkDirectory}/platforms/${project.android.compileSdkVersion}/android.jar"
|
||||||
|
|
||||||
|
task androidJavadocs(type: Javadoc, dependsOn: assembleDebug) {
|
||||||
|
println("开始打包aar")
|
||||||
|
source = variants.collect { it.getJavaCompileProvider().get().source }
|
||||||
|
classpath = files(
|
||||||
|
getAndroidJar,
|
||||||
|
project.file("build/intermediates/classes/debug")
|
||||||
|
)
|
||||||
|
doFirst {
|
||||||
|
classpath += files(variants.collect { it.javaCompile.classpath.files })
|
||||||
|
}
|
||||||
|
options {
|
||||||
|
links("http://docs.oracle.com/javase/7/docs/api/")
|
||||||
|
linksOffline("http://d.android.com/reference",
|
||||||
|
"${getAndroidSdkDirectory}/docs/reference")
|
||||||
|
encoding "UTF-8"
|
||||||
|
charSet 'UTF-8'
|
||||||
|
addStringOption('Xdoclint:none', '-quiet') // 忽略检查@params 和 @return
|
||||||
|
}
|
||||||
|
|
||||||
|
exclude '**/R.java'
|
||||||
|
exclude "**/BuildConfig.class"
|
||||||
|
}
|
||||||
|
|
||||||
|
def cleanJavadocTask = task("cleanJavadocTask", type: Delete) {
|
||||||
|
delete androidJavadocs.destinationDir
|
||||||
|
} as Task
|
||||||
|
project.clean.dependsOn(cleanJavadocTask)
|
||||||
|
|
||||||
|
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
|
||||||
|
classifier = 'javadoc'
|
||||||
|
from androidJavadocs.destinationDir
|
||||||
|
baseName "${JAR_PREFIX}${project.name}"
|
||||||
|
}
|
||||||
|
|
||||||
|
task androidSourcesJar(type: Jar) {
|
||||||
|
classifier = 'sources'
|
||||||
|
from project.android.sourceSets.main.java.source
|
||||||
|
baseName "${JAR_PREFIX}${project.name}"
|
||||||
|
|
||||||
|
exclude "**/R.class"
|
||||||
|
exclude "**/BuildConfig.class"
|
||||||
|
}
|
||||||
|
|
||||||
|
task androidLibraryJar(type: Jar, dependsOn: compileDebugJavaWithJavac
|
||||||
|
/* == variant.javaCompile */) {
|
||||||
|
// java 编译后的 class文件, build/intermediates/classes/debug/
|
||||||
|
from compileDebugJavaWithJavac.destinationDir
|
||||||
|
// kotlin 编译后的 class文件
|
||||||
|
from 'build/tmp/kotlin-classes/debug/'
|
||||||
|
// 指定需要被打包成 jar 的文件夹
|
||||||
|
// include('libs/**')
|
||||||
|
exclude '**/R.class'
|
||||||
|
exclude '**/R$*.class'
|
||||||
|
exclude "**/BuildConfig.class"
|
||||||
|
baseName "${JAR_PREFIX}${project.name}-cache"
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact androidLibraryJar
|
||||||
|
artifact androidSourcesJar
|
||||||
|
artifact androidJavadocsJar
|
||||||
|
|
||||||
|
} else if (project.plugins.hasPlugin('java')) {
|
||||||
|
from components.java
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
|
classifier = 'sources'
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
}
|
||||||
|
|
||||||
|
task javadocsJar(type: Jar, dependsOn: javadoc) {
|
||||||
|
classifier = 'javadoc'
|
||||||
|
from javadoc.destinationDir
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact sourcesJar
|
||||||
|
artifact javadocsJar
|
||||||
|
}
|
||||||
|
|
||||||
|
pom {
|
||||||
|
name = PUBLISH_ARTIFACT_ID
|
||||||
|
description = rootProject.ext.desc
|
||||||
|
url = rootProject.ext.website
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
//协议类型,一般默认Apache License2.0的话不用改:
|
||||||
|
name = rootProject.ext.mavenCentralLicences
|
||||||
|
url = rootProject.ext.mavenCentralLicencesURL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id = rootProject.ext.mavenCentralUserID
|
||||||
|
name = rootProject.ext.mavenCentralUserName
|
||||||
|
email = rootProject.ext.mavenCentralEmail
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
//修改成你的Git地址:
|
||||||
|
connection = rootProject.ext.mavenCentralConnection
|
||||||
|
developerConnection = rootProject.ext.mavenCentralDeveloperConnection
|
||||||
|
//分支地址:
|
||||||
|
url = rootProject.ext.mavenCentralTreeURL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "mavencentral"
|
||||||
|
|
||||||
|
def releasesRepoUrl = getReleaseRepositoryUrl()
|
||||||
|
def snapshotsRepoUrl = getSnapshotRepositoryUrl()
|
||||||
|
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||||
|
|
||||||
|
credentials {
|
||||||
|
username ossrhUsername
|
||||||
|
password ossrhPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
signing {
|
||||||
signing {
|
sign publishing.publications
|
||||||
sign publishing.publications
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -3,6 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
#distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-all.zip
|
||||||
#distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
|
||||||
|
|||||||
Reference in New Issue
Block a user