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'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.arialyy.simple"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
multiDexEnabled true
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
defaultConfig {
|
||||
applicationId "com.arialyy.simple"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
multiDexEnabled true
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("lyy.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "key0"
|
||||
keyPassword "123456"
|
||||
v2SigningEnabled false
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
minifyEnabled false //混淆
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("lyy.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "key0"
|
||||
keyPassword "123456"
|
||||
v2SigningEnabled false
|
||||
}
|
||||
}
|
||||
release {
|
||||
zipAlignEnabled true
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
minifyEnabled false //混淆
|
||||
}
|
||||
release {
|
||||
zipAlignEnabled true
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
||||
merge 'META-INF/services/com.arialyy.aria.core.inf.IUtil'
|
||||
}
|
||||
packagingOptions {
|
||||
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
||||
merge 'META-INF/services/com.arialyy.aria.core.inf.IUtil'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
|
||||
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}"
|
||||
api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
|
||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||
implementation 'com.pddstudio:highlightjs-android:1.5.0'
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation project(':AppFrame')
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlin_version}"
|
||||
api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
|
||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||
implementation 'com.pddstudio:highlightjs-android:1.5.0'
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation project(':AppFrame')
|
||||
|
||||
// aria
|
||||
kapt project(':AriaCompiler')
|
||||
implementation project(':Aria')
|
||||
implementation project(':M3U8Component')
|
||||
implementation project(':FtpComponent')
|
||||
implementation project(path: ':AriaAnnotations')
|
||||
implementation project(path: ':SFtpComponent')
|
||||
// aria
|
||||
kapt project(':AriaCompiler')
|
||||
implementation project(':Aria')
|
||||
implementation project(':M3U8Component')
|
||||
implementation project(':FtpComponent')
|
||||
implementation project(path: ':AriaAnnotations')
|
||||
implementation project(path: ':SFtpComponent')
|
||||
|
||||
|
||||
// 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:m3u8Component:3.8.12' // 如果需要使用m3u8下载功能,请增加该组件
|
||||
|
||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
||||
}
|
||||
|
||||
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.
|
||||
buildscript {
|
||||
// ext.kotlin_version = '1.3.20'
|
||||
ext.kotlin_version = '1.4.30'
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||
// classpath 'com.novoda:bintray-release:0.9.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
|
||||
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.30" // kotlin 文档引擎
|
||||
// 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
|
||||
}
|
||||
ext.kotlin_version = '2.4.0'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
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' }
|
||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
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 {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options {
|
||||
encoding "UTF-8"
|
||||
charSet 'UTF-8'
|
||||
links "http://docs.oracle.com/javase/7/docs/api"
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
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' }
|
||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options {
|
||||
encoding "UTF-8"
|
||||
charSet 'UTF-8'
|
||||
links "http://docs.oracle.com/javase/7/docs/api"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
ext {
|
||||
versionCode = 390
|
||||
versionName = '3.8.16-beta-1'
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = versionName
|
||||
versionCode = 390
|
||||
versionName = '3.8.16-beta-1'
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = versionName
|
||||
// publishVersion = '1.0.4' //FTP插件
|
||||
repoName='maven'
|
||||
repoName = 'maven'
|
||||
// repoName='aria'
|
||||
|
||||
desc = 'android 下载框架'
|
||||
website = 'https://github.com/AriaLyy/Aria'
|
||||
licences = ['Apache-2.0']
|
||||
desc = 'android 下载框架'
|
||||
website = 'https://github.com/AriaLyy/Aria'
|
||||
licences = ['Apache-2.0']
|
||||
|
||||
// mavenCentral
|
||||
mavenVersion = '3.8.16'
|
||||
mavenCentralGroupId = 'me.laoyuyu.aria'
|
||||
mavenCentralUserID = 'laoyuyu'
|
||||
mavenCentralUserName = 'laoyuyu'
|
||||
mavenCentralEmail = '511455842@qq.com'
|
||||
mavenCentralLicences = 'Apache-2.0'
|
||||
mavenCentralLicencesURL = 'https://www.apache.org/licenses/LICENSE-2.0'
|
||||
mavenCentralConnection = 'scm:git:github.com/AriaLyy/Aria.git'
|
||||
mavenCentralDeveloperConnection = 'scm:git:ssh://github.com/AriaLyy/Aria.git'
|
||||
mavenCentralTreeURL = 'https://github.com/AriaLyy/KeepassA/tree/master'
|
||||
// mavenCentral
|
||||
mavenVersion = '3.8.16'
|
||||
mavenCentralGroupId = 'me.laoyuyu.aria'
|
||||
mavenCentralUserID = 'laoyuyu'
|
||||
mavenCentralUserName = 'laoyuyu'
|
||||
mavenCentralEmail = '511455842@qq.com'
|
||||
mavenCentralLicences = 'Apache-2.0'
|
||||
mavenCentralLicencesURL = 'https://www.apache.org/licenses/LICENSE-2.0'
|
||||
mavenCentralConnection = 'scm:git:github.com/AriaLyy/Aria.git'
|
||||
mavenCentralDeveloperConnection = 'scm:git:ssh://github.com/AriaLyy/Aria.git'
|
||||
mavenCentralTreeURL = 'https://github.com/AriaLyy/KeepassA/tree/master'
|
||||
|
||||
compileSdkVersion = 28
|
||||
supportLibVersion = "27.1.1"
|
||||
buildToolsVersion = "29.0.2"
|
||||
targetSdkVersion = 28
|
||||
lifecycleVersion = "1.1.1"
|
||||
minSdkVersion = 15
|
||||
compileSdkVersion = 28
|
||||
supportLibVersion = "27.1.1"
|
||||
buildToolsVersion = "29.0.2"
|
||||
targetSdkVersion = 28
|
||||
lifecycleVersion = "1.1.1"
|
||||
minSdkVersion = 15
|
||||
|
||||
// 以下是androidX
|
||||
XAppcompatVersion = "1.1.0"
|
||||
// 以下是androidX
|
||||
XAppcompatVersion = "1.1.0"
|
||||
}
|
||||
|
||||
@@ -2,32 +2,32 @@ apply plugin: 'maven-publish'
|
||||
apply plugin: 'signing'
|
||||
|
||||
ext {
|
||||
PUBLISH_GROUP_ID = rootProject.ext.mavenCentralGroupId
|
||||
PUBLISH_VERSION = rootProject.ext.mavenVersion
|
||||
PUBLISH_GROUP_ID = rootProject.ext.mavenCentralGroupId
|
||||
PUBLISH_VERSION = rootProject.ext.mavenVersion
|
||||
}
|
||||
|
||||
|
||||
//编译groovy代码时采用 UTF-8
|
||||
tasks.withType(GroovyCompile) {
|
||||
groovyOptions.encoding = "UTF-8"
|
||||
groovyOptions.encoding = "UTF-8"
|
||||
}
|
||||
//编译JAVA文件时采用UTF-8
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
options.encoding = "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
|
||||
tasks.withType(Javadoc) {
|
||||
if(JavaVersion.current().isJava9Compatible()) {
|
||||
options.addBooleanOption('html5', true)
|
||||
}
|
||||
options {
|
||||
encoding "UTF-8"
|
||||
charSet 'UTF-8'
|
||||
links "http://docs.oracle.com/javase/7/docs/api"
|
||||
addStringOption('Xdoclint:none', '-quiet') // 忽略检查@params 和 @return
|
||||
}
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
options.addBooleanOption('html5', true)
|
||||
}
|
||||
options {
|
||||
encoding "UTF-8"
|
||||
charSet 'UTF-8'
|
||||
links "http://docs.oracle.com/javase/7/docs/api"
|
||||
addStringOption('Xdoclint:none', '-quiet') // 忽略检查@params 和 @return
|
||||
}
|
||||
}
|
||||
|
||||
ext["signing.keyId"] = ''
|
||||
@@ -38,192 +38,192 @@ ext["ossrhPassword"] = ''
|
||||
|
||||
File secretPropsFile = project.rootProject.file('local.properties')
|
||||
if (secretPropsFile.exists()) {
|
||||
println "Found secret props file, loading props"
|
||||
Properties p = new Properties()
|
||||
p.load(new FileInputStream(secretPropsFile))
|
||||
p.each { name, value ->
|
||||
ext[name] = value
|
||||
}
|
||||
println "Found secret props file, loading props"
|
||||
Properties p = new Properties()
|
||||
p.load(new FileInputStream(secretPropsFile))
|
||||
p.each { name, value ->
|
||||
ext[name] = value
|
||||
}
|
||||
} else {
|
||||
println "No props file, loading env vars"
|
||||
println "No props file, loading env vars"
|
||||
}
|
||||
|
||||
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() {
|
||||
return isLocal() ? localMavenRepo()
|
||||
: hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
|
||||
: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
|
||||
return isLocal() ? localMavenRepo()
|
||||
: hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
|
||||
: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
|
||||
}
|
||||
|
||||
def getSnapshotRepositoryUrl() {
|
||||
return isLocal() ? localMavenRepo()
|
||||
: hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
|
||||
: 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
||||
return isLocal() ? localMavenRepo()
|
||||
: hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
|
||||
: 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
|
||||
def isLocal(){
|
||||
return ISLOCAL == 'true'
|
||||
def isLocal() {
|
||||
return ISLOCAL == 'true'
|
||||
}
|
||||
|
||||
afterEvaluate { project ->
|
||||
if (isLocal()) {
|
||||
println("上传到本地仓库")
|
||||
} else {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isLocal()) {
|
||||
println("上传到本地仓库")
|
||||
} else {
|
||||
println("上传到中央仓库")
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "mavencentral"
|
||||
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
|
||||
|
||||
def releasesRepoUrl = getReleaseRepositoryUrl()
|
||||
def snapshotsRepoUrl = getSnapshotRepositoryUrl()
|
||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||
if (isAndroidProject) {
|
||||
// 移除R文件,移除BuildConfig文件
|
||||
generateReleaseBuildConfig.enabled = false
|
||||
generateDebugBuildConfig.enabled = false
|
||||
generateReleaseResValues.enabled = false
|
||||
generateDebugResValues.enabled = false
|
||||
// 使用了这个组件,就不需要自己aar、pom.withxml了
|
||||
from components.release
|
||||
|
||||
credentials {
|
||||
username ossrhUsername
|
||||
password ossrhPassword
|
||||
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 {
|
||||
maven {
|
||||
name = "mavencentral"
|
||||
|
||||
def releasesRepoUrl = getReleaseRepositoryUrl()
|
||||
def snapshotsRepoUrl = getSnapshotRepositoryUrl()
|
||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||
|
||||
credentials {
|
||||
username ossrhUsername
|
||||
password ossrhPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
signing {
|
||||
sign publishing.publications
|
||||
}
|
||||
signing {
|
||||
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
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
#distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-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
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-all.zip
|
||||
|
||||
Reference in New Issue
Block a user