2012-02-09 60 views
2

我在.NET商店中使用Ant和Ivy進行依賴關係管理,並且已經取得了很多成功,但是我找不到解決此問題的解決方案。我的問題涉及具有幾個不同配置文件的模塊的存儲庫結構(缺少 這個更好的術語)。例如,我試圖在存儲庫中設置的模塊(它是第三方庫 - Castle)已針對不同版本的.NET平臺進行了編譯。這個分佈具有以下目錄結構:具有多個構建(配置文件)的模塊的常青藤儲存庫結構?

  • net35/Castle.Core.dll
  • net40clientprofile/Castle.Core.dll
  • SL3/Castle.Core.dll
  • SL4/Castle.Core。 dll的

我ivysettings.xml文件都有文件解析器設置爲這樣:

<filesystem name="fs.resolver" cache="nn.repo.cache"> 
    <ivy pattern="${repository.dir}/[organisation]/[module]/[shortRevision]/[revision]/ivy.xml" /> 
    <artifact pattern="${repository.dir}/[organisation]/[module]/[shortRevision]/[revision]/[artifact].[ext]" /> 
</filesystem> 

起初,我認爲配置可以用於此,但沒有 取得很大進展。我如何在Ivy.xml文件中多次指定同名的工件?我不認爲你可以。另外,如果我在存儲庫中添加子目錄,我的 必須在ivysettings.xml中修改我的工件模式?

Ivy建議使用此模塊的建議方法是什麼? 這個模塊的Ivy.xml文件是什麼樣的? ivysettings.xml文件如何修改?

希望我不必爲同一版本的庫的每個不同編譯創建單獨的模塊。

在此先感謝您的幫助。

回答

3

在ivy中,您可以將extra attributes添加到模塊工件中。

項目設置:

|-- build.xml 
|-- ivysettings.xml 
|-- ivy.xml 
`-- repository 
    `-- myorg 
     `-- Castle 
      `-- 1.0 
       |-- ivy.xml 
       |-- net35 
       | `-- Castle.Core.dll 
       |-- net40clientprofile 
       | `-- Castle.Core.dll 
       |-- sl3 
       | `-- Castle.Core.dll 
       `-- sl4 
        `-- Castle.Core.dll 

的ivy.xml

使用配置映射來選擇要下載的神器:

<ivy-module version="2.0"> 
    <info organisation="org.demo" module="demo"/> 
    <dependencies> 
     <dependency org="myorg" name="Castle" rev="1.0" conf="default->net35"/> 
    </dependencies> 
</ivy-module> 

ivysettings.xml

僞影圖案包括extra attribute稱爲 「簡檔」

<ivysettings> 
    <settings defaultResolver="local"/> 
    <resolvers> 
     <filesystem name="local"> 
      <ivy pattern="${ivy.settings.dir}/repository/[organisation]/[module]/[revision]/ivy.xml" /> 
      <artifact pattern="${ivy.settings.dir}/repository/[organisation]/[module]/[revision]/[profile]/[artifact].[ext]" /> 
     </filesystem> 
    </resolvers> 
</ivysettings> 

庫/ MYORG /城堡/ 1.0 /的ivy.xml

extra attribute的 「簡檔」 用於模塊內的工件之間進行區分。這些配置用於啓用客戶端模塊的配置映射。

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra"> 
    <info organisation="myorg" module="Castle" revision="1.0" status="release"/> 
    <configurations> 
     <conf name="net35"/> 
     <conf name="net40clientprofile"/> 
     <conf name="sl3"/> 
     <conf name="sl4"/> 
    </configurations> 
    <publications> 
     <artifact name="Castle.Core" type="dll" e:profile="net35" conf="net35"/> 
     <artifact name="Castle.Core" type="dll" e:profile="net40clientprofile" conf="net40clientprofile"/> 
     <artifact name="Castle.Core" type="dll" e:profile="sl3" conf="sl3"/> 
     <artifact name="Castle.Core" type="dll" e:profile="sl4" conf="sl4"/> 
    </publications> 
</ivy-module> 
+0

馬克,謝謝你。至於你的答案,由於額外的屬性和配置有相同的值,我不能只使用[conf]工件模式,而不是添加額外的屬性?你可以在ivysettings中使用[conf]作爲文件解析器嗎? – drohm 2012-02-10 20:52:53

+0

我想到了同樣的想法。但是,它不會那樣工作。嘗試一下,你會發現它試圖對工件模式的[conf]部分使用值「default」。這是因爲「default」是在依賴聲明中映射的配置。這很難描述,但額外的屬性是將附加元數據添加到模塊中的工件的機制。另一方面,配置是決定檢索哪些工件的機制。 – 2012-02-10 21:24:34

+0

感謝您的見解,這將有很大幫助。 – drohm 2012-02-10 23:06:48