Nexus安裝和項(xiàng)目接入

之前下載的安裝包,現(xiàn)在直接拿來用.
下載地址:https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.18.1-01-win64.zip

1.安裝Nexus并創(chuàng)建倉庫

1.解壓即完成安裝, 我安裝到了本地D:\soft\nexus-3.18.1-01-win64目錄中.
2.打開D:\soft\nexus-3.18.1-01-win64\nexus-3.18.1-01\bin\nexus.exe.
3.打開瀏覽器,輸入http://127.0.0.1:8081, 如下圖:


image.png

4.點(diǎn)擊右上角的Sign in,第一次登錄會(huì)讓你輸入用戶名admin,秘密在它提示的一個(gè)admin.password文件中,按照它給的路徑即可找到.然后會(huì)提示你重新設(shè)置密碼,以后就用你設(shè)置的這個(gè)密碼登錄即可.
5.創(chuàng)建倉庫.


image.png

image.png

image.png

點(diǎn)擊Create repository即可創(chuàng)建一個(gè)名為ProjectA-release的發(fā)布版本的倉庫, 如果想創(chuàng)建快照版本的倉庫, 在第6步,選擇Snapshot即可.
image.png
image.png

我這里創(chuàng)建完兩個(gè)倉庫后,開始在androidStudio中做配置

2.在工程目錄下的build.gradle文件中配置

分別在buildscript - repositories節(jié)點(diǎn)下,和allprojects - repositories配置maven

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()  //這個(gè)也是我們經(jīng)常用到的一個(gè)倉庫
        //開始配置我們自己的私服倉庫,分別是release和snapshot
        //這只是為gradle的構(gòu)建添加的倉庫,還需要為java工程添加倉庫
        maven {
            url 'http://127.0.0.1:8081/repository/componentization-releases/'
            credentials {
                username 'admin'
                password 'qwer1234'
            }
        }
        maven {
            url 'http://127.0.0.1:8081/repository/componentization-snapshots/'
            credentials {
                username 'admin'
                password 'qwer1234'
            }
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url 'http://127.0.0.1:8081/repository/componentization-releases/'
            credentials {
                username 'admin'
                password 'qwer1234'
            }
        }
        maven {
            url 'http://127.0.0.1:8081/repository/componentization-snapshots/'
            credentials {
                username 'admin'
                password 'qwer1234'
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在工程目錄的gradle.properties文件中做配置幾個(gè)上傳需要的變量

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
# 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
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# 配置上傳路徑
NEXUS_REPOSITORY_URL=http://127.0.0.1:8081/repository/componentization-snapshots/
# 公司域名倒置+項(xiàng)目類型. eg:com.alibaba.android
POM_GROUPID=com.app.android
# 庫類型,打包類型,java:jar Android:aar
POM_PACKAGING=aar
# 用戶名
NEXUS_USERNAME=admin
# 密碼
NEXUS_PASSWORD=qwer1234

在創(chuàng)建的lib module中的build.gradle文件中配置上傳參數(shù)

比如,新建的network庫,

apply plugin: 'com.android.library'
apply plugin: 'maven'       //1.引入maven插件
//2.定義幾個(gè)變量
def pomName = this.getName()
def pomVersion = '1.0.0-SNAPSHOT'
def pomDescription = 'this network library for all projects'

android {
    compileSdkVersion 29

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}

//編寫上傳所需的配置參數(shù)
uploadArchives {
    repositories {      //倉庫信息
        mavenDeployer { //maven部署參數(shù)
            //NEXUS_REPOSITORY_URL,NEXUS_USERNAME,NEXUS_PASSWORD已經(jīng)在項(xiàng)目目錄的gradle.properties中定義
            repository(url: NEXUS_REPOSITORY_URL) { //倉庫, url
                //用戶名和密碼
                authentication (userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
            }
            pom.project {
                name pomName
                version pomVersion
                description pomDescription
                artifactId pomVersion
                groupId POM_GROUPID
                packaging POM_PACKAGING
            }
        }
    }
}

同步下項(xiàng)目后,在gradle欄目里可以點(diǎn)擊上傳network庫


image.png

未完待續(xù)...

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末掩蛤,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子掂名,更是在濱河造成了極大的恐慌忍法,老刑警劉巖缎讼,帶你破解...
    沈念sama閱讀 211,265評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡宦芦,警方通過查閱死者的電腦和手機(jī)嘹履,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,078評(píng)論 2 385
  • 文/潘曉璐 我一進(jìn)店門腻扇,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人砾嫉,你說我怎么就攤上這事幼苛。” “怎么了焕刮?”我有些...
    開封第一講書人閱讀 156,852評(píng)論 0 347
  • 文/不壞的土叔 我叫張陵舶沿,是天一觀的道長。 經(jīng)常有香客問我配并,道長括荡,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,408評(píng)論 1 283
  • 正文 為了忘掉前任溉旋,我火速辦了婚禮畸冲,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己邑闲,他們只是感情好岩喷,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,445評(píng)論 5 384
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著监憎,像睡著了一般纱意。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上鲸阔,一...
    開封第一講書人閱讀 49,772評(píng)論 1 290
  • 那天偷霉,我揣著相機(jī)與錄音,去河邊找鬼褐筛。 笑死类少,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的渔扎。 我是一名探鬼主播硫狞,決...
    沈念sama閱讀 38,921評(píng)論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢(mèng)啊……” “哼晃痴!你這毒婦竟也來了残吩?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,688評(píng)論 0 266
  • 序言:老撾萬榮一對(duì)情侶失蹤倘核,失蹤者是張志新(化名)和其女友劉穎泣侮,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體紧唱,經(jīng)...
    沈念sama閱讀 44,130評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡活尊,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,467評(píng)論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了漏益。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片蛹锰。...
    茶點(diǎn)故事閱讀 38,617評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖绰疤,靈堂內(nèi)的尸體忽然破棺而出铜犬,到底是詐尸還是另有隱情,我是刑警寧澤峦睡,帶...
    沈念sama閱讀 34,276評(píng)論 4 329
  • 正文 年R本政府宣布翎苫,位于F島的核電站,受9級(jí)特大地震影響榨了,放射性物質(zhì)發(fā)生泄漏煎谍。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,882評(píng)論 3 312
  • 文/蒙蒙 一龙屉、第九天 我趴在偏房一處隱蔽的房頂上張望呐粘。 院中可真熱鬧满俗,春花似錦、人聲如沸作岖。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,740評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽痘儡。三九已至辕万,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間沉删,已是汗流浹背渐尿。 一陣腳步聲響...
    開封第一講書人閱讀 31,967評(píng)論 1 265
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留矾瑰,地道東北人砖茸。 一個(gè)月前我還...
    沈念sama閱讀 46,315評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長得像殴穴,于是被迫代替她去往敵國和親凉夯。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,486評(píng)論 2 348