How do i hook a batch file to maven?

2019-04-15 01:30发布

i need to hook or attach a batch file to maven

so if lets say i type mvn package

and the there were no errors then a batch file i created would start running.

is there a way of doing something like that ?

1条回答
家丑人穷心不美
2楼-- · 2019-04-15 02:09

You can easily do that with the maven-exec-plugin and linking it with the package phase:

    <build>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
              <execution>
                <id>runbatchfile</id>
                <phase>package</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <executable>c:\path\to\file.bat</executable>
            </configuration>
          </plugin>
        </plugins>

With this configuration : your batch file will be execute just after the default goal associated with the package phase.

查看更多
登录 后发表回答