我有my.zip文件在項目的target/
文件夾下。Linux命令(unzip -p)使用exec-maven-plugin運行
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定義exec-maven-plugin執行相同的命令.xml。
<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一起工作?
用'>'而不是'>'試過,它不起作用 – user842225
@ user842225:這不是你唯一需要改變的東西。 –
@Aaron,我非常感謝你通過添加'-c unzip'來更新你的答案,但它也不起作用。 – user842225