使用pom.xml执行windows powershell脚本

问题描述 投票:-1回答:1

我想用Maven执行windows powershell脚本。这是我尝试过的:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <executions>
        <execution>
            <id>some-execution</id>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>D:\Projects\test.ps1</executable>
    </configuration>
</plugin>

但它只是在执行pom时打开powershell脚本

mvn exec:exec
maven powershell maven-3 pom.xml
1个回答
0
投票

没有任何其他选项,所以在批处理文件中写下面的行

PowerShell -NoProfile -ExecutionPolicy unrestricted -Command D:\Projects\Test.ps1

并使用exec插件调用批处理文件,该文件将执行powershell脚本。

喜欢

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <executions>
        <execution>
            <id>some-execution</id>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>D:\Projects\test1.bat</executable>
    </configuration>
</plugin>
© www.soinside.com 2019 - 2024. All rights reserved.