nexus + ivy 搭建lib仓库

1、nexus安装与启动

Nexus官方下载地址:http://www.sonatype.org/nexus/go,目前最新的版本是2.7.2。

Nexu安装非常容易,因为它内嵌了Jetty,只要有JRE救能直接运行。解压Nexu包会得到两个目录nexus-2.7.2-03和sonatype-work,sonatype-work是默认仓库目录。运行、安装都是使用nexus-2.7.2-03/bin/nexus.bat文件,它的使用方式:

        Usage:nexus.bat { console : start : stop : restart : install : uninstall }

其中console是控制台方式运行,install是以windows service寄存,uninstall是下载windows service,start是运行windows service,stop是停止windows service,restart是重启windows service,。

Nexus默认端口是8081,可以在nexus-2.7.1-01/conf/nexus.properties中修改,启动后就可以通过地址:http://localhost/:8081/nexus 来访问了。

2、ant语法

http://www.cnblogs.com/wufengxyz/archive/2011/11/24/2261797.html

3、nexus上传选填的group和Artifact会生成对应填入名称的路径,

ivysettings.xml

<?xml version="1.0" encoding="utf-8"?> 
<ivysettings>
       <settings defaultResolver="public" checkUpToDate="true" defaultConflictManager="latest-time"/>
        <resolvers>
                <ibiblio name="public" m2compatible="true" root="http://127.0.0.1:8081/nexus/service/local/repositories/releases/content/"/>
                 <ibiblio name="3rdparty" m2compatible="true" root="http://127.0.0.1:8081/nexus/content/repositories/thirdparty/"/>      
        </resolvers>
</ivysettings> 

ivy.xml

<ivy-module version="2.0">
    <info organisation="org.apache" module="hello-ivy"/>
    <dependencies>
        <dependency org="commons-lang" name="commons-lang" rev="2.4"/>
        <dependency org="commons-cli" name="commons-cli" rev="1.0"/>
    </dependencies>
</ivy-module>

root和dependencies决定build时拉取库的地址,如当前设置拉取commons-lang的路径是:

http://127.0.0.1:8081/nexus/service/local/repositories/releases/content/commons-lang/commons-lang/2.4/commons-lang-2.4.jar

因此,nuxus上传时group和Artifact都填‘commons-lang‘,对应dependency的’org‘和’name‘,形成两层的commons-lang目录

原文地址:https://www.cnblogs.com/iyjhabc/p/4135791.html