添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
小猫猫  ·  使用 DPO 微调 Llama 2-CSDN博客·  6 月前    · 
爱跑步的沙滩裤  ·  奇·达楞太·  9 月前    · 
冷静的炒粉  ·  可 爱 狗 狗 五 ...·  1 年前    · 
Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more

I am trying to run the com.github.klieber.phantomjs-maven-plugin alone before trying to run it with com.github.searls.jasmine-maven-plugin .

The final goal is to be able to run Javascripts tests in maven then in Jenkins.

But I always have the same error :

    [ERROR] Failed to execute goal com.github.klieber:phantomjs-maven-plugin:0.7:install (default) on project my-jasmine-project: Execution default of goal com.gith
    ub.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@f4a24a]
    [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)
    [ERROR]
    [ERROR] 1 error
    [ERROR] role: org.apache.maven.plugin.Mojo
    [ERROR] roleHint: com.github.klieber:phantomjs-maven-plugin:0.7:install

I created a maven project with

    mvn archetype:generate  -DarchetypeGroupId=com.github.searls
    -DarchetypeArtifactId=jasmine-archetype
    -DarchetypeVersion=RELEASE
    -DjasminePluginVersion=2.1
    -DgroupId=com.acme
    -DartifactId=my-jasmine-project
    -Dversion=0.0.1-SNAPSHOT

and here is the pom where I try to only install Phantom JS

  <build>
    <plugins>
      <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.7</version>
        </configuration>
      </plugin>
    </plugins>
  </build>

Could you tell me what I am doing wrong ?

Thanks in advance,

I think your issue is the same as this one: https://github.com/klieber/phantomjs-maven-plugin/issues/34

Solution: Make sure you are using Maven 3.1 or higher.

Thanks for you answer. Sorry for my late reply, didn't check my stackoverflow mails for long. I post my answer below if that can help anyone. It doesn't use the same maven plugin though. I was using Maven 3.0.3 so I think you were right. Thanks. – Kris Sep 25 '16 at 19:16

I found an other solution for running Javascripts tests in maven then in Jenkins

Below is how I use it in my POM:

                <!-- Install phantom JS binaries. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>initialize</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>org.phantomjs</groupId>
                                        <artifactId>phantomjs</artifactId>
                                        <version>${phantomjs.version}</version>
                                        <type>${phantomjs.packaging}</type>
                                        <classifier>${phantomjs.classifier}</classifier>
                                        <!-- Unpack the artifact in a directory at the same level than 
                                            the build directory. -->
                                        <outputDirectory>${project.build.directory}/..</outputDirectory>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

Depending on the platform I activate different profile so that I download the correct artifact (the one for Windows or the one for Linux on where our Jenkins runs. Hope it helps ! :)

    <!-- PhantomJS for Windows -->
    <profile>
        <id>phantomJS-windows</id>
        <activation>
                <family>windows</family>
        </activation>
        <properties>
            <phantomjs.classifier>windows</phantomjs.classifier>
            <phantomjs.bin>phantomjs.exe</phantomjs.bin>
            <phantomjs.packaging>zip</phantomjs.packaging>
            <test.script.ext>bat</test.script.ext>
        </properties>
    </profile>
    <!-- XXX: Jenkins instance runs on Linux 64 bits. -->
    <!-- 64 bits. -->
    <profile>
        <id>phantomJS-bca-jenkins</id>
        <activation>
            <property>
                <name>sun.arch.data.model</name>
                <value>64</value>
            </property>
        </activation>
        <properties>
            <phantomjs.classifier>linux-x86_64</phantomjs.classifier>
            <phantomjs.bin>bin/phantomjs</phantomjs.bin>
            <phantomjs.packaging>tar.bz2</phantomjs.packaging>
            <test.script.ext>sh</test.script.ext>
        </properties>
    </profile>
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2020.4.3.36492