Maven Tutorial – a recap – I

Before getting started with this tutorial, pls ensure you have the following.

  • JDK is installed
  • JAVA_HOME is correctly defined
  • Maven is installed
  • JAVA_HOME/bin is added to PATH
  • maven_install_folder/bin is added to PATH

My meals on Emirates, Dubai to London

Test your Maven version

D:\maven>mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 19:21:28+0530)
Maven home: D:\apache-maven-3.0.5\bin\..
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: c:\Program Files\Java\jdk1.7.0_17\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 8", version: "6.2", arch: "amd64", family: "windows"

maven_logo

Create a new Project Environment

D:\maven>mvn archetype:generate -DgroupId=org.grassfield.mvn -DartififactId=mvn-tutorial -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.534s
[INFO] Finished at: Wed Jun 26 06:31:58 IST 2013
[INFO] Final Memory: 6M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'archetype' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\pandian\.m2\repository), central (http://repo.maven.apache.org/maven2)%5D -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/NoPluginFoundForPrefixException

This error "[ERROR] No plugin found for prefix 'archetype' in the current project" can arise in two scenarios, I guess.

  • When you are behind a proxy (I'm not)
  • When you are using Windows 8

Mine is the second one. Pls find the fix here

So, we are running the same command with additional JVM parameter now

mvn archetype:generate -DgroupId=org.grassfield.mvn -DartififactId=mvn-tutorial -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -Djava.net.preferIPv4Stack=true

[WARNING] Property artifactId is missing. Add -DartifactId=someValue
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5:24.928s
[INFO] Finished at: Wed Jun 26 07:28:05 IST 2013
[INFO] Final Memory: 13M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: Archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.0 is not configured
[ERROR] Property artifactId is missing.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: Archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.0 is not configured
Property artifactId is missing.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
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:59)
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:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:352)
Caused by: org.apache.maven.plugin.MojoFailureException: Archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.0 is not configured
Property artifactId is missing.
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:221)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.apache.maven.archetype.exception.ArchetypeNotConfigured: Archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.0 is not configured
Property artifactId is missing.
at org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator.configureArchetype(DefaultArchetypeGenerationConfigurator.java:272)
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:205)
... 21 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoFailureException

That was due to incorrect Artifact Id given by me, and now

mvn archetype:generate -DgroupId=org.grassfield.mvn -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -e -Djava.net.preferIPv4Stack=true

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.grassfield.mvn
[INFO] Parameter: packageName, Value: org.grassfield.mvn
[INFO] Parameter: package, Value: org.grassfield.mvn
[INFO] Parameter: artifactId, Value: my-app
[INFO] Parameter: basedir, Value: D:\maven
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: D:\maven\my-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.152s
[INFO] Finished at: Wed Jun 26 07:57:55 IST 2013
[INFO] Final Memory: 13M/218M
[INFO] ------------------------------------------------------------------------

(to be continued...)

About these ads

One thought on “Maven Tutorial – a recap – I

  1. Pingback: Maven Tutorial – a recap – II | JavaShine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s