【问题标题】:Execute cmd command using maven pom.xml file使用 maven pom.xml 文件执行 cmd 命令
【发布时间】:2014-02-28 13:15:31
【问题描述】:

我想使用单个 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>

我可以知道我该怎么做吗?

【问题讨论】:

  • 你想运行哪些命令?
  • 'cd files123' 和 'grunt'
  • 你看过添加和Ant任务吗?
  • @OveSundberg 不,我不知道。
  • 首先使用最新版本的 exec-maven-plugin 并描述什么不符合您的预期?

标签: java maven cmd pom.xml


【解决方案1】:

试试类似的东西

<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-30
    • 2011-03-30
    • 1970-01-01
    • 2013-07-21
    • 2021-02-19
    • 2012-06-27
    • 1970-01-01
    相关资源
    最近更新 更多