2011-08-05 158 views
0

我在Mac 10.6.6上使用Maven 3.0.3。打包我的戰爭後,我想執行一個unzip命令(我想這樣做是因爲我使用的是一個Grails插件,它刪除了爆炸的戰爭目錄)。所以,我有這個在我的pom.xml ...Maven exec插件問題

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <version>1.1.1</version> 
    <configuration> 
     <executable>unzip</executable> 
     <arguments> 
      <argument>-d target/jx-1.0-SNAPSHOT target/jx-1.0-SNAPSHOT.war</argument> 
     </arguments> 
    </configuration> 
    <executions> 
     <execution> 
      <phase>verify</phase> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

然而,當我執行調用插件的命令,我得到的錯誤...

[INFO] --- exec-maven-plugin:1.1.1:exec (default-cli) @ jx --- 
[INFO] UnZip 5.52 of 28 February 2005, by Info-ZIP. Maintained by C. Spieler. Send 
[INFO] bug reports using http://www.info-zip.org/zip-bug.html; see README for details. 
[INFO] 
[INFO] Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir] 
[INFO] Default action is to extract files in list, except those in xlist, to exdir; 
[INFO] file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage). 
[INFO] 
[INFO] -p extract files to pipe, no messages  -l list files (short format) 
[INFO] -f freshen existing files, create none -t test compressed archive data 
[INFO] -u update files, create if necessary  -z display archive comment 
[INFO] -x exclude files that follow (in xlist) -d extract files into exdir 
[INFO] 
[INFO] modifiers:         -q quiet mode (-qq => quieter) 
[INFO] -n never overwrite existing files   -a auto-convert any text files 
[INFO] -o overwrite files WITHOUT prompting  -aa treat ALL files as text 
[INFO] -j junk paths (do not make directories) -v be verbose/print version info 
[INFO] -C match filenames case-insensitively  -L make (some) names lowercase 
[INFO] -X restore UID/GID info     -V retain VMS version numbers 
[INFO] -K keep setuid/setgid/tacky permissions -M pipe through "more" pager 
[INFO] Examples (see unzip.txt for more info): 
[INFO] unzip data1 -x joe => extract all files except joe from zipfile data1.zip 
[INFO] unzip -p foo | more => send contents of foo.zip via pipe into program more 
[INFO] unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 

任何想法我做錯了嗎?謝謝,戴夫

+0

爲什麼不使用maven-dependency-plugin並使用它而不是調用外部程序(這使得構建不可移植!)。 – khmarbaise

回答

1

你正在打包多個參數到一個<argument>。該元素只需要一個參數,如示例中的「-d」或「target/jx-1.0-SNAPSHOT」。您必須分解它們,否則您可以嘗試使用<commandlineArgs>

1

萊恩寫道,你會想這樣的:

<argument>-d</argument> 
<argument>target/jx-1.0-SNAPSHOT</argument> 
<argument>target/jx-1.0-SNAPSHOT.war</argument> 

而且,你是硬編碼的東西很多應該使用maven變量來實現。所以這裏有一個更好的版本:

<argument>-d</argument> 
<argument>${project.build.directory}/${project.build.finalName}</argument> 
<argument>${project.build.directory}/${project.build.finalName}.${project.packaging}</argument>