使用maven-antrun-plugin在单独的窗口中启动批处理脚本



我有以下Maven Ant任务来启动批处理文件。

mvn clean verify成功启动服务器,但它似乎在后台。我想要的是在一个单独的DOS窗口中启动服务器

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>mavenproject2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>run</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <target>
                                <exec executable="cmd"
                                      dir="C:/apps/wlp/bin" spawn="true">
                                    <arg value="/c"/>
                                    <arg value="C:/apps/wlp/bin/server.bat"/>
                                    <arg value="start"/>
                                    <arg value="defaultServer"/>
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

cmd.exe有一个START命令:

C:>start /?
Starts a separate window to run a specified program or command.
START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
      [command/program] [parameters]

因此,<exec>任务将变成:

<exec executable="cmd"
  dir="C:/apps/wlp/bin" spawn="true">
  <arg value="/c"/>
  <arg value="START"/>
  <arg value="Optional Title of cmd.exe Window"/>
  <arg value="C:/apps/wlp/bin/server.bat"/>
  <arg value="start"/>
  <arg value="defaultServer"/>
</exec>

相关内容

  • 没有找到相关文章

最新更新