Meaningless Drivel is fun!*
The moose likes Ant, Maven and Other Build Tools and the fly likes how to run a project using maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "how to run a project using maven" Watch "how to run a project using maven" New topic
Author

how to run a project using maven

Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
hi,
I am new to maven. I have a few doubts -

1. where does the local repository get created once maven is installed?
2. The directory structure like src,main,target etc... do they get created automatically. i mean where are the artifacts placed? do we have to create the structure explicitly?
3. how to customize the settings.xml n how to run a sample project on maven?

help needed.

Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

I'm not a Maven maven, but a number of popular project types come with a prototype option so you can use Maven to build a blank project with the appropriate deirectory structures and files. I actually made a prototype myself for JSF/Facelet/JPA/Hibernate webapp projects. The process is fairly simple and it's documented on the maven.apache.org site.

Config info is kept in a per-user config directory whose name depends on what version of Maven you're using.


Customer surveys are for companies who didn't pay proper attention to begin with.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

1. The local repositorygets created in the %USER_HOME%/.m2 directory by default, though this can be configured to go to another location.

2. In general, no - Maven creates the directory structure for you when you create a Maven project through the archetype plugin.

3. As for the settings.xml - Reference to Maven's settings.xml. As for the second part of this question - that's a big topic - I'd agree with Tim that you should probably look at some projects that already use Maven and see how they do things.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

"Archetype" is the Maven term I was thinking of when I said "prototype project".

You can see the use of an archetype in the 5-minute getting started guide:
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

For custom archetypes, see http://maven.apache.org/guides/introduction/introduction-to-archetypes.html
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
Thanks for guiding me.

While running the command for creating the archetype -

mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

initially the error said - no archetype plugin found. I copied the archetype plugin into the lib folder of maven. Now the error says -

Internal error in the plugin manager executing goal 'org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-3:create': Cannot find Plexus container for plugin: org.apache.maven.plugins:maven-archetype-plugin

where do i find plexus container?
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
i copied the plexus containers from the maven site. Still, m getting the same error.
Simon Joseph Aquilina
Ranch Hand

Joined: Feb 14, 2006
Posts: 102
Hi,

if you have an internet connection on, then maven should download all the plugins you need automatically! If this is not happening, then I sugest you connect to the internet and try that command again! If it still does not work then maybe the remote repository has been labeled as not accessable! What I did for this is delete the repository folder in the .m2 folder, make sure you are connected to the internet, and try that command again!

Regards,
Sim085
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
the plexus container issue is still not resolved...
the steps i followed -
1. unzip maven
2. set the JAVA_HOME variable to the JDK
3. set the PATH variable to the maven's bin
4. execute mvn --version, to see the version which is in use
5. create a project -
mvn archetype:create -DgroupId=com.demo.app -DartifactId=my-app

At this step, i get an error - The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found.

I downloaded archetype plugin explicitly....now the error says - plexus container not found in the plugin. I even downloaded plexus container jars. Still the error exist.
I am connected to the internet for maven to download plugins during run time for all the operations.

Where am i going wrong?
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
my local repository is not getting created? does unzipping maven itself create a local rep .m2?
any settings to be done in settings.xml?
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
I got it....it was with my settings.xml - proxy settings.
Thanks to all for guiding me.
Murali Mohan Atmakuri
Greenhorn

Joined: Jan 02, 2006
Posts: 20
hi,

Could you please let me know how you resolved it because i am facing the same problem.

Thanks,
Murali


SCJP, SCWCD, SCBCD,OCP 9i - basics
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Vani,

I have changed the settings.xml to have the right proxy and have configured the mirror as well.

My error is -

[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = 'ea866874c9
68b794a16d61f6a2f8351273e30e66'; remote = 'b0280b2e376542c692104f38b14a4892e509a
379' - IGNORING
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The PluginDescriptor for the plugin Plugin [org.apache.maven.plugins:mave
n-archetype-plugin] was not found.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.IllegalStateException: The PluginDescriptor for the plugin Plugin [org
.apache.maven.plugins:maven-archetype-plugin] was not found.
at org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginM
anager.java:317)


Can you please help

Regards
Menon


SCJP , SCWCD , SCBCD , SCDJWS
barron logan
Greenhorn

Joined: Jun 30, 2004
Posts: 6
Vani,

What exactly was the problem with your proxy settings....
Can you expand on how you resolved this. I am having the same issue.
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
The problem was because the internet policy in our company was obstructing the download of the jars. So when maven runs , it tries updating the respo and fails.

Check with your network administrator, if you are getting the same problem even after the proxy settings are right.

regards
Menon
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

DontWakeTheZombies

(Although I guess following up a year and a half later might help somebody.)
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Yes David

Was going through the old Maven posts and realised I had not posted the solution. Its a very common prob and this might come into some use for someone!

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to run a project using maven