我第一次创建了Maven项目,之前我可以使用mvn test
命令在不传递参数的情况下运行它。
现在我想将参数传递给它,所以我改变了pom.xml但得到了跟随错误
BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.209 s
[INFO] Finished at: 2014-12-23T12:52:44+05:30
[INFO] Final Memory: 5M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'exec' in plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 among available goals help, compile, testCompile -> [Help 1]
org.apache.maven.plugin.MojoNotFoundException: Could not find goal 'exec' in plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 among available goals help, compile, testCompile
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:273)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:239)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:233)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:103)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:83)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:85)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
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.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)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/3.2.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/3.2.3 http://maven.apache.org/xsd/maven-3.2.3.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Grok</groupId>
<artifactId>MobileApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Login to app</name>
<description>Login to Grok app</description>
<repositories>
<repository>
<id>saucelabs-repository</id>
<url>https://repository-saucelabs.forge.cloudbees.com/release</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>sauce_junit</artifactId>
<version>2.1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<!-- Include Sauce Connect plugin -->
<plugin>
<groupId>com.saucelabs.maven.plugin</groupId>
<artifactId>sauce-connect-plugin</artifactId>
<version>2.1.9</version>
<configuration>
<sauceUsername>admins-test-numenta</sauceUsername>
<sauceAccessKey>f6c91fa5-d400-42be-85e1-f7060098f922</sauceAccessKey>
<options>-i testing</options>
</configuration>
<executions>
<execution>
<id>start-sauceconnect</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-sauceconnect</goal>
</goals>
</execution>
<execution>
<id>stop-sauceconnect</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-sauceconnect</goal>
</goals>
</execution>
<execution>
<id>exec-one</id>
<phase>verify</phase>
<configuration>
<executable>echo</executable>
<variables>
<variable>serverUrl:${Gvars.server}</variable>
</variables>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<configuration>
<variables>
<variable>serverUrl:${RFvars.browser}</variable>
</variables>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
我是从命令行运行它
mvn org.apache.maven.plugins:maven-compiler-plugin:exec -DGvars.server=url_to_be_used
如果我在pom文件或命令中执行任何错误操作,请告诉我。 提前致谢
答案 0 :(得分:1)
问题在于您的maven-compiler-plugin配置。正如错误消息所述,编译器插件没有exec
目标(Could not find goal 'exec' in plugin org.apache.maven.plugins:maven-compiler-plugin
)。
它只有两个目标可供选择:
compile
testCompile
此外,我不确定您希望编译器插件对variables
配置做什么。它不会know关于variables
所以会忽略它。
将编译器插件配置更改为:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
但实际上这是默认配置,所以你可以进一步简化它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
答案 1 :(得分:0)
我没有更新我的pom.xml
只使用Testng的@Parameters({"url", "pwd"})
注释
它为我工作。