【发布时间】:2015-03-05 10:58:04
【问题描述】:
我将 ivy 配置为先使用 maven 本地 repo,然后再使用远程。但是出了点问题! (顺便说一下,我正在处理快照)
- 如果 ivy 缓存不存在,ivy 首先检查 maven 本地 repo,然后远程获取所需的 jars。一切都很好。
- 如果 ivy 缓存存在,ivy 只会检查本地 repo!它不检查远程!我这里有两个问题:
- 如果我在 maven 项目中更改某些内容并将其安装到 maven 的本地 repo,ivy 仍然会从其缓存中获取 jar,而不是从 maven 的本地 repo 中获取。
- 更糟糕的是,如果在 ivy 缓存中请求 jar,它不会在远程获取任何 jar。
ivysettings.xml
<ivysettings>
<settings defaultResolver="chain_resolver"/>
<credentials host="localhost"
realm="Sonatype Nexus Repository Manager"
username="username" passwd="password"/>
<property name="nexus.repo" value="url here"/>
<property name="nexus-public" value="http://${nexus.repo}:8081/nexus/content/groups/public"/>
<property name="m2-pattern" value="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]"/>
<resolvers>
<chain name="chain_resolver">
<ibiblio name="nexus" m2compatible="true" root="${nexus-public}"/>
<filesystem name="local" m2compatible="true">
<artifact pattern="${m2-pattern}"/>
<ivy pattern="${m2-pattern}"/>
</filesystem>
</chain>
</resolvers>
</ivysettings>
相关的蚂蚁任务
<target name="ivy-download" unless="offline">
<mkdir dir="${ivy.dir}"/>
<get src="${repo_public}/org/apache/ivy/ivy/${ivy.ver}/ivy-${ivy.ver}.jar" dest="${ivy.jar}" usetimestamp="true"/>
</target>
<target name="ivy-install" depends="ivy-download">
<path id="ivy.lib.path">
<fileset file="${ivy.jar}"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<ivy:settings file="ivysettings.xml" />
</target>
<target name="lib.get">
<mkdir dir="${lib.dir}"/>
<ivy:retrieve type="jar" conf="lib" pattern="${lib.dir}/[artifact]-[revision].[ext]"/>
</target>
<target name="ivy.lib.get" depends="ivy-install" if="${skipClean}">
<antcall target="lib.get" />
</target>
<target name="ivy.clean.lib.get" depends="ivy-install" unless="${skipClean}">
<ivy:cleancache/>
<antcall target="lib.get" />
</target>
如何查看
- 首先,本地 repo,如果有变化,从本地 repo 下载
- 然后,远程,如果有变化,从远程下载
这里还有一种可能的情况,就是如果remote和local同时发生变化,我该怎么办?
【问题讨论】: