我目前正在处理使用maven的问题。我在使用maven构建软件时尝试更新文件。出于某种原因,我必须使用powershell脚本并在使用mvn构建时运行它。这是我的代码:
<exec executable="powershell.exe"
spawn="true">
<arg value="/c"/>
<arg value="myReplace.ps1"/>
<arg value="../../the/path/to/the/directory/" />
<arg value ="filename"/>
<arg value="value1" />
<arg value="value2" />
<arg value="value3" />
</exec>
它没有按预期工作,有人可以帮助我吗?
答案 0 :(得分:0)
此消息可以追溯到一段时间,但我在最后几天进行了练习。关键是使用exec插件如上所述。以下是项目的pom.xml中的示例:
下面的代码在PowerShell模块脚本上启动代码签名。请注意,命令字符串必须从命令行调用PowerShell函数,并且&amp;没有被Maven正确消化。逃避它可以解决问题。对于更复杂的操作,请调用PS脚本。
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>scripts-package</id>
<goals>
<goal>exec</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<!-- optional -->
<workingDirectory>/Temp</workingDirectory>
<arguments>
<argument>-command</argument>
<argument>"& { Set-AuthenticodeSignature '${project.build.directory}/Logging_Functions/*.psm1' @(Get-ChildItem ${project.build.certificate.path} -codesigning)[0]"}</argument>
</arguments>
</configuration>
</execution>