【问题标题】:Maven exec plugin questionMaven exec插件问题
【发布时间】:2011-08-05 23:38:21
【问题描述】:

我在 Mac 10.6.6 上使用 Maven 3.0.3。打包我的战争后,我想执行一个解压缩命令(我想这样做是因为我使用了一个删除爆炸的战争目录的 Grails 插件)。所以我在我的 pom.xml 中有这个……

<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] ------------------------------------------------------------------------

任何想法我做错了什么?谢谢, - 戴夫

【问题讨论】:

  • 为什么不使用 maven-dependency-plugin 并使用它而不是调用外部程序(这使得构建不可移植!)。

标签: maven-2 maven-plugin unzip


【解决方案1】:

您将多个参数打包到一个&lt;argument&gt; 中。该元素仅采用一个参数,例如您的示例中的“-d”或“target/jx-1.0-SNAPSHOT”。您要么必须拆分它们,要么尝试改用&lt;commandlineArgs&gt;

【讨论】:

    【解决方案2】:

    正如 Ryan 所写,你会想要这个:

    <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>
    

    【讨论】:

      猜你喜欢
      • 2015-02-04
      • 2017-05-11
      • 2018-04-12
      • 2018-12-25
      • 1970-01-01
      • 2011-11-29
      • 1970-01-01
      • 2016-12-08
      • 2018-07-10
      相关资源
      最近更新 更多