我如何将命令行选项传递给 phantomjs maven 插件

How can i pass command line option to phantomjs maven plugin

我在我的 Java 项目中使用 phantomjs-maven-plugin。 我试图用 pom.xml 将命令行选项传递给 phantomjs 类似的东西(在插件 docs:

中描述
<plugin>
            <groupId>com.github.klieber</groupId>
            <artifactId>phantomjs-maven-plugin</artifactId>
            <version>0.7</version>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>install</goal>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <version>2.1.1</version>
                <checkSystemPath>true</checkSystemPath>
                <commandLineOptions>--ssl-protocol=any --ignore-ssl-errors</commandLineOptions>
                <script>assets/test.js</script>
                <arguments>
                    <argument>${liberty.https.server.port}</argument>
                </arguments>
            </configuration>
        </plugin>

一般来说,我试图做的是这样的事情:

phantomjs --ssl-protocol=any --ignore-ssl-errors test.js

但经过数小时的搜索,目前还没有成功。

当我执行 运行 我的 Maven 任务时,出现以下错误:

[INFO] Executing phantomjs command
Invalid values for 'ssl-protocol' option.

我想这个命令行选项有一些语法问题。

感谢您的帮助!

终于发现我这里的配置有问题了。 只需要将 <commandLineOptions> 移动到 <execution> 区域内的配置部分。 它最终看起来是这样的:

    <execution>
        <phase>integration-test</phase>
        <goals>
            <goal>install</goal>
            <goal>exec</goal>
        </goals>
        <configuration>
            <commandLineOptions>--ssl-protocol=any --ignore-ssl-errors=true</commandLineOptions>
        </configuration>
    </execution>

我从下面的主要配置部分中删除了它。

我设法弄清楚我之前所做的是将命令行参数传递给 test.js 脚本的执行和 phantom.js 的执行。

我希望它能为像我这样迷路的人服务:)