Java7
Maven Cargo
Maven Cargo Error: Artifact [xx:xx:war] is not a dependency of the project.
Nov 6th
You run a Maven task and it fails with the message “Artifact [xx:xx:war] is not a dependency of the project.”.
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.3:deploy (default-cli) on project hms-web: Artifact [sg.java:hms-web:war] is not a dependency of the project. -> [Help 1]
[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/MojoExecutionException
It tells you to get more help with a link reference that i did not find much helpful.
This error is surfacing because you have specified in your Maven task to deploy the WAR with cargo:deploy.
Cargo could not find the war!
Rectification
Check that your project coordinates tally with what you have specified in the Cargo plugin, specifically the groupId and artifactId.
Making sure the groupId and artifactId project coordinates tally with what is specified in Cargo plugin solves the problem.
Take note of the groupId and artifactId project coordinates specified.
Check that the groupId and artifactId project coordinates tally with what you have specified inside the Cargo plugin.
If the groupId and artifactId project coordinates do not tally, the Cargo plugin will stop with an error.
Mistakes like this are hard to pin point especially if you have transferred this pom.xml from another project which appeared to have worked perfectly. It helps a little if you turn on the DEBUG logging level from the Eclipse preference.
This would have been what you will see with DEBUG logging level:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.3:deploy (default-cli) on project hms-web: Artifact [sg.java:hms-web:war] is not a dependency of the project. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.3:deploy (default-cli) on project hms-web: Artifact [sg.java:hms-web:war] is not a dependency of the project. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) 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:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:60) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:354) Caused by: org.apache.maven.plugin.MojoExecutionException: Artifact [sg.java:hms-web:war] is not a dependency of the project. at org.codehaus.cargo.maven2.configuration.AbstractDependency.findArtifactLocation(AbstractDependency.java:182) at org.codehaus.cargo.maven2.configuration.Deployable.computeLocation(Deployable.java:303) at org.codehaus.cargo.maven2.configuration.Deployable.createDeployable(Deployable.java:177) at org.codehaus.cargo.maven2.AbstractDeployerMojo.performDeployerActionOnAllDeployables(AbstractDeployerMojo.java:187) at org.codehaus.cargo.maven2.AbstractDeployerMojo.doExecute(AbstractDeployerMojo.java:103) at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo.java:279) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more
Run Custom Maven Goals In Eclipse
Mar 19th
While starters may be comfortable with, and benefit much from entering maven commands from command line (or shell in the case of Linux), this tedious notion can be greatly alleviated with a simple no frills and quick setup on Eclipse.
It is assumed that you already have m2clipse Maven plugin installed into your Eclipse IDE. If you don’t, this guide from Sonatype provides concise instructions to help you. http://m2eclipse.sonatype.org/installing-m2eclipse.html
Running s simple Maven goal (clean) in shell ~
bash-3.2$ mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Virtualization Management Console 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ web.vms ---
[INFO] Deleting C:\c\development projects\project ejb3.1\ide_workspace\ejb3.1_eclipse_workspace\web.vms\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.437s
[INFO] Finished at: Sat Mar 19 17:03:42 SGT 2011
[INFO] Final Memory: 4M/119M
[INFO] ------------------------------------------------------------------------
Running the same Maven goal in Eclipse with m2clipse Sonatype Eclipse plugin
However, as there are only so Maven goals supplied by default (clean, build, package … ) with the plugin, you need to customize a little if you wish to run more complex goals, especially with another Maven plugin, or stacked goals.
For example, say you need to run a Maven command to clean, package, then deploy to your application server. In one look you need something like:
$ mvn clean package cargo:deploy
Cargo is a deployment tool that works for many popular Application Servers. Look at http://java.sg/managing-deployment-to-jboss-application-server-using-maven-through-cargo-plugin/ for an example on how to configure your pom.xml to deploy a JSF 2.0 project into JBoss AS.
To do this in Eclipse IDE:
1. Open ‘Run Configurations‘ through clicking on the arrow beside the Run icon.
This should open up the Run Configurations dialog box.
2. Right click on the ‘Maven Build‘ tree node and create a ‘New‘ configuration.
This should bring up the new configuration dialog box.
3. Specify the project that this custom Maven command should run on by clicking on the ‘Browse Workspace‘ button, select your project.
4. Enter the Maven goals that you need, in this case ‘clean package cargo:redeploy‘
clean build cargo:redeploy
5. Give your configuration a meaningful name. You may name your configuration using the following convention:
<project name> + <maven goal 1> + [... <maven goal 2>]
For example,
vsphere clean package cargo-redeploy
6. Find and run your newly created custom Maven goal by click on the ‘Run‘ icon
7. Watch the output from the Eclipse console view.
Complete!










