2013-10-12 36 views
1

我在Ubuntu上安装了7za。从命令行工作的:从maven-exec调用7za失败

7za a -tzip -pMY_SECRET -mem=AES256 secure.zip /home/user/tmp/test.txt 

在Maven项目我试图从Maven的Exec插件调用它:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>encrypt-zip</id> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
      <phase>process-resources</phase> 
      <configuration> 
       <executable>7za</executable> 
      <!-- <executable>/usr/bin/7za</executable> --> 
       <arguments> 
        <argument>-tzip</argument> 
        <argument>-pMY_SECRET</argument> 
        <argument>-mem=AES256</argument> 
        <argument>/home/user/tmp/test.txt</argument> 
        <argument>secure.zip</argument> 
       </arguments> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

但它失败,此错误:

7-Zip (A) [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU) 


Error: 
Incorrect command line 

没有太多的工作在这里,有什么建议吗?

+1

我真的不知道,但不应该在'单曲在同一顺序在命令行的例子吗?另外我没有看到'a',这是命令行中的第一个参数。 – janos

+0

你是对的,它现在可以工作,如果你喜欢,将它转换为答案。 – u123

回答

1

<argument>标记与示例命令行不完全匹配,缺少a

或许,如果你重写这样它会工作:

<argument>a</argument> 
<argument>-tzip</argument> 
<argument>-pMY_SECRET</argument> 
<argument>-mem=AES256</argument> 
<argument>secure.zip</argument> 
<argument>/home/user/tmp/test.txt</argument>