2014-05-06 41 views
2

你好我試圖在Maven來設置父的版本上的屬性定義的版本,但它不工作使用屬性值來設置maven父級版本?

這裏是我寫的

<parent> 
    <groupId>com.me.android</groupId> 
    <artifactId>me-android</artifactId> 
    <version>${tools.version}</version> 
    <relativePath>../pom.xml</relativePath> 
</parent> 
<properties> 
     <tools.version>1.0.0-SNAPSHOT</tools.version> 
<properties> 

它不工作,我不得不手動鍵入版本值而不是使用屬性值。下面

[ERROR] The build could not read 1 project -> [Help 1] 
[ERROR] 
[ERROR] The project com.me.android:tools-android-hello:${tools.version} (/Users/me/Work/tools-android/ToolsServer/pom.xml) has 1 error 
[ERROR]  Non-resolvable parent POM: Could not transfer artifact com.me.android:tools-android:pom:${tools.version} from/to releases (http://artifactory/artifactory/releases): Illegal character in path at index 89: http://artifactory/artifactory/releases/com/me/android/tools-android/${tools.version}/tools-android-${tools.version}.pom and 'parent.relativePath' points at wrong local POM @ line 11, column 13 -> [Help 2] 

    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
    [ERROR] Re-run Maven using the -X switch to enable full debug logging. 
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles: 
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException 
    [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException 
+0

確實我有,但沒有解決它 – jonney

+0

編輯帖子 – jonney

回答

5

誤差這是一個已知的問題。不幸的是,你不能參數化父節。

Maven不允許在父元素中的任何元素中指定變量。安裝或部署項目時,Maven會將項目的pom.xml複製到本地或遠程存儲庫中。沒有對文件進行更改。

進行了詳細的解釋和可能的解決方法請參見本JIRA問題:

http://docs.codehaus.org/display/MAVEN/Automatic+Parent+Versioning

雖然錯誤是記錄在2008年,不幸的是它仍然是一個當前問題。看看上市相關的問題,特別是:

http://jira.codehaus.org/browse/MNG-624

這是最近更新的。似乎沒有補救措施即將推出,但您可以嘗試解決方法。