簡體   English   中英

常春藤依賴(拉入文件目錄)

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

對問題進行極端編輯以使其更有意義:

假設我需要使用本地版本的 httpclient 而不是我可以從在線存儲庫中提取的版本(由於簽名原因)。 我想處理這個的方式是這樣的......

常春藤.xml


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

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>

現在我在這里希望(並且運氣不佳)是 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 unresolved dependency: com.apache#httpclient;4.2.2: not found


感謝您對此事的幫助。

當您將構建配置為使用以下解析器時

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

您是在告訴 ivy 從Maven Central下載它的依賴項

你在這里的目標是什么? 要創建一個功能類似於 Maven Central 的本地常春藤存儲庫? 在這種情況下,最簡單的解決方案是設置一個 Maven 存儲庫管理器,如: NexusArtifactoryArchiva Maven 存儲庫管理器可以充當智能緩存和存儲在中央 Maven 存儲庫中的“代理”jar。

配置您的構建以使用本地 Maven 存儲庫很容易:

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

Ivy 希望在同一個解析器中找到給定工件的所有依賴項。 因此,它com.apache在您的repo解析器中找到com.httpclient的工件,並希望在那里找到com.httpclient

Ivy 還將在同一個解析器聲明中按順序滾動您的<ivy pattern.../><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>

您為遠程 JAR 存儲庫使用什么服務器?

Nexus 和 Artifactory 都可以設置為在從遠程存儲庫中提取 jar 之前提取本地存儲的 jar。 這樣,您就不必修改您的ivysettings.xml 相反,您只需在 Artifactory/Nexus 上下載您喜歡的 jar 版本。 而且,兩者都是免費的、開源的、可下載的。 使用 Artifactory/Nexus 做你想做的事情比使用你的 Ivy 設置更容易。

順便說一下,我在 Github 上有一個Ivy 項目,你可能想看看。 您只需將此項目附加到您的 Ant 項目,它就會為 Ivy 自動配置所有內容。 這樣,整個站點都可以將 Ivy 用於他們的所有項目,並且一切都集中控制。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM