I have created Maven project for the first time and I was able to run it previously without passing parameter by using mvn test
command.
Now I want to pass parameter to it so i changes pom.xml but getting following error
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
Here is my 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>
I am running this from command line
mvn org.apache.maven.plugins:maven-compiler-plugin:exec -DGvars.server=url_to_be_used
Please let me know if I am doing anything wrong in pom file or in command to run project. Thanks in advance
The problem is with your maven-compiler-plugin configuration. As the error message states the compiler plugin does not have an exec
goal ( Could not find goal 'exec' in plugin org.apache.maven.plugins:maven-compiler-plugin
).
It only has two goals available and these are:
compile
testCompile
Also I'm not sure what you expect the compiler plugin to do with the variables
configuration. It doesn't know about variables
so will ignore it.
Change your compiler-plugin configuration to be as follows:
<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>
But actually this is the default configuration so you can simplify it even further to just be:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
I am not updating my pom.xml
Just using @Parameters({"url", "pwd"})
annotation of Testng
Its working for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.