如何将批处理文件挂钩到maven?

Dav*_*kys 1 hook batch-file maven

我需要挂钩或附加批处理文件到maven

所以,如果我说我输入mvn包

并且没有错误然后我创建的批处理文件将开始运行.

有没有办法做这样的事情?

ben*_*n75 7

您可以轻松地maven-exec-plugin将其与包阶段相关联:

    <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>
Run Code Online (Sandbox Code Playgroud)

使用此配置:批处理文件将在与包阶段关联的默认目标之后执行.