2012-07-26 15 views
1

我已經通過下面的命令克隆番石榴的存儲庫:如何運行番石榴的單元測試?

git clone https://code.google.com/p/guava-libraries/

因爲我不完全熟悉番石榴的結構,我想下面的命令:

cd guava-libraries 
mvn test

不幸的是,我收到以下錯誤(整個輸出可用查看here)。

[INFO] ------------------------------------------------------------------------ 
[INFO] Building Guava GWT compatible libs 
[INFO] task-segment: [test] 
[INFO] ------------------------------------------------------------------------ 
Downloading: https://oss.sonatype.org/content/repositories/snapshots/com/google/guava/guava/13.0-SNAPSHOT/guava-13.0-SNAPSHOT-sources.jar 
[INFO] Unable to find resource 'com.google.guava:guava:jar:sources:13.0-SNAPSHOT' in repository sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots) 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Failed to resolve artifact. 

Missing: 
---------- 
1) com.google.guava:guava:jar:sources:13.0-SNAPSHOT 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=com.google.guava -DartifactId=guava -Dversion=13.0-SNAPSHOT -Dclassifier=sources -Dpackaging=jar -Dfile=/path/to/file 

    Alternatively, if you host your own repository you can deploy the file there: 
     mvn deploy:deploy-file -DgroupId=com.google.guava -DartifactId=guava -Dversion=13.0-SNAPSHOT -Dclassifier=sources -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] 

    Path to dependency: 
    1) com.google.guava:guava-gwt:jar:13.0-SNAPSHOT 
    2) com.google.guava:guava:jar:sources:13.0-SNAPSHOT 

---------- 
1 required artifact is missing. 

for artifact: 
    com.google.guava:guava-gwt:jar:13.0-SNAPSHOT 

from the specified remote repositories: 
    central (http://repo1.maven.org/maven2), 
    sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots)

我該如何運行番石榴的單元測試?

回答

3

在完成安裝到本地存儲庫之前,您不能僅運行mvn測試。請首次運行:

mvn clean install 

然後您只能運行mvn test。 SNAPSHOT的庫在庫中尚不可用。

+0

謝謝,這有幫助。拋出了一些例外。我可能會在未來幾天進一步調查。 – 2012-07-27 11:39:02

+0

對不起,但在完成安裝之前無法運行mvn測試的表達是錯誤的。因爲您不瞭解Maven構建生命週期,因此測試即將在生命週期中安裝。此外,如果mvn測試無法正常工作,則構建會出現問題。 – khmarbaise 2012-07-31 08:05:44

+0

@khmarbaise你寫一個模塊maven項目。現在想象一下 - 子項目B依賴於項目A.您沒有編譯/安裝項目A.現在您正在嘗試構建項目B.您將收到錯誤「無法找到資源groupId:B:jar:sources:version-SNAPSHOT',因爲項目A沒有上傳/安裝在任何存儲庫中。 – 2012-07-31 08:16:25

0

爲什麼在從Maven Central獲得候選版本時使用快照修訂?

<dependency> 
    <groupId>com.google.guava</groupId> 
    <artifactId>guava</artifactId> 
    <version>13.0-rc2</version> 
</dependency> 
+0

要清楚,我沒有選擇使用快照修訂。我簡單地克隆了這個項目,並試圖運行它的單元測試。 – 2012-07-27 11:29:57