1

对问题进行极端编辑以使其更有意义:

假设我需要使用本地版本的 httpclient 而不是我可以从在线仓库中提取的版本(由于签名原因)。我想处理这个的方式是这样的......

常春藤.xml


<dependencies>  
    ...Other dependencies here
    <dependency org="com.apache" name="httpclient" rev="4.2.2" conf="compile->default" ext="jar" />
</dependencies>

常春藤设置.xml


<settings defaultResolver="central"/>

<resolvers>
<url name="repo">
    <ivy pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/ivy.xml" />
    <artifact pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/[artifact].[ext]"/>
</url>

<url name="httpclient">
    <artifact pattern="http://myServer:8080/Repo/com.apache/httpclient/4.2.2/[artifact].[ext]"/>
</url>



<modules>
    <module organisation="com.apache" resolver="repo" />
    <module organisation="com.httpclient" resolver="httpclient" />
</modules>

现在我在这里希望(并且运气不佳)是 com.apache 解析器正在寻找 myServer:8080/Repo/com.apache/httpclient/4.2.2/ivy.xml 并阅读它,这是该文件的内容:

ivy.xml(在 myServer:8080/repo/... 目录中)


    <dependency org="com.httpclient" name="commons-codec" rev="1.6" />
    <dependency org="com.httpclient" name="commons-logging" rev="1.1.1" />
    <dependency org="com.httpclient" name="fluent-hc" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpclient" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpclient-cache" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpcore" rev="4.2.2" />
    <dependency org="com.httpclient" name="httpmime" rev="4.2.2"/>

当您考虑到有多少 LOC 会添加到我们经常包含的内容中时,想要读取第二个 xml 文件而不是在我的第一个文件中包含标记的原因非常明显。它还使所有未来包括更容易。

现在我得到的错误是:

部分项目无法解析 无法解析 com.myCompany#myProgramt;working@CompName 的依赖 未解析的依赖:com.apache#httpclient;4.2.2: not found


感谢您对此事的帮助。

4

3 回答 3

1

Ivy 期望在同一个解析器中找到给定工件的所有依赖项。因此,它会com.apache在您的repo解析器中找到工件,并希望也能com.httpclient在其中找到。

Ivy 还将在同一个解析器声明中按顺序遍历您的<ivy pattern.../>and语句。<artifact pattern.../>您可以利用它来创建一个解析器,该解析器按您想要的顺序访问两个存储库:

<url name="amalgamation">
    <ivy pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/ivy.xml" />
    <artifact pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/[artifact].[ext]"/>
    <artifact pattern="http://myServer:8080/Repo/com.apache/httpclient/4.2.2/[artifact].[ext]"/>
</url>
于 2012-11-28T18:35:05.193 回答
1

当您将构建配置为使用以下解析器时

 <ibiblio name="central" m2compatible="true"/>

你告诉 ivy 从Maven Central下载它的依赖

你在这里的目标是什么?要创建一个功能类似于 Maven Central 的本地 ivy 存储库?在这种情况下,最简单的解决方案是设置一个 Maven 存储库管理器,例如:NexusArtifactoryArchiva。maven 存储库管理器可以充当存储在 Central Maven 存储库中的智能缓存和“代理”jar。

将构建配置为使用本地 Maven 存储库很容易:

 <ibiblio name="central" m2compatible="true" root="http://hostname:portnum/MavenRepo/>
于 2012-11-27T06:13:29.503 回答
0

What server are you using for your remote JAR repository?

Both Nexus and Artifactory can be setup to pull jars stored locally on themselves before puling ones from the remote repository. This way, you don't have to munge your ivysettings.xml. Instead, you simply download your preferred versions of the jars on Artifactory/Nexus. And, both are free, open source, downloads. It's way easier to do what you want with Artifactory/Nexus than futzing with your Ivy settings.

By the way, I have a Ivy project in Github you might want to look at. You simply attach this project to your Ant project, and it has everything automatically configured for Ivy. This way, an entire site can use Ivy for all of their projects, and everything is centrally controlled.

于 2012-11-28T19:34:07.347 回答