从maven

时间:2015-04-22 13:15:57

标签: maven maven-3 maven-plugin exec-maven-plugin

我在名为Project root/ -output/ -my.zip pom.xml 的文件夹下有一个 zip 文件。该zip包含3个文件。

output/

my.zip(包含names.txt,schools.txt,teachers.txt)。

如何从zip&中提取 names.txt ?把它放在 maven unzip -p output/my.zip names.txt > output/names.txt 下?

===我尝试过:===

我可以通过从项目根运行命令来实现它:

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> <executable>unzip</executable> <commandlineArgs>-p output/my.zip names.txt > output/names.txt</commandlineArgs> </configuration> </execution> </executions> </plugin> &amp;跑maven:

exec-maven-plugin

我总是使用exec-maven-plugin 无法执行目标

我的{{1}}配置有什么问题,以及在maven中实现它的任何其他方法?

3 个答案:

答案 0 :(得分:2)

您应该查看提供目标unpack的{​​{3}}:

<project>
   [...]
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <version>2.10</version>
         <executions>
           <execution>
             <id>unpack</id>
             <phase>package</phase>
             <goals>
               <goal>unpack</goal>
             </goals>
             <configuration>
               <artifactItems>
                 <artifactItem>
                   <groupId>junit</groupId>
                   <artifactId>junit</artifactId>
                   <version>3.8.1</version>
                   <type>jar</type>
                   <overWrite>false</overWrite>
                   <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                   <destFileName>optional-new-name.jar</destFileName>
                   <includes>**/*.class,**/*.xml</includes>
                   <excludes>**/*test.class</excludes>
                 </artifactItem>
               </artifactItems>
               <includes>**/*.java</includes>
               <excludes>**/*.properties</excludes>
               <outputDirectory>${project.build.directory}/wars</outputDirectory>
               <overWriteReleases>false</overWriteReleases>
               <overWriteSnapshots>true</overWriteSnapshots>
             </configuration>
           </execution>
         </executions>
       </plugin>
     </plugins>
   </build>
   [...]
 </project>

答案 1 :(得分:0)

您可以使用Default: Not set Timeout: 30 seconds EasyBCD Boot Device: D:\ Entry #1 Name: Internal Hard Disk or Solid State Disk BCD ID: {8fc567c6-d7b0-11e4-9454-c3522382cf45} Device: Unknown Bootloader Path: Entry #2 Name: USB Drive (UEFI) BCD ID: {8fc567c2-d7b0-11e4-9454-c3522382cf45} Device: Unknown Bootloader Path: Entry #3 Name: Internal CD/DVD ROM Drive (UEFI) BCD ID: {8fc567c3-d7b0-11e4-9454-c3522382cf45} Device: Unknown Bootloader Path: Entry #4 Name: Windows 8.1 BCD ID: {current} Drive: C:\ Bootloader Path: \Windows\system32\winload.efi Entry #5 Name: Lubuntu BCD ID: {eabbb4d1-d76f-11e4-825c-40e2303afcfa} Drive: D:\ Bootloader Path: \NST\AutoNeoGrub0.mbr 执行此操作,此示例我认为您将得到答案。

maven-antrun-plugin

答案 2 :(得分:0)

可能是因为commandLineArgs正在被给予。

例如:根据插件文档,标准输出应使用可选参数“outputFile”进行定向

http://mojo.codehaus.org/exec-maven-plugin/exec-mojo.html#outputFile

尝试执行一些简单的命令,例如pwdls -la,然后返回unzip示例。

更新

您可能还需要查看使用XML CDATA提供参数

<sampleTag>
<![CDATA[
    Some text with > and <
 ]]>
</sampleTag>