三、零基础搭建本地maven——配置(Android Studio)

配置Gradle

1.新建library

打开Android Studio,选择File,点击new Module,创建Android Library,或者使用已有的Library。

2.配置gradle

打开module的build.gradle,加入如下代码:

apply plugin: 'maven'

...

uploadArchives {    
  repositories.mavenDeployer {        
  name = 'mavenCentralReleaseDeployer'        
    repository(url: http://host:port/repository/release/) {            
      authentication(userName: admin, password: admin123)  
    }        
     snapshotRepository(url: http://host:port/repository/snapshot/) {           
      authentication(userName: admin, password: admin123)  
    }        
    pom.groupId = 'com.example.lib'
    pom.artifactId = 'libdemo'
    pom.version = '0.0.1'                              
    pom.name = 'demo'        
    pom.packaging = 'aar'    
  }
}

其中url就是我们仓库的地址,下面几个pom.xxx,称为maven坐标,他们的配置形如:

groupId:artifactId:packaging:version

3.上传library到maven

配置好上面的内容后,就可以在当前工程的终端下,键入如下命令:

gradle -p [your module name] clean build uploadArchives --info

ps.提示没有gradle命令的,记得把gradle加入环境变量哦

GRADLE_HOME:gradle根目录
path:%GRADLE_HOME%\bin

然后运行gradle -version,看到版本号就OK了

在nexus的控制台中,如果能看到library和对应的版本,说明上传成功,可以进行依赖了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 172,975评论 25 708
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,489评论 2 45
  • 在读李娟的散文集《走夜路时请放声歌唱》,其中有一篇是《妈妈说》,其中写了几段和妈妈的有意思的对话。想起我妈妈和我的...
    南北2018阅读 353评论 0 0
  • 文/何以今昔昨 近日,有幸拜读了杨绛先生写的《我们仨》,读后,伤感越发地浓重,心情久久不能平静。 书中用了平实的文...
    何以今昔昨阅读 561评论 0 6
  • 我失败过,沮丧过。 但从未放弃过,因为我坚信 I'm the best.
    因为艾所以爱阅读 157评论 1 0