如何为phantomjs-maven-plugin传命令行参数?遇ssl-protocol报错
It looks like the issue comes down to how you're passing command-line options to the plugin. Using a single space-separated string for commandLineOptions can lead to incorrect parsing, which is why you're seeing the invalid value error for ssl-protocol.
Here's the corrected configuration that should resolve the problem:
<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> <!-- Split each command-line option into its own <option> element --> <commandLineOptions> <option>--ssl-protocol=any</option> <option>--ignore-ssl-errors</option> </commandLineOptions> <script>assets/test.js</script> <arguments> <argument>${liberty.https.server.port}</argument> </arguments> </configuration> </plugin>
Why this works:
The phantomjs-maven-plugin handles individual <option> elements far more reliably than a single concatenated string. By splitting your SSL-related flags into separate entries, you ensure the plugin passes them as distinct command-line arguments to PhantomJS—exactly matching the manual command you want to replicate:
phantomjs --ssl-protocol=any --ignore-ssl-errors test.js ${liberty.https.server.port}
Quick validation checks:
- PhantomJS 2.1.1 does support
--ssl-protocol=any(this option was added to let the binary auto-negotiate the best SSL/TLS version, so it's valid for your chosen version). - Double-check for typos in option names (e.g., confirm
--ignore-ssl-errorsis spelled correctly—no missing hyphens or misspellings).
After updating your pom.xml with this configuration, re-run your Maven integration test phase. This should eliminate the invalid option error and execute your script with the desired SSL settings.
内容的提问来源于stack exchange,提问作者nisanarz

