2012-02-21 90 views

回答

8

使用輸出特性:

MVN幫助:有效-POM -Doutput = < FILE>

+0

我誤解了文檔。我認爲它只會將你得到的輸出寫入文件。但是,由於所有的日誌語句都來自maven本身,而不是插件,所以輸出文件從這種垃圾中清晰可見。你知道一種方法來抑制mvn日誌語句,並只寫入插件結果到標準輸出嗎? – oschrenk 2012-02-24 10:04:35

+0

有了這個,獲取屬性的腳本被簡化爲'mvn help:effective-pom -Doutput = effective.pom && xml sel -N x = http://maven.apache.org/POM/4.0.0 - t -c「/ x:project/x:屬性」effective.pom「。但是它會在你的工作目錄中留下effective.pom。 – oschrenk 2012-02-24 10:07:27

4

作爲一種變通方法

mvn help:effective-pom | grep -v '\[INFO\|\[WARNING\|Downloading' | sed '1,2d' | xml sel -N x=http://maven.apache.org/POM/4.0.0 -t -c "/x:project/x:properties" 

將輸出特性爲XML。您需要xmlstarlet

brew install xmlstarlet #OSX 
apt-get install xmlstarlet