简体   繁体   English

常春藤依赖(拉入文件目录)

[英]Ivy Dependency (pull in directory of files)

Extreme edit to question to have it make more sense:对问题进行极端编辑以使其更有意义:

Let's assume that I need to use a local version of httpclient rather than one that I can just pull from an online repo (due to signing reasons).假设我需要使用本地版本的 httpclient 而不是我可以从在线存储库中提取的版本(由于签名原因)。 The way that I want to handle this is like so...我想处理这个的方式是这样的......

ivy.xml常春藤.xml


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

ivysettings.xml ivysettings.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>

Now what I'm hoping for here (and haven't been having much luck with) is the com.apache resolver looking for myServer:8080/Repo/com.apache/httpclient/4.2.2/ivy.xml and reading that, here's the contents of that file:现在我在这里希望(并且运气不佳)是 com.apache 解析器寻找 myServer:8080/Repo/com.apache/httpclient/4.2.2/ivy.xml 并阅读它,这是该文件的内容:

ivy.xml (in myServer:8080/repo/... directory) 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"/>

The reasoning behind wanting to read the second xml file rather than including the markup in my first file is pretty obvious when you consider how many LOC that would add to something that we include frequently.当您考虑将有多少 LOC 添加到我们经常包含的内容时,想要读取第二个 xml 文件而不是在我的第一个文件中包含标记的原因非常明显。 It also makes all future includes easier as well.它还使所有未来包括更容易。

Right now the error that I'm getting is:现在我得到的错误是:

Some projects fail to be resolved Impossible to resolve dependencies of com.myCompany#myProgramt;working@CompName unresolved dependency: com.apache#httpclient;4.2.2: not found部分项目无法解析无法解析com.myCompany#myProgramt的依赖;working@CompName unresolved dependency: com.apache#httpclient;4.2.2: not found


Thanks for your help on this matter.感谢您对此事的帮助。

When you configure your build to use the following resolver当您将构建配置为使用以下解析器时

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

You are telling ivy to download its dependencis from Maven Central您是在告诉 ivy 从Maven Central下载它的依赖项

What is your objective here?你在这里的目标是什么? To create a local ivy repo that functionally works like Maven Central?要创建一个功能类似于 Maven Central 的本地常春藤存储库? In that case the simplest solution would be to setup a Maven repository manager like: Nexus , Artifactory or Archiva .在这种情况下,最简单的解决方案是设置一个 Maven 存储库管理器,如: NexusArtifactoryArchiva A maven repository manager can act like a smart cache and "proxy" jars stored in the Central Maven repo. Maven 存储库管理器可以充当智能缓存和存储在中央 Maven 存储库中的“代理”jar。

Configuring your build to use a local Maven Repository is easy:配置您的构建以使用本地 Maven 存储库很容易:

 <ibiblio name="central" m2compatible="true" root="http://hostname:portnum/MavenRepo/>

Ivy expects to find all the dependencies of a given artifact in the same resolver. Ivy 希望在同一个解析器中找到给定工件的所有依赖项。 So, it finds the artifacts for com.apache in your repo resolver, and expects to find com.httpclient in there as well.因此,它com.apache在您的repo解析器中找到com.httpclient的工件,并希望在那里找到com.httpclient

Ivy also will roll through your <ivy pattern.../> and <artifact pattern.../> statements in order within the same resolver declaration. Ivy 还将在同一个解析器声明中按顺序滚动您的<ivy pattern.../><artifact pattern.../>语句。 You can use this to your advantage to create a single resolver which hits both repositories in the order you want:您可以利用它来创建一个解析器,该解析器以您想要的顺序访问两个存储库:

<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>

What server are you using for your remote JAR repository?您为远程 JAR 存储库使用什么服务器?

Both Nexus and Artifactory can be setup to pull jars stored locally on themselves before puling ones from the remote repository. Nexus 和 Artifactory 都可以设置为在从远程存储库中提取 jar 之前提取本地存储的 jar。 This way, you don't have to munge your ivysettings.xml .这样,您就不必修改您的ivysettings.xml Instead, you simply download your preferred versions of the jars on Artifactory/Nexus.相反,您只需在 Artifactory/Nexus 上下载您喜欢的 jar 版本。 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.使用 Artifactory/Nexus 做你想做的事情比使用你的 Ivy 设置更容易。

By the way, I have a Ivy project in Github you might want to look at.顺便说一下,我在 Github 上有一个Ivy 项目,你可能想看看。 You simply attach this project to your Ant project, and it has everything automatically configured for Ivy.您只需将此项目附加到您的 Ant 项目,它就会为 Ivy 自动配置所有内容。 This way, an entire site can use Ivy for all of their projects, and everything is centrally controlled.这样,整个站点都可以将 Ivy 用于他们的所有项目,并且一切都集中控制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM