I am trying to executing a powershell script that writes to a file during a maven build.
I am invoking the build with mvn clean install
through Eclipse IDE.
This is the plugin in my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/.my-file.ps1</executable>
</configuration>
</plugin>
</plugins>
The powershell script is a hidden file so that's why I have a .
in front of the file name.
However, the plugin is not executing and I am following the instructions in the official documentation.
You are running mvn clean install
which will go through various build phases, but your exec plugin execution is not attached to any phase. You'll have to either:
Attach your execution to a phase by adding the <phase>
element to your execution, for example to attach it to the pre-integration-test
phase:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>my-exec</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/.my-file.ps1</executable>
</configuration>
</plugin>
Or call specifically the exec goal using mvn exec:exec
command.
If you are not familiar with the Maven lifecycle and various phases of a build, read the Introduction to the Build Lifecycle guide, or specifically the Plugins part to learn more about plugins executions and phases attachment.