通过maven调用程序插件运行构建后脚本



在构建war文件后,我正在尝试运行一个简单的beanshell脚本来打印"Hello World"。我正在参考这篇文章。然而,我不断地得到";没有选择要执行的项目"在运行mvn clean install之后。我不确定错误是来自文件的目录,还是在构建war文件后无法打印"Hello World"。

+- project folder/
+- buildTargetWarFileFolder/
+- python/
+- folder/
|  +-helloWolrd.bsh
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<debug>true</debug>
<projectsDirectory>project folder</projectsDirectory>
<postBuildHookScript>python/folder/helloWorld.bsh</postBuildHookScript>
</configuration>
<executions>
<execution>
<id>print Hello World</id>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

我建议直接使用exec:exec目标,绑定到maven构建的集成测试阶段(试用您的python脚本(。

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<executable>python</executable>
<arguments>
<argument>-c</argument>
<argument>print('Hello world')</argument>
</arguments>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>

这与创建战争后在命令行上运行以下命令相同:

python -c "print('Hello world')"

最新更新