我在项目文件夹下有my.ziptarget/
文件。
MyProject/
-target/
-my.zip
-pom.xml
在my.zip中有一个名为names.txt的文件。如果我在项目根目录下运行 linux 命令:
unzip -p target/my.zip names.txt > target/names.txt
我成功地将names.txt提取到target/
文件夹中:
MyProject/
-target/
-my.zip
-names.txt
-pom.xml
我想使用pom.xml中定义的exec-maven-plugin执行相同的命令。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>get names.txt</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- define the command to execute -->
<executable>unzip</executable>
<arguments>
<commandlineArgs>-p target/my.zip names.txt > target/names.txt</commandlineArgs>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
但是当我运行时maven clean install
,它不会生成names.txt,终端会显示我解压缩帮助文档:
UnZip 5.52 of 28 February 2005, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).
-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive
为什么?我怎样才能使它与 exec-maven-plugin 一起工作?