問題現象:從svn上簽下源代碼,本地執行打包命令,提示如下錯誤:
[ERROR] Failed to execute goal on project dddwriter: Could not resolve dependencies for project com.xxx.yyy:dddwriter:jar:1.0.0: Failed to collect dependencies at com.xxx.yyy:zzzplugin:jar:1.0.0: Failed to read artifact descriptor for com.xxx.yyy:zzzplugin:jar:1.0.0: Failure to find com.xxx.yyy: aa-bb-zzz:pom:1.0.0 in http://10.10.1.5:8081/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
分析:開始以為原因是找不到zzzplugin:jar,這個是本地的一個項目模塊,可以打包成功,仔細看提示,說的是Failed to collect,並非找不到jar包。最后一個Failure to find ... 點出了根本原因,找不到 aa-bb-zzz構建,而且是線上找不到(當然首先本地沒有才會去線上找),這個構建作用是提供dddwriter和zzzplugin的父pom,打包dddwriter時,因為依賴的zzzplugin沒有在倉庫找到此構建,所以失敗。
總結:在有父pom的情況下,打包上傳子構建會導致引用此構建的項目無法成功打包。
解決辦法:直接打包父構建。
ps: 一開始並不是想直接打包子模塊,只是因為前人將子模塊的name設置的非常像父模塊(應該是手誤),加上在IDEA里面,父子模塊是平級的,所以把它當父模塊打包了,后來找出真正的父模塊,一次打包成功。