根據documentation,Maven發佈:執行目標檢查項目,然後派生一個新的Maven實例來構建它。出於某種原因,分叉的實例似乎忽略了用戶的settings.xml
,這在我的情況下會導致錯誤,因爲該文件具有用於組成父pom中的存儲庫URL的屬性的定義。在 「關係」 配置文件是始終處於活動狀態的屬性Maven發佈的進程分叉:執行插件會忽略用戶的settings.xml?
用戶的settings.xml
定義。<profiles> <profile> <id>nexus</id> <properties> <dist.url>http://host.com/nexus/content/repositories</dist.url> </properties> </profile> </profiles> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
家長的pom.xml
定義屬性的使用來組成存儲庫的URL。<distributionManagement> <repository> <id>nexus</id> <url>${dist.url}/releases</url> </repository> </distributionManagement>
執行的命令:
mvn release:perform
輸出(之後則表示已經成功簽出,構建,測試和封裝項目):
[INFO] Uploading: ${dist.url}/releases/com/acme/access/my-project/1.0/my-project-1.0.jar [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] BUILD FAILURE [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] Total time: 3.659s [INFO] [INFO] Finished at: Wed Aug 01 14:40:23 EDT 2012 [INFO] [INFO] Final Memory: 21M/307M [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [WARNING] The requested profile "nexus" could not be activated because it does not exist. [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project my-project: Failed to deploy artifacts: Could not transfer artifact com.acme.access:my-project:jar:1.0 from/to nexus (${dist.url}/releases): Error transferring file: no protocol: ${dist.url}/releases/com/acme/access/my-project/1.0/my-project-1.0.jar -> [Help 1]
注意如何分叉的Maven實例正試圖上傳到$ {dist.url},這表明在setti中定義的屬性沒有讀取ngs.xml。此外,警告消息通知未找到配置文件「nexus」。我假設主Maven實例將配置文件信息傳遞給分叉實例,以便它知道要查找它,但由於它忽略(或未找到)用戶的settings.xml,因此無法找到該配置文件。
我已經找到了規避,這是通過使用Maven的命令行-s
參數「包裝」該插件的arguments
說法手動指定settings.xml
文件的位置的唯一方法,如
mvn release:perform -Darguments="-s C:\Users\theuser\.m2\settings.xml"
該插件是否以預期/正確的方式運行?有沒有辦法將屬性定義保留在用戶的settings.xml
內,而不必像上面所做的那樣指定文件的位置?
的更多信息:
這個問題似乎與插件沒有找到用戶的
settings.xml
,如複製配置文件信息融入全球settings.xml
不會導致它的工作是特別。用戶的
settings.xml
被正確命名/創建,因爲運行help:active-profiles
表明配置文件處於活動狀態。使用mvn clean deploy
手動構建和部署也可以正常工作(即正確計算存儲庫URL並上載工件)。
我覺得在我的情況下類似類型的問題.http://stackoverflow.com/questions/18636196/maven-issue-the-goal-you-specified-requires-a-project-to-execute-but-there -is – 2013-09-06 04:56:34