浏览 10066 次
锁定老帖子 主题:ivy尝试
精华帖 (0) :: 良好帖 (11) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-01-07
ivy是apche的ant的子项目,主要是用来解决ant的jar的版本管理。 项目的网址是http://ant.apache.org/ivy/ 下载网址http://ant.apache.org/ivy/download.cgi 包中有个ivy-2.1.0.jar,放在ant的安装目录的lib ,比如我的ubuntu的/usr/share/ant/lib 这样就可以使用在ant的中使用一些ivy内置的命令。 比如一个项目名phoenix,新建一个ivy.xml,
<ivy-module version="2.0"> <info organisation="com.phoenix" module="phoenix" revision="1.0.0"/> <configurations> <conf name="default"/> <conf name="test" visibility="private"/> </configurations> <dependencies> <dependency org="com.phoenix" name="phoenix-util" rev="${phoenix-public.version}" conf="default"/> <dependency org="com.phoenix" name="phoenix-core" rev="${phoenix-public.version}" conf="default"/> <dependency org="com.phoenix" name="phoenix-area" rev="${phoenix-public.version}" conf="default"/> <dependency org="com..phoenix" name="phoenix-kaka" rev="${phoenix-yunying.version}" conf="default"/> <dependency org="com..phoenix" name="phoenix-tag" rev="${phoenix.version}" conf="default"/> <dependency org="org.apache.struts" name="struts2-core" rev="2.0.14" conf="default"/> <dependency org="com.opensymphony" name="xwork" rev="2.0.7" conf="default"/> <dependency org="net.sourceforge" name="pinyin4j" rev="2.5.0" conf="default"/> <dependency org="org.apache.poi" name="poi" rev="3.2-FINAL" conf="default"/> <dependency org="dom4j" name="dom4j" rev="1.6.1" conf="default"/> <dependency org="org.springframework" name="spring-beans" rev="2.5.6" conf="default"/> <dependency org="org.springframework" name="spring" rev="2.5.6" conf="default"/> <dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="default"/> </dependencies> </ivy-module> 上面有该个工程需要的jar的版本,公司内部的jar版本用一个变量定义,便于统一升级 还有的ivysettings.xml是的主要配置的文件 <?xml version="1.0" encoding="utf-8"?> <ivysettings> <include url="./ivysettings-public.xml"/> <include url="./ivyconf-main-chain.xml"/> <include url="./ivyconf-local.xml"/> <ivy:configure url="./ivysettings.xml" > <credentials host="10.5.58.91" realm="Sonatype Nexus Repository Manager" username="admin" passwd="admin123" /> </ivy:configure> <settings defaultResolver="main" checkUpToDate="true" defaultConflictManager="latest-revision"/> </ivysettings> 上面的有我自己的 nexus的私服,可以上传ivy的打的jar包 ivysettings-public.xml(公共的服务器)下面定义两个仓库,用来区分是自己的release的,还是外部提供的jar <ivysettings> <resolvers> <ibiblio name="release" m2compatible="true" usepoms = " false " root="http://10.5.58.91/nexus/content/repositories/Koubei-release/"/> <ibiblio name="public" m2compatible="true" usepoms = " false " root="http://10.5.58.91/nexus/content/groups/public/"/> </resolvers> </ivysettings> ivyconf-local.xml <ivysettings> <property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local" override="false"/> <property name="ivy.local.default.ivy.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]" override="false"/> <property name="ivy.local.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]" override="false"/> <resolvers> <filesystem name="local"> <ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" /> <artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" /> </filesystem> </resolvers> </ivysettings> ivyconf-main-chain.xml
<ivysettings> <resolvers> <chain name="main" dual="true"> <resolver ref="release"/> <resolver ref="public"/> </chain> </resolvers> </ivysettings> 以上的ivy基本配置基本完成 现在就是在ant 中写相关的build.xml 的任务 ant resolve 下载需要的jar ant publish-local 发布到自己本机的仓库 ant publish 把相关的包发布到自己的私服 <!-- ================================= target: resolve ================================= --> <target name="resolve" description="--> retreive dependencies with ivy"> <ivy:retrieve /> </target> <!-- ================================= target: report ================================= --> <target name="report" depends="resolve" description="--> generates a report of dependencies"> <ivy:report todir= "build" /> </target> <!-- ================================= target: clean-cache ================================= --> <target name="clean-cache" description="--> clean the ivy cache"> <ivy:cleancache /> </target> <target name="publish-local" description="--> Publish Local" depends="build.phoenix"> <ivy:retrieve /> <ivy:publish resolver="local" pubrevision="${release.version}" status="release" update="true" overwrite="true"> <artifacts pattern="dist/[artifact].[ext]" /> </ivy:publish> </target> <target name="publish" description="--> Publish nexus" depends="publish-local"> <ivy:retrieve /> <ivy:publish resolver="release" pubrevision="${release.version}" status="release" update="true" overwrite="true" forcedeliver="true"> <artifacts pattern="dist/[artifact].[ext]" /> </ivy:publish> </target> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2010-05-24
根据你那个nexus设置后,我jar包上传到release目录下出现权限不够问题, refused by the server: Unauthorized。你的可以么
|
|
返回顶楼 | |
发表时间:2010-06-03
tanklove2 写道 根据你那个nexus设置后,我jar包上传到release目录下出现权限不够问题, refused by the server: Unauthorized。你的可以么
你可以在ivysettings.xml里设置ivy:configure。 如下: < ivy:configure file ="path/to/my/ivysettings.xml" > < credentials host ="myhost.com" realm ="My Realm" username ="myuser" passwd ="mypasswd" /> < credentials host ="yourhost.com" realm ="Your Realm" username ="myuser" passwd ="myotherpasswd" /> </ ivy:configure > |
|
返回顶楼 | |
发表时间:2010-07-13
ivy + ant 是否相当于 Python + ant 这样使用
|
|
返回顶楼 | |
发表时间:2010-07-17
shunai 写道 ivy + ant 是否相当于 Python + ant 这样使用
ivy是ant的一个子项目,应该是不是相当于python+ant的 |
|
返回顶楼 | |
发表时间:2010-10-09
用起来好麻烦,太麻烦了
|
|
返回顶楼 | |