搭建本地maven仓库实战

搭建本地maven仓库实战

1 搭建本地maven

1.1 下载nexus(http://www.sonatype.org/nexus/archived/)

1.2 解压放到之后放到/Library/nexus-2.14.2-01

1.3 配置修改

在Nexus的安装目录找到/bin/nexus,修改NEXUS_HOMERUN_AS_USER两个参数如下。

NEXUS_HOME="/Library/nexus-2.14.2-01"

# If specified, the Wrapper will be run as the specified user.

# IMPORTANT - Make sure that the user has the required privileges to write into the Nexus installation directory.

# NOTE - This will set the user which is used to run the Wrapper as well as
#  the JVM and is not useful in situations where a privileged resource or
#  port needs to be allocated prior to the user being changed.
RUN_AS_USER=root

# Application
APP_NAME="nexus"
APP_LONG_NAME="Nexus OSS"

2 启动服务

2.1 sudo su (输入密码以后即可切换到root用户)

2.2 /Library/nexus-2.14.2-01/bin/nexus start

2.3 使用浏览器,打开http://localhost:8081/nexus/

3 上传构件到Maven仓库

apply plugin: 'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "http://localhost:8081/nexus/content/repositories/android/") {
                authentication(userName: "admin", password: "admin123")
            }
            pom.version = "1.0"
            pom.artifactId = "deskcore"
            pom.groupId = "com.le"
        }
    }
}

4 使用构件

在项目的根目录gradle.build文件,添加本地的meaven仓库

buildscript {
    repositories {
        jcenter()
        maven {
            credentials {
                username 'admin'
                password 'admin123'
            }
            url 'http://localhost:8081/nexus/content/repositories/android/'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

在具体的module的gradle.build文件,添加对应的依赖

dependencies {
    compile 'com.le:ucenter-core:1.0'
}

参考文献

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值