Commit ce7fe133 authored by shiyl's avatar shiyl

使用maven-publish插件进行aar发布

parent 42cfb7a6
......@@ -8,6 +8,9 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
rootProject.ext.artifact_id = 'managerCenter'
apply from:'../../publish.gradle'
android {
compileSdkVersion build_versions.compileSdkVersion
......
......@@ -8,6 +8,9 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
rootProject.ext.artifact_id = 'order'
apply from:'../../publish.gradle'
android {
compileSdkVersion build_versions.compileSdkVersion
......
......@@ -29,6 +29,15 @@ allprojects {
addRepos(repositories)
}
/**
* 发布版本信息
*/
ext {
group_id = 'com.yidian.business'
artifact_id = ''
version_name = '0.0.1-SNAPSHOT'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
\ No newline at end of file
apply plugin: 'maven-publish'
/**
* 从 local.properties 中提取 Maven 仓库账号信息
*/
def localProperties = new Properties()
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
def mavenUserName = localProperties.getProperty("MavenUsername")
def mavenPassword = localProperties.getProperty("MavenPassword")
/**
* 上传的仓库地址
*/
def release_repository_url = "http://dailybuild2.yidian-inc.com:8088/repository/maven-releases/"
def snapshot_repository_url = "http://dailybuild2.yidian-inc.com:8088/repository/maven-snapshots/"
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
afterEvaluate {
publishing {
publications {
Production(MavenPublication) {
from components.release
groupId rootProject.ext.group_id
artifactId rootProject.ext.artifact_id
version rootProject.ext.version_name
// 上传source,这样使用放可以看到方法注释
artifact generateSourcesJar
}
}
repositories {
// 定义 maven远程 仓库
maven {
// 可以有且仅有一个仓库不指定 name 属性,会隐式设置为 Maven
name = version_name.endsWith('SNAPSHOT') ? "pbSnapshots" : "pbReleases"
// 根据 versionName 来判断仓库地址
url = version_name.endsWith('SNAPSHOT') ? snapshot_repository_url : release_repository_url
// 仓库用户名密码
credentials {
username = mavenUserName
password = mavenPassword
}
}
// 定义 mavenLocal 仓库
mavenLocal {
name = "pbMavenLocal"
url = uri('../../repo')
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment