klieber / phantomjs-maven-plugin Goto Github PK
View Code? Open in Web Editor NEWA maven plugin for installing the phantomjs binary on your system automatically.
Home Page: http://klieber.github.io/phantomjs-maven-plugin
License: MIT License
A maven plugin for installing the phantomjs binary on your system automatically.
Home Page: http://klieber.github.io/phantomjs-maven-plugin
License: MIT License
Not sure if this is the right place for this..
Could you please push the latest release of phantomjs (1.9.8) to the central repo.
phantomjs 1.9.8 sets the default SSL version to TLS instead of SSLv3, thus addressing the vulnarability described in CVE-2014-3566
see:
The plugin is searching the path for phantomjs
when it should be searching for phantomjs.exe
on windows systems.
We currently have a test that validates we can use this plugin to download phantomjs and then pass the location of that binary to another maven plugin. I would like to have a test that validates that we can also pass the location of the binary into a suite of JUnit tests that might need it for creating a PhantomJSDriver.
This should be very simple. Will just need a project with a single JUnit test that gets the value of the phantomjs.binary
property and fails if it is not set.
Add configuration options so that you can use this plugin on a network behind a proxy.
Something like:
<configuration>
<proxy.host>example.com</proxy.host>
<proxy.port>8000</proxy.port>
<proxy.username>klieber</proxy.username>
<proxy.password>mypassword</proxy.password>
</configuration>
For credentials, I'd like to take an approach similar to the github maven-site-plugin which allows you to store them in your settings.xml instead of in the pom.xml.
I am using this plugin with phantomjs version 1.9.2, Java 1.6 and maven 3.2. It works well in my local eclipse set up. When I run this on bamboo CI build, it throws following error:
"target/phantomjs-maven-plugin/phantomjs-1.9.2-linux-i686/bin/phantomjs: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory"
Here is the pom.xml plugin details:
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.9.2</version>
</configuration>
</plugin>
Am I missing any thing or doing something wrong. Any suggestions or help on this would be much appreciated.
Thanks
Hi,
First of all, thanks for this plugin, it helps a lot !
I am using the version 0.7 (same with 0.6) of your plugin, using
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: d:\java\apache-maven-3.0.4
Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
Java home: d:\java\jdk1.6.0_26\jre
Default locale: en_IE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
The following exception is thrown.
28-May-2015 16:30:19 org.sonatype.guice.bean.reflect.Logs$JULSink warn
WARNING: Error injecting: com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo
com.google.inject.ConfigurationException: Guice configuration errors:
1 error
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:991)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:950)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1000)
at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
If you need anything else to help
Currently when the plugin is executed from a project the working directory is the project base dir. [1]
The phantomjs command executes using this directory and there isn't option to change it.
Add a workingDirectory
optional parameter to the exec
goal to customize it.
I think that given that this goal it is bound by default to the lifecycle phase test
the default working directory must be the ${project.build.testOutputDirectory}
with the posibility to change it. [2]
[1]
PhantomJsProcessBuilder.start()
uses ProcessBuilder
and looking at the JavaDoc of java.lang.ProcessBuilder.directory()
we find this:
"The returned value may be null -- this means to use the working directory of the current Java process, usually the directory named by the system property user.dir, as the working directory of the child process."
[2]
This will break backward compatibility but to get the same behavior of version < 0.5 you can set <workingDirectory>${project.basedir}</workingDirectory>
inside the section of this plugin.
It would be nice to be able to specify phantomjs binary path without invoking 'install' goal.
Currently jasmine-maven-plugin relies on ${phantomjs.binary} property set by phantomjs-maven-plugin within 'install' goal. While it is okay for CI build, it makes impossible to run jasmine-maven-plugin:test goal separately on developer host. Right now it is possible to specify 'outputDirectory' property but the final path will be OS specific anyway (phantomjs.exe vs phantomjs). I suggest to add 'outputBinaryPath' which will be the final full path of binary including executable filename. I.e.
<outputBinaryPath>
target/phantomjs-dir/custom-phantomjs-name</outputBinaryPath>
means to extract binary to '${project.dir}/target/phantomjs-dir', rename 'phantomjs' to 'custom-phantomjs-name' and grant it executable rights. This way 'install' goal on developer host can be run only once and will extract binary to predictable path. Then jasmine:test goal can be used with specified 'phantomjs.binary.path' equals to 'outputBinaryPath' value.
What does the following in the POM Plugin XML refer to?
<configuration>
<version>1.9.2</version>
</configuration>
Caused by: java.lang.NullPointerException
at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.findBinaryOnSystemPath(InstallPhantomJsMojo.java:131)
at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.run(InstallPhantomJsMojo.java:113)
at com.github.klieber.phantomjs.mojo.AbstractPhantomJsMojo.execute(AbstractPhantomJsMojo.java:73)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 20 more
When a phantomjs script is executed and exits with a non-zero exit code that should cause the build to fail. There should also be a configuration parameter for ignoring the exit code (which is the current behavior) for those that do not wish to have this functionality.
It appears that bitbucket has changed the URL their downloads are hosted on.
For instance, the old URL for the 1.9.6 version for 64 bit Linux systems was the following:
http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.6-linux-x86_64.tar.bz2
But now that URL returns a 403 error. The new URL appears to be this:
https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.6-linux-x86_64.tar.bz2
Phantomjs 2.1.1 is released. Please add.
It looks like in newer maven the plugin's classloader is closed before TrueZip's shutdown hook has a chance to unmount any open files, leading to an exception.
PR #19 contains a proposed fix that works with maven 3.1.1
PhantomJS has released ver 2.1,
http://phantomjs.org/releases.html
PhantomJS 2.1 was released on January 23, 2016. It came with an updated WebKit library based on Qt 5.5.
The download page has 2.1.1 http://phantomjs.org/download.html
Please could you bundle this up for phantomjs-maven-plugin
and update here when it's ready?
(I'd submit a PR, but I don't know how to for this.)
When using the version 2.0.0 of phantomjs the plugin will fail with
de.schlichtherle.truezip.fs.FsEntryNotFoundException: zip:file:~/.m2/repository/com/github/klieber/phantomjs/2.0.0/phantomjs-2.0.0-windows.zip!/phantomjs-2.0.0-windows/phantomjs.exe (no such entry)
The problem is that phantomjs.exe is now in the phantomjs-2.0.0-windows/bin
subdirectory in the phantomjs-2.0.0-windows.zip
instead of the phantomjs-2.0.0-windows
directory.
Only tested on windows.
We have a multi-module project in which we declare and configure the phantomjs-maven-plugin for optional use by the child modules. When the plugin is enabled for a child module and we run mvn
from the child module's directory to build only that module, phantomjs-maven-plugin executes successfully. However, when mvn
is run from the parent module's directory, the phantomjs-maven-plugin fails to execute for that same child module, giving the following error:
Failed to execute PhantomJS command: Unable to start phantomjs process. Cannot run program "cmd.exe" (in directory "test"): CreateProcess error=267, The directory name is invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.klieber:phantomjs-maven-plugin:0.7:exec (default) on project CMS_Chat_Management_Portlet: Failed to execute PhantomJS command
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to execute PhantomJS command
at com.github.klieber.phantomjs.mojo.ExecPhantomJsMojo.run(ExecPhantomJsMojo.java:139)
at com.github.klieber.phantomjs.mojo.AbstractPhantomJsMojo.execute(AbstractPhantomJsMojo.java:73)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: com.github.klieber.phantomjs.exec.ExecutionException: Unable to start phantomjs process.
at com.github.klieber.phantomjs.exec.PhantomJsProcessBuilder.start(PhantomJsProcessBuilder.java:104)
at com.github.klieber.phantomjs.exec.PhantomJsExecutor.execute(PhantomJsExecutor.java:33)
at com.github.klieber.phantomjs.mojo.ExecPhantomJsMojo.run(ExecPhantomJsMojo.java:134)
... 23 more
Caused by: java.io.IOException: Cannot run program "cmd.exe" (in directory "test"): CreateProcess error=267, The directory name is invalid
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at com.github.klieber.phantomjs.exec.PhantomJsProcessBuilder.start(PhantomJsProcessBuilder.java:102)
... 25 more
Caused by: java.io.IOException: CreateProcess error=267, The directory name is invalid
at java.base/java.lang.ProcessImpl.create(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:420)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:151)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
... 27 more
The parent pom can be simplified as follows:
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<configuration>
<version>2.1.1</version>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
...
and the child pom as follows:
...
<build>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>install</goal>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<workingDirectory>test</workingDirectory>
<script>${basedir}/../test_lib/qunit-phantomjs-runner-2.3.1/runner-list.js</script>
<arguments>
<argument>test_suite.html</argument>
<argument>30</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
...
The debug information for the module execution when run from the parent directory is:
[INFO] --- phantomjs-maven-plugin:0.7:exec (default) @ CMS_Chat_Management_Portlet ---
[DEBUG] Configuring mojo com.github.klieber:phantomjs-maven-plugin:0.7:exec from plugin realm ClassRealm[plugin>com.github.klieber:phantomjs-maven-plugin:0.7, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@5ef04b5]
[DEBUG] Configuring mojo 'com.github.klieber:phantomjs-maven-plugin:0.7:exec' with basic configurator -->
[DEBUG] (f) arguments = [test_suite.html, 30]
[DEBUG] (f) failOnNonZeroExitCode = true
[DEBUG] (f) mavenProject = MavenProject: mil.mc2sa:CMS_Chat_Management_Portlet:1.0.0-SNAPSHOT @ C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet\pom.xml
[DEBUG] (f) phantomJsBinary = C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet\target\phantomjs-maven-plugin\phantomjs-2.1.1-windows\bin\phantomjs.exe
[DEBUG] (f) propertyName = phantomjs.binary
[DEBUG] (f) script = C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet/../test_lib/qunit-phantomjs-runner-2.3.1/runner-list.js
[DEBUG] (f) skip = false
[DEBUG] (f) workingDirectory = test
[DEBUG] -- end configuration --
[INFO] Executing phantomjs command
[DEBUG] phantomjs command: [cmd.exe, /X, /C, "C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet\target\phantomjs-maven-plugin\phantomjs-2.1.1-windows\bin\phantomjs.exe C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet/../test_lib/qunit-phantomjs-runner-2.3.1/runner-list.js test_suite.html 30"]
and the debug information for the module execution when run from the child directory is:
[INFO] --- phantomjs-maven-plugin:0.7:exec (default) @ CMS_Chat_Management_Portlet ---
[DEBUG] Configuring mojo com.github.klieber:phantomjs-maven-plugin:0.7:exec from plugin realm ClassRealm[plugin>com.github.klieber:phantomjs-maven-plugin:0.7, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@5ef04b5]
[DEBUG] Configuring mojo 'com.github.klieber:phantomjs-maven-plugin:0.7:exec' with basic configurator -->
[DEBUG] (f) arguments = [test_suite.html, 30]
[DEBUG] (f) failOnNonZeroExitCode = true
[DEBUG] (f) mavenProject = MavenProject: mil.mc2sa:CMS_Chat_Management_Portlet:1.0.0-SNAPSHOT @ C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet\pom.xml
[DEBUG] (f) phantomJsBinary = C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet\target\phantomjs-maven-plugin\phantomjs-2.1.1-windows\bin\phantomjs.exe
[DEBUG] (f) propertyName = phantomjs.binary
[DEBUG] (f) script = C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet/../test_lib/qunit-phantomjs-runner-2.3.1/runner-list.js
[DEBUG] (f) skip = false
[DEBUG] (f) workingDirectory = test
[DEBUG] -- end configuration --
[INFO] Executing phantomjs command
[DEBUG] phantomjs command: [cmd.exe, /X, /C, "C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet\target\phantomjs-maven-plugin\phantomjs-2.1.1-windows\bin\phantomjs.exe C:\Users\Developer\Source\cms\CMS_Chat_Management_Portlet/../test_lib/qunit-phantomjs-runner-2.3.1/runner-list.js test_suite.html 30"]
Using your 2.0-beta-2
, I am successfully running tests on windows and mac. On linux, however, the following exception is thrown (see below). It looks like a linux version of phantomjs 2.0.0 is missing, which I do not see here here: https://repo1.maven.org/maven2/com/github/klieber/phantomjs/2.0.0/
[INFO] jetty-8.1.14.v20131031
[INFO] Started [email protected]:42304
[INFO] Executing Jasmine Specs
[INFO] Downloading: http://wd-artifactory.autodesk.com/artifactory/repo/com/github/klieber/phantomjs/2.0.0/phantomjs-2.0.0-linux-x86_64.tar.bz2
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/github/klieber/phantomjs/2.0.0/phantomjs-2.0.0-linux-x86_64.tar.bz2
[ERROR] Unable to locate phantomjs binary
com.github.klieber.phantomjs.install.InstallationException: Unable to install phantomjs.
at com.github.klieber.phantomjs.install.PhantomJsInstaller.install(PhantomJsInstaller.java:55)
at com.github.klieber.phantomjs.locate.ArchiveLocator.locate(ArchiveLocator.java:45)
at com.github.klieber.phantomjs.locate.CompositeLocator.locate(CompositeLocator.java:39)
at com.github.klieber.phantomjs.locate.PhantomJsLocator.locate(PhantomJsLocator.java:54)
at com.github.searls.jasmine.driver.WebDriverFactory.createPhantomJsWebDriver(WebDriverFactory.java:145)
at com.github.searls.jasmine.driver.WebDriverFactory.createWebDriver(WebDriverFactory.java:68)
at com.github.searls.jasmine.mojo.TestMojo.createDriver(TestMojo.java:258)
at com.github.searls.jasmine.mojo.TestMojo.executeSpecs(TestMojo.java:233)
at com.github.searls.jasmine.mojo.TestMojo.run(TestMojo.java:202)
at com.github.searls.jasmine.mojo.AbstractJasmineMojo.execute(AbstractJasmineMojo.java:396)
at com.github.searls.jasmine.mojo.TestMojo.execute(TestMojo.java:189)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven32Launcher.main(Maven32Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven32Main.launch(Maven32Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:136)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
at hudson.remoting.UserRequest.perform(UserRequest.java:121)
at hudson.remoting.UserRequest.perform(UserRequest.java:49)
at hudson.remoting.Request$2.run(Request.java:324)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.github.klieber.phantomjs.download.DownloadException: Unable to resolve artifact.
at com.github.klieber.phantomjs.download.RepositoryDownloader.download(RepositoryDownloader.java:64)
at com.github.klieber.phantomjs.install.PhantomJsInstaller.install(PhantomJsInstaller.java:52)
... 42 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.github.klieber:phantomjs:tar.bz2:linux-x86_64:2.0.0 in autodesk-releases (http://wd-artifactory.autodesk.com/artifactory/repo)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)
at com.github.klieber.phantomjs.download.RepositoryDownloader.download(RepositoryDownloader.java:58)
... 43 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.github.klieber:phantomjs:tar.bz2:linux-x86_64:2.0.0 in autodesk-releases (http://wd-artifactory.autodesk.com/artifactory/repo)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 47 more
Hello Kyle,
it seems a bug troubling many people has finally been adressed: ariya/phantomjs#12750
The fix should be contained in the release 2.1.13
It would be highly appreciated if the Maven plugin could use version 2.1.13 on Linux.
Hello,
in order to automate PhantomJS tests I found your plug-in.
As far as I see from the docs, I just need to add this to my pom.xml
<build>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>${phantomjs-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.9.7</version>
</configuration>
</plugin>
</plugins>
</build>
And then I expect all Phantom JS binaries to be downloaded and the tests to run smoothly.
But each time I run them I get:
java.lang.IllegalStateException: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable
Only if I set explicidly the PATH variable to point the target folder with the binaries with PhantomJS, but thats not the option.
Am I doing something wrong? Thanks!
Follow the Sonatype guide to get this deployed to the maven central repository.
Hi,
We are using the phantomjs-maven-plugin
with Maven
version Apache Maven 3.0.5 (Red Hat 3.0.5-17)
and are seeing this error:
[ERROR] Failed to execute goal com.github.klieber:phantomjs-maven-plugin:0.7:install (default) on project <project_name>: Execution default of goal com.github.klieber:phantomjs-maven-plugin:0.7:install failed: Unable to load the mojo 'install' (or one of its required components) from the plugin 'com.github.klieber:phantomjs-maven-plugin:0.7': com.google.inject.ProvisionException: Guice provision errors:
[ERROR]
[ERROR] 1) Could not find a suitable constructor in com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
[ERROR] at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.class(Unknown Source)
[ERROR] while locating com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo
[ERROR] at ClassRealm[plugin>com.github.klieber:phantomjs-maven-plugin:0.7, parent: sun.misc.Launcher$AppClassLoader@7852e922]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=com.github.klieber:phantomjs-maven-plugin:0.7:install)
...
One of the suggestions is to use Maven version >= 3.1, can you confirm if this is the only solution?
Hello,
We have a company maven repository that proxies all maven artifact requests.
It seems that phantomjs-maven-plugin tries to download phantomjs artifact in a way that is preventing our company repository from getting the artifact from maven central.
Maybe the issue lies in aether project or the way it is used?
Downloading: http://repo.mycompany.com/repository/all/com/github/klieber/phantomjs/1.9.8/phantomjs-1.9.8-linux-x86_64.tar.bz2
[ERROR] Unable to locate phantomjs binary
com.github.klieber.phantomjs.install.InstallationException: Unable to install phantomjs.
at com.github.klieber.phantomjs.install.PhantomJsInstaller.install(PhantomJsInstaller.java:55)
at com.github.klieber.phantomjs.locate.ArchiveLocator.locate(ArchiveLocator.java:45)
at com.github.klieber.phantomjs.locate.CompositeLocator.locate(CompositeLocator.java:39)
at com.github.klieber.phantomjs.locate.PhantomJsLocator.locate(PhantomJsLocator.java:58)
at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.run(InstallPhantomJsMojo.java:180)
at com.github.klieber.phantomjs.mojo.AbstractPhantomJsMojo.execute(AbstractPhantomJsMojo.java:73)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:185)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:181)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.github.klieber.phantomjs.download.DownloadException: Unable to resolve artifact.
at com.github.klieber.phantomjs.download.RepositoryDownloader.download(RepositoryDownloader.java:64)
at com.github.klieber.phantomjs.install.PhantomJsInstaller.install(PhantomJsInstaller.java:52)
... 18 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.github.klieber:phantomjs:tar.bz2:linux-x86_64:1.9.8 in company-repo-all (http://repo.mycompany.com/repository/all)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)
at com.github.klieber.phantomjs.download.RepositoryDownloader.download(RepositoryDownloader.java:58)
... 19 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.github.klieber:phantomjs:tar.bz2:linux-x86_64:1.9.8 in company-repo-all (http://repo.mycompany.com/repository/all)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 23 more
Regards
When checkSystemPath is set to true and phantomjs is found, the phantomjs-maven-plugin sets the phantomjs.binary to "phantomjs" and not the actual path where phantomjs is located. This causes a problem when used with the Jasmine-Maven-Plugin and PhantomJsDriver. When PhantomJsDriver tries to locate the phantom binaries it tries new File("phantomjs"), and thus looking in the current directory, which will fail.
The following code can be used to retrieve the correct location on OSX/Linux:
private String getAbsolutePhantomPath() throws MojoExecutionException{
Commandline commandline = new Commandline("which");
commandline.createArg().setValue(PHANTOMJS);
try {
String path = extractString(commandline);
getLog().info("Phantomjs is installed in location"+path);
return path;
} catch (IOException e) {
throw new MojoExecutionException("Failed to locate phantom",e);
} catch (InterruptedException e) {
throw new MojoExecutionException("Failed to locate phantom", e);
}
}
private String extractString(Commandline commandline) throws IOException, InterruptedException{
Process process = new ProcessBuilder(commandline.getShellCommandline()).start();
BufferedReader standardOut = new BufferedReader(new InputStreamReader(process.getInputStream()));
String versionString = StringUtils.trim(standardOut.readLine());
int exitCode = process.waitFor();
if (exitCode != 0){
return null;
}
return versionString;
}
On windows, the "where" command could possibly be used instead of "which", but I haven't verified this.
The link in the readme.md gives me "Owner is restricted"
A few days ago version 2 of phantomjs was released. Not all builds are available yet, but just making a note of this.
release notes: http://phantomjs.org/release-2.0.html
also note that there are some regressions.
How I can fix this error in the pom.xml file in the project?
Plugin execution not covered by lifecycle configuration: com.github.klieber:phantomjs-maven-plugin:0.7:install (execution: default, phase: process-test-sources)
Pom.xml:
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>2.1.1</version>
</configuration>
</plugin>
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
<webDriverCapabilities>
<capability>
<name>phantomjs.binary.path</name>
<value>${phantomjs.binary}</value>
</capability>
</webDriverCapabilities>
<jsSrcDir>WebContent/public/utils/test/jasmine</jsSrcDir>
<jsTestSrcDir>WebContent/public/utils/test/spec</jsTestSrcDir>
<preloadSources>
<include>WebContent/public/utils/js/validate_utils-company-1.0.js</include>
</preloadSources>
<haltOnFailure>true</haltOnFailure>
</configuration>
</execution>
</executions>
</plugin>
Hi,
I am new to maven and try to use PhantomJS in my unit test. Here is part of my pom.xml
<project>
...
<build>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.4</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.9.8</version>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
The code I use in my unit test is
@Test
public void shouldHavePhantomJsBinary() {
String binary = System.getProperty("phantomjs.binary");
assertNotNull(binary);
assertTrue(new File(binary).exists());
}
The assert fails when I run the test.
I think the goal is trigger because it downloads phantomjs into target directory.
But it seems phantomjs.binary is not set?
I use maven 3.2.3 and java 8.
Thank you in advance!
Hi,
I get the error below when I added the plugin to my pom.xml file -
[ERROR] 1) Could not find a suitable constructor in com.github.klieber.phantomjs
.mojo.InstallPhantomJsMojo. Classes must have either one (and only one) construc
tor annotated with @Inject or a zero-argument constructor that is not private.
[ERROR] at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.class(Unknown
Source)
Is there anything I should configure that would fix this issue?
The binary phantomjs-2.0.0-macosx-fix01.zip
is found here:
https://repo1.maven.org/maven2/com/github/klieber/phantomjs/2.0.0/
but not here:
https://bitbucket.org/ariya/phantomjs/downloads/
when the application is run on a Tomcat server the ${phantomjs,binary} defined in pom.xml is always returning null
The documentation claims that the POM plugin xml will automatically set ${phantomjs.binary} however when using JetBrains IntelliJ IDEA, the IDE does not seem to recognize that token.
In addition, when running the maven step, the build fails on:
<webDriverCapabilities>
<phantomjs.binary.path>${phantomjs.binary}</phantomjs.binary.path>
</webDriverCapabilities>
I'm assuming because it does not recognize the token ${phantomjs.binary}
Is there any chance you could add the binaries from 2.5beta to your archive?
Hello,
is it really neccesary for your library to use Maven 3.1 as minumim requierement? We use Maven 3.0x and it is not possible for us to upgrade to a newer version. :-(
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.