Getting started with Maven!

· Read in about 1 min · (199 Words)

I installed Maven on my Fedora 12 box and fired the command listed at How_do_I_make_my_first_Maven_project :

$ mvn archetype:create \
   -DarchetypeGroupId=org.apache.maven.archetypes \
   -DgroupId=com.mycompany.app \
   -DartifactId=my-app
/usr/lib/jvm/java
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu May 20 13:15:56 GMT+05:30 2010
[INFO] Final Memory: 13M/26M
[INFO] -----------------------

I tried to debug it further by adding -X and -e options to the commandline. It didn’t work! After a lot of googling around I found that the default repository site ( http://www.ibiblio.org/ ) is not responding. So I added a mirror url to my local maven repository:

$ cat ~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"               
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0           
                      http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
  <localRepository/>                                                   
  <interactiveMode/>                                                   
  <usePluginRegistry/>                                                 
  <offline/>                                                           
  <pluginGroups/>                                                      
  <servers/>                                                           
  <mirrors>                                                            
    <mirror>                                                           
      <id>maven2repo</id>                                              
      <name>MavenRepo</name>                                           
      <url>http://repo2.maven.org/maven2/</url>                        
      <mirrorOf>central</mirrorOf>                                     
    </mirror>                                                          
  </mirrors>                                                           
  <proxies/>                                                           
  <profiles/>                                                          
  <activeProfiles/>                                                    
</settings>                                                            

This time I added additional option -U to the command line ( as per suggestion from irc://irc.codehaus.org/maven ):

mvn -U -X -e archetype:create\
   -DarchetypeGroupId=org.apache.maven.archetypes\
   -DgroupId=com.mycompany.app\
   -DartifactId=my-app

Thats it. It worked perfectly.