结合上次创建一个Android基本封装库项目:https://blog.csdn.net/xxkalychen/article/details/95479191

一、在需要发布的模块chrisbaselibrary下的build.gradle中添加以下部分

//maven插件apply plugin: 'maven'//打包main目录下代码和资源的 tasktask androidSourcesJar(type: Jar) {    classifier = 'sources'    from android.sourceSets.main.java.srcDirs}//配置需要上传到maven仓库的文件artifacts {    archives androidSourcesJar}//上传到Maven仓库的taskuploadArchives {    repositories {        mavenDeployer {            //指定maven仓库url 如果使用快照库需要注意版本号的后缀            repository(url: "http://maven.chris.com/nexus/content/repositories/releases/") {                //nexus登录默认用户名和密码 userName大小写要匹配                authentication(userName: "admin", password: "admin123")            }            pom.groupId = 'com.chris'            pom.artifactId = 'base-library'            pom.version = '1.0.0'        }    }}

直接添加到最后即可。

使用gradle的插件uploadArchives实现部署。

部署成功后,我们可以修改app模块的依赖方式。不过建议另外建一个项目进行依赖测试,毕竟这个项目中的app模块是用来做实时测试的,不需要先部署再同步。

修改project的build.gradle文件中的仓库设置:

allprojects {    repositories {        maven {            url 'http://maven.chris.com/nexus/content/repositories/releases'        }        google()        jcenter()            }}

然后再在module下的build.gradle中添加依赖:

dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])    implementation 'com.android.support:appcompat-v7:28.0.0'    implementation 'com.android.support.constraint:constraint-layout:1.1.3'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'com.android.support.test:runner:1.0.2'    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'    //implementation project(path: ':chrisbaselibrary')    implementation 'com.chris:base-library:1.0.0'}

测试可以使用,与原来并无二致。

 

更多相关文章

  1. Android(安卓)解决Could not find com.android.tools.build:grad
  2. Android(安卓)Logo消息角标数字提醒
  3. android模块
  4. Android(安卓)VTS学习
  5. Android(安卓)解决Could not find com.android.tools.build:grad
  6. Android(安卓)多渠道打包进阶版
  7. 自定义android模块不编译的问题
  8. 通用android studio gradle 文件(电商商家版,两个gradle不同)
  9. 理解 Android(安卓)Build 系统

随机推荐

  1. PHP基础: 命名空间的引入方式和自动加载
  2. 类名的引入及自动加载类和常用mysql语句
  3. 类的重载与命名空间
  4. flex元素常用属性
  5. CISSP学习:第9章安全漏洞、威胁和对策
  6. Linux路线
  7. 【死磕JVM】JVM快速入门之前戏篇
  8. Sql Server之旅——第十二站 对锁的初步
  9. Sql Server之旅——第十三站 深入的探讨
  10. 一个static和面试官扯了一个小时,舌战加强