如何在maven中运行powershell脚本

如何在maven中运行powershell脚本,maven,powershell,Maven,Powershell,我目前正在使用maven处理一个问题。我尝试在使用maven构建软件时更新一个文件。出于某种原因,在使用mvn构建时,我必须使用powershell脚本并运行它。这是我的密码: <exec executable="powershell.exe" spawn="true"> <arg value="/c"/> <arg value="myRepl

我目前正在使用maven处理一个问题。我尝试在使用maven构建软件时更新一个文件。出于某种原因,在使用mvn构建时,我必须使用powershell脚本并运行它。这是我的密码:

<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>


它没有像预期的那样工作,有人能帮我吗?

这条消息来自一段时间,但我在最后几天完成了这项练习。关键是要使用前面提到的exec插件。以下是项目的pom.xml中的一个示例:

下面的代码启动PowerShell模块脚本上的代码签名。注意,为了从命令行调用PowerShell函数,命令字符串必须以&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>"&amp; { Set-AuthenticodeSignature '${project.build.directory}/Logging_Functions/*.psm1' @(Get-ChildItem ${project.build.certificate.path} -codesigning)[0]"}</argument>
                    </arguments>
                    </configuration>
                </execution>
。。。
org.codehaus.mojo
execmaven插件
1.3.2
脚本包
执行官
准备包装
/临时工
-命令
“&;{Set AuthenticodeSignature'${project.build.directory}/Logging_Functions/*.psm1'@(Get-ChildItem${project.build.certificate.path}-代码签名)[0]””

这条消息可以追溯到很久以前,但我在最后几天完成了这项练习。关键是要使用前面提到的exec插件。以下是项目的pom.xml中的一个示例:

下面的代码启动PowerShell模块脚本上的代码签名。注意,为了从命令行调用PowerShell函数,命令字符串必须以&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>"&amp; { Set-AuthenticodeSignature '${project.build.directory}/Logging_Functions/*.psm1' @(Get-ChildItem ${project.build.certificate.path} -codesigning)[0]"}</argument>
                    </arguments>
                    </configuration>
                </execution>
。。。
org.codehaus.mojo
execmaven插件
1.3.2
脚本包
执行官
准备包装
/临时工
-命令
“&;{Set AuthenticodeSignature'${project.build.directory}/Logging_Functions/*.psm1'@(Get-ChildItem${project.build.certificate.path}-代码签名)[0]””

请给我们错误消息这看起来很像Ant。你说(并标记了Maven)。怎么样?你不是只想使用吗?请给我们错误信息这看起来很像Ant。你说(并标记了Maven)。怎么样?你不就是想用这个吗?