Max
Max

Reputation: 2343

Can maven run command line instructions?

Can we bind some native OS commands to the maven goals and/or phases?

Upvotes: 20

Views: 31355

Answers (3)

jitter
jitter

Reputation: 54605

Actually there is the Exec Maven Plugin for these cases.

Upvotes: 18

user130532
user130532

Reputation:

See exec-maven-plugin for details

Upvotes: 9

Romain Linsolas
Romain Linsolas

Reputation: 81617

Not natively.

However, by using the AntRun plugin, you can specify an Ant task (using Exec) that execute a OS command during the build.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase> <!-- a lifecycle phase --> </phase>
            <configuration>
              <tasks>

                <!--
                  Place any Ant task here. You can add anything
                  you can add between <target> and </target> in a
                  build.xml.
                -->

              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>

Upvotes: 5

Related Questions