使用maven pom.xml文件执行cmd命令

时间:2014-02-28 04:21:30

标签: java maven cmd pom.xml

我想使用单个pom.xml在maven中运行多个CMD命令。

我正在使用此插件,但它无效

<pluginManagement>          <plugins>
                <plugin>
                    <!-- ignore unsupported maven operations in eclipse m2e -->
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-dependency-plugin</artifactId>
                                        <versionRange>[1.0.0,)</versionRange>
                                        <goals>
                                            <goal>unpack</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>

                <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>exec-maven-plugin</artifactId>
                  <version>1.2</version>
                  <executions>
                    <execution>
                      <id>run a backup</id>
                      <phase>pre-integration-test</phase>
                      <goals>
                        <goal>exec</goal>
                      </goals>
                      <configuration>
                        <executable>yourscript.sh</executable>
                      </configuration>
                    </execution>
                  </executions>
                </plugin>

            </plugins>      </pluginManagement>

我可以知道我该怎么做?

1 个答案:

答案 0 :(得分:0)

尝试类似

的内容
<plugin>  
 <artifactId>maven-antrun-plugin </artifactId>  
   <executions>  
     <execution>  
       <phase>install </phase>  
       <configuration>  
         <tasks name="Run Notepad">    
           <exec  
             dir="${basedir}"  
             executable="${basedir}/notepad.exe"  
             failonerror="true">  
             <arg line=""/>  
           </exec>  
        </tasks>  
       </configuration>  
       <goals>  
         <goal>run </goal>  
       </goals>  
     </execution>  
   </executions>  
 </plugin>