zoukankan      html  css  js  c++  java
  • mac nexus搭建本地maven服务器

    1.在保证安装jdk 1.7+,去nexus官网下载nexus(http://www.sonatype.com/download-oss-sonatype) 最新版本

    2.解压zip文件,配置nexus下bin目录全局变量 打开.bash_profile添加如下 

    export PATH=${PATH}:/Users/mac/Documents/software/nexus-3.6.0-02-mac/nexus-3.6.0-02/bin

    3.进入到bin目录后./nexus start启动nexus, 浏览器打开http://localhost:8081/nexus/ 如果能成功访问。则说明安装成功了,界面如下:

    我们在设置里面可以新建仓库

    填写仓库名称等一些信息

    接下来 我们安装maven 下载地址 http://maven.apache.org/download.cgi

    同样配置maven bin目录全局变量

    export PATH=${PATH}:/Users/mac/Documents/software/apache-maven-3.5.2/bin

    打开maven下面的conf文件夹后 打开settings.xml添加如下代码

    <server>

           <id>仓库id</id>

              <username>admin</username>

              <password>admin123</password>

    </server>

     

    <mirror>

            <id>nexus</id>

            <mirrorOf>仓库id</mirrorOf>

            <name>Nexus Mirror</name>

            <url>仓库url地址</url>

    </mirror>

     

    4.发布带有pom的jar包

    命令如下:

    mvn deploy:deploy-file -DpomFile=<path-to-pom>
    -Dfile=<path-to-file>
    -DrepositoryId=<id-to-map-on-server-section-of-settings.xml>
    -Durl=<url-of-the-repository-to-deploy>
     
    5.发布不带pom文件的独立jar包:
    命令如下:
    mvn deploy:deploy-file -DgroupId=<group-id>
    -DartifactId=<artifact-id>
    -Dversion=<version>
    -Dpackaging=<type-of-packaging>
    -Dfile=<path-to-file>
    -DrepositoryId=<id-to-map-on-server-section-of-settings.xml>
    -Durl=<url-of-the-repository-to-deploy>
     
    6.上传android studio library

    build.gradle中添加代码:

    apply from: './nexus-push.gradle'

    在同级目录下创建一个nexus-push.gradle文件,代码如下:

    apply plugin: 'maven'

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


    artifacts {
        archives androidSourcesJar
    }
    uploadArchives {
        repositories {
            mavenDeployer {

                repository(url: "http://127.0.0.1:9999/nexus-zip/repository/maven-releases/") {
                    authentication(userName: "admin", password: "123456")      //账号,密码
                }
                pom.project {

          //groupId:唯一标识符
          //artifactId:类似于项目名称
          //version:版本号
                    version '1.0.3'
                    artifactId 'xxxxid'
                    groupId 'cn.xxx.android'
                    packaging 'aar'
                    description 'dependences lib'

                }
            }
        }
    }

    Terminal命令上传

    gradlew uploadArchives

    表示上传成功,可以在最初建立的仓库下看到你上传的文件了。如果有问题,请留言,我们一起讨论。

  • 相关阅读:
    素数路径Prime Path POJ3126 素数,BFS
    Fliptile POJ3279 DFS
    Find the Multiple POJ1426
    洗牌Shuffle'm Up POJ3087 模拟
    棋盘问题 POJ1321 DFS
    抓住那只牛!Catch That Cow POJ3278 BFS
    Dungeon Master POJ2251 三维BFS
    Splitting into digits CodeForce#1104A
    Ubuntu下手动安装Nvidia显卡驱动
    最大连续子序列和
  • 原文地址:https://www.cnblogs.com/limingblogs/p/7797802.html
Copyright © 2011-2022 走看看