亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

mac上搭建nexus環境給安卓搭建moven環境

標簽:
Android

打开网站https://www.sonatype.com/download-oss-sonatype下载mac版nexus

https://img1.sycdn.imooc.com//5cde5c4b000193ee11860408.jpg


我们通过termial进入nexus-3.16-02,然后进入bin目录,执行

https://img1.sycdn.imooc.com//5cde5c7300018d2511260382.jpg

然后就可以打开http://192.168.118.45:8081/,用户名和密码是admin/admin123

https://img1.sycdn.imooc.com//5cde5cac0001fdfd25921246.jpg


如何上传一个aar到nexus里呢,在项目中建立一个library包,在build.gradle中加入

apply from: 'mvn.gradle'

https://img1.sycdn.imooc.com//5cde5d17000116f024781212.jpg

然后增加mvn.gradle文件,内容是:

apply plugin: 'maven'

uploadArchives {
    configuration = configurations.archives

    repositories {
        mavenDeployer {
            if (MVN_RELEASE == 'product') {
                repository(url: uri(MVN_RL_URL)) {
                    authentication(userName: MVN_NAME, password: MVN_PASS)
                }
                pom.project {
                    version MVN_VERSION
                    artifactId MVN_ARTIFACT_ID
                    groupId MVN_GROUP_ID
                    packaging MVN_PACKAGING
                }
            } else if (MVN_RELEASE == 'snapshot') {
                repository(url: uri(MVN_SN_URL)) {
                    authentication(userName: MVN_NAME, password: MVN_PASS)
                }
                pom.project {
                    version MVN_VERSION + "-SNAPSHOT"
                    artifactId MVN_ARTIFACT_ID
                    groupId MVN_GROUP_ID
                    packaging MVN_PACKAGING
                }
            } else if (MVN_RELEASE == 'local') {
                repository(url: uri("build/aar"))
                pom.project {
                    version MVN_VERSION
                    artifactId MVN_ARTIFACT_ID
                    groupId MVN_GROUP_ID
                    packaging MVN_PACKAGING
                }
            } else {
                project.println("do nothing for task uploadArchives")
            }
        }
    }
}

task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.sourceFiles
}

artifacts {
    archives androidSourcesJar
}

然后在主工程的gradle.properties里加入:

org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
MVN_ARTIFACT_ID=basemodule
MVN_GROUP_ID=com.imooc.basemodule
MVN_RL_URL=http://192.168.118.45:8081/repository/maven-releases/
MVN_SN_URL=http://192.168.118.45:8081/repository/maven-snapshots/


MVN_NAME=admin
MVN_PASS=admin123

MVN_PACKAGING=aar

MVN_RELEASE=snapshot
MVN_VERSION=1.4.8.7

然后点击

https://img1.sycdn.imooc.com//5cde5d640001dc8923161236.jpg

就会生成jar包:

https://img1.sycdn.imooc.com//5cde5d7900016cff21601160.jpg

如何在项目中进行使用呢:

在主工程的moven中加入:

https://img1.sycdn.imooc.com//5cde5d9b00011c3217221272.jpg

然后compile的时候使用

compile 'com.nick.module:emotion:1.4.8.6-SNAPSHOT'

就行了

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消